Merge "Add information 'node_uuid' in debug logs to facilitate the reader's life"
This commit is contained in:
@@ -235,8 +235,8 @@ def get_disk_identifier(dev):
|
||||
|
||||
|
||||
def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
|
||||
configdrive_mb, commit=True, boot_option="netboot",
|
||||
boot_mode="bios"):
|
||||
configdrive_mb, node_uuid, commit=True,
|
||||
boot_option="netboot", boot_mode="bios"):
|
||||
"""Partition the disk device.
|
||||
|
||||
Create partitions for root, swap, ephemeral and configdrive on a
|
||||
@@ -253,12 +253,14 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
|
||||
partitions will not be written to disk.
|
||||
:param boot_option: Can be "local" or "netboot". "netboot" by default.
|
||||
:param boot_mode: Can be "bios" or "uefi". "bios" by default.
|
||||
:param node_uuid: Node's uuid. Used for logging.
|
||||
:returns: A dictionary containing the partition type as Key and partition
|
||||
path as Value for the partitions created by this method.
|
||||
|
||||
"""
|
||||
LOG.debug("Starting to partition the disk device: %(dev)s",
|
||||
{'dev': dev})
|
||||
LOG.debug("Starting to partition the disk device: %(dev)s "
|
||||
"for node %(node)s",
|
||||
{'dev': dev, 'node': node_uuid})
|
||||
part_template = dev + '-part%d'
|
||||
part_dict = {}
|
||||
|
||||
@@ -274,26 +276,30 @@ def make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
|
||||
dp = disk_partitioner.DiskPartitioner(dev)
|
||||
|
||||
if ephemeral_mb:
|
||||
LOG.debug("Add ephemeral partition (%(size)d MB) to device: %(dev)s",
|
||||
{'dev': dev, 'size': ephemeral_mb})
|
||||
LOG.debug("Add ephemeral partition (%(size)d MB) to device: %(dev)s "
|
||||
"for node %(node)s",
|
||||
{'dev': dev, 'size': ephemeral_mb, 'node': node_uuid})
|
||||
part_num = dp.add_partition(ephemeral_mb)
|
||||
part_dict['ephemeral'] = part_template % part_num
|
||||
if swap_mb:
|
||||
LOG.debug("Add Swap partition (%(size)d MB) to device: %(dev)s",
|
||||
{'dev': dev, 'size': swap_mb})
|
||||
LOG.debug("Add Swap partition (%(size)d MB) to device: %(dev)s "
|
||||
"for node %(node)s",
|
||||
{'dev': dev, 'size': swap_mb, 'node': node_uuid})
|
||||
part_num = dp.add_partition(swap_mb, fs_type='linux-swap')
|
||||
part_dict['swap'] = part_template % part_num
|
||||
if configdrive_mb:
|
||||
LOG.debug("Add config drive partition (%(size)d MB) to device: "
|
||||
"%(dev)s", {'dev': dev, 'size': configdrive_mb})
|
||||
"%(dev)s for node %(node)s",
|
||||
{'dev': dev, 'size': configdrive_mb, 'node': node_uuid})
|
||||
part_num = dp.add_partition(configdrive_mb)
|
||||
part_dict['configdrive'] = part_template % part_num
|
||||
|
||||
# NOTE(lucasagomes): Make the root partition the last partition. This
|
||||
# enables tools like cloud-init's growroot utility to expand the root
|
||||
# partition until the end of the disk.
|
||||
LOG.debug("Add root partition (%(size)d MB) to device: %(dev)s",
|
||||
{'dev': dev, 'size': root_mb})
|
||||
LOG.debug("Add root partition (%(size)d MB) to device: %(dev)s "
|
||||
"for node %(node)s",
|
||||
{'dev': dev, 'size': root_mb, 'node': node_uuid})
|
||||
part_num = dp.add_partition(root_mb, bootable=(boot_option == "local" and
|
||||
boot_mode == "bios"))
|
||||
part_dict['root'] = part_template % part_num
|
||||
@@ -603,7 +609,8 @@ def work_on_disk(dev, root_mb, swap_mb, ephemeral_mb, ephemeral_format,
|
||||
node_uuid)
|
||||
|
||||
part_dict = make_partitions(dev, root_mb, swap_mb, ephemeral_mb,
|
||||
configdrive_mb, commit=commit,
|
||||
configdrive_mb, node_uuid,
|
||||
commit=commit,
|
||||
boot_option=boot_option,
|
||||
boot_mode=boot_mode)
|
||||
LOG.info(_LI("Successfully completed the disk device"
|
||||
|
||||
@@ -313,7 +313,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
'swap': swap_part}
|
||||
|
||||
make_partitions_expected_args = [dev, root_mb, swap_mb, ephemeral_mb,
|
||||
configdrive_mb]
|
||||
configdrive_mb, node_uuid]
|
||||
make_partitions_expected_kwargs = {'commit': True}
|
||||
deploy_kwargs = {}
|
||||
|
||||
@@ -458,6 +458,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
mock.call.make_partitions(dev, root_mb, swap_mb,
|
||||
ephemeral_mb,
|
||||
configdrive_mb,
|
||||
node_uuid,
|
||||
commit=True,
|
||||
boot_option="local",
|
||||
boot_mode="uefi"),
|
||||
@@ -521,6 +522,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
mock.call.make_partitions(dev, root_mb, swap_mb,
|
||||
ephemeral_mb,
|
||||
configdrive_mb,
|
||||
node_uuid,
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios"),
|
||||
@@ -581,6 +583,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
mock.call.make_partitions(dev, root_mb, swap_mb,
|
||||
ephemeral_mb,
|
||||
configdrive_mb,
|
||||
node_uuid,
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios"),
|
||||
@@ -647,6 +650,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
mock.call.make_partitions(dev, root_mb, swap_mb,
|
||||
ephemeral_mb,
|
||||
configdrive_mb,
|
||||
node_uuid,
|
||||
commit=False,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios"),
|
||||
@@ -713,6 +717,7 @@ class PhysicalWorkTestCase(tests_base.TestCase):
|
||||
mock.call.make_partitions(dev, root_mb, swap_mb,
|
||||
ephemeral_mb,
|
||||
configdrive_mb,
|
||||
node_uuid,
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios"),
|
||||
@@ -1174,7 +1179,9 @@ class WorkOnDiskTestCase(tests_base.TestCase):
|
||||
self.mock_ibd.assert_called_once_with(self.root_part)
|
||||
self.mock_mp.assert_called_once_with(self.dev, self.root_mb,
|
||||
self.swap_mb, self.ephemeral_mb,
|
||||
self.configdrive_mb, commit=True,
|
||||
self.configdrive_mb,
|
||||
'fake-uuid',
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios")
|
||||
|
||||
@@ -1189,7 +1196,9 @@ class WorkOnDiskTestCase(tests_base.TestCase):
|
||||
self.assertEqual(self.mock_ibd.call_args_list, calls)
|
||||
self.mock_mp.assert_called_once_with(self.dev, self.root_mb,
|
||||
self.swap_mb, self.ephemeral_mb,
|
||||
self.configdrive_mb, commit=True,
|
||||
self.configdrive_mb,
|
||||
'fake-uuid',
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios")
|
||||
|
||||
@@ -1214,7 +1223,9 @@ class WorkOnDiskTestCase(tests_base.TestCase):
|
||||
self.assertEqual(self.mock_ibd.call_args_list, calls)
|
||||
self.mock_mp.assert_called_once_with(self.dev, self.root_mb,
|
||||
self.swap_mb, ephemeral_mb,
|
||||
self.configdrive_mb, commit=True,
|
||||
self.configdrive_mb,
|
||||
'fake-uuid',
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios")
|
||||
|
||||
@@ -1245,7 +1256,9 @@ class WorkOnDiskTestCase(tests_base.TestCase):
|
||||
self.assertEqual(self.mock_ibd.call_args_list, calls)
|
||||
self.mock_mp.assert_called_once_with(self.dev, self.root_mb,
|
||||
self.swap_mb, self.ephemeral_mb,
|
||||
configdrive_mb, commit=True,
|
||||
configdrive_mb,
|
||||
'fake-uuid',
|
||||
commit=True,
|
||||
boot_option="netboot",
|
||||
boot_mode="bios")
|
||||
mock_unlink.assert_called_once_with('fake-path')
|
||||
@@ -1268,6 +1281,7 @@ class MakePartitionsTestCase(tests_base.TestCase):
|
||||
mock_exc.return_value = (None, None)
|
||||
utils.make_partitions(self.dev, self.root_mb, self.swap_mb,
|
||||
self.ephemeral_mb, self.configdrive_mb,
|
||||
'12345678-1234-1234-1234-1234567890abcxyz',
|
||||
boot_option=boot_option)
|
||||
|
||||
expected_mkpart = ['mkpart', 'primary', 'linux-swap', '1', '513',
|
||||
@@ -1296,7 +1310,8 @@ class MakePartitionsTestCase(tests_base.TestCase):
|
||||
cmd = self.parted_static_cmd + expected_mkpart
|
||||
mock_exc.return_value = (None, None)
|
||||
utils.make_partitions(self.dev, self.root_mb, self.swap_mb,
|
||||
self.ephemeral_mb, self.configdrive_mb)
|
||||
self.ephemeral_mb, self.configdrive_mb,
|
||||
'12345678-1234-1234-1234-1234567890abcxyz')
|
||||
|
||||
parted_call = mock.call(*cmd, run_as_root=True, check_exit_code=[0])
|
||||
mock_exc.assert_has_calls([parted_call])
|
||||
|
||||
Reference in New Issue
Block a user