From 134d90b365273b2f75a3259f78f0cf21c7ead93b Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Tue, 14 Oct 2014 14:15:57 +0400 Subject: [PATCH] Added ext2 into extend_fs method in fuel_agent Without this change it is impossible to extend ext2 file systems which we use for /boot. Change-Id: Icd6a3866a754b32cf0f1aa5f129674c8dfb0e0e4 Implements: blueprint image-based-provisioning --- fuel_agent/tests/test_fs_utils.py | 17 +++++++++++++---- fuel_agent/utils/fs_utils.py | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/fuel_agent/tests/test_fs_utils.py b/fuel_agent/tests/test_fs_utils.py index a02a1af..426b1b6 100644 --- a/fuel_agent/tests/test_fs_utils.py +++ b/fuel_agent/tests/test_fs_utils.py @@ -24,21 +24,30 @@ class TestFSUtils(test_base.BaseTestCase): @mock.patch.object(utils, 'execute') def test_make_fs(self, mock_exec): - fu.make_fs('ext4', ' -F ', ' -L fake_label ', '/dev/fake') + fu.make_fs('ext4', '-F', '-L fake_label', '/dev/fake') mock_exec.assert_called_once_with('mkfs.ext4', '-F', '-L', 'fake_label', '/dev/fake') @mock.patch.object(utils, 'execute') def test_make_fs_swap(self, mock_exec): - fu.make_fs('swap', ' -f ', ' -L fake_label ', '/dev/fake') + fu.make_fs('swap', '-f', '-L fake_label', '/dev/fake') mock_exec.assert_called_once_with('mkswap', '-f', '-L', 'fake_label', '/dev/fake') + @mock.patch.object(utils, 'execute') + def test_extend_fs_ok_ext2(self, mock_exec): + fu.extend_fs('ext2', '/dev/fake') + expected_calls = [ + mock.call('e2fsck', '-yf', '/dev/fake', check_exit_code=[0]), + mock.call('resize2fs', '/dev/fake', check_exit_code=[0]) + ] + self.assertEqual(mock_exec.call_args_list, expected_calls) + @mock.patch.object(utils, 'execute') def test_extend_fs_ok_ext3(self, mock_exec): fu.extend_fs('ext3', '/dev/fake') expected_calls = [ - mock.call('e2fsck', ' -f', '/dev/fake', check_exit_code=[0]), + mock.call('e2fsck', '-yf', '/dev/fake', check_exit_code=[0]), mock.call('resize2fs', '/dev/fake', check_exit_code=[0]) ] self.assertEqual(mock_exec.call_args_list, expected_calls) @@ -47,7 +56,7 @@ class TestFSUtils(test_base.BaseTestCase): def test_extend_fs_ok_ext4(self, mock_exec): fu.extend_fs('ext4', '/dev/fake') expected_calls = [ - mock.call('e2fsck', ' -f', '/dev/fake', check_exit_code=[0]), + mock.call('e2fsck', '-yf', '/dev/fake', check_exit_code=[0]), mock.call('resize2fs', '/dev/fake', check_exit_code=[0]) ] self.assertEqual(mock_exec.call_args_list, expected_calls) diff --git a/fuel_agent/utils/fs_utils.py b/fuel_agent/utils/fs_utils.py index e15bc5e..ae7991c 100644 --- a/fuel_agent/utils/fs_utils.py +++ b/fuel_agent/utils/fs_utils.py @@ -31,10 +31,10 @@ def make_fs(fs_type, fs_options, fs_label, dev): def extend_fs(fs_type, fs_dev): - if fs_type in ('ext3', 'ext4'): + if fs_type in ('ext2', 'ext3', 'ext4'): # ext3,4 file system can be mounted # must be checked with e2fsck -f - utils.execute('e2fsck', ' -f', fs_dev, check_exit_code=[0]) + utils.execute('e2fsck', '-yf', fs_dev, check_exit_code=[0]) utils.execute('resize2fs', fs_dev, check_exit_code=[0]) elif fs_type == 'xfs': # xfs file system must be mounted