diff --git a/Dockerfile b/Dockerfile index 8c7a56a68..fda630f91 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,7 +25,7 @@ RUN proxy.sh apt-get update && \ proxy.sh apt-get -y upgrade && \ proxy.sh apt-get install -y --no-install-recommends gdisk python2.7 python2.7-dev \ python-pip qemu-utils parted hdparm util-linux genisoimage git gcc \ - bash coreutils tgt dmidecode ipmitool psmisc dosfstools && \ + bash coreutils tgt dmidecode ipmitool psmisc dosfstools bsdmainutils && \ proxy.sh apt-get --only-upgrade -t jessie-backports install -y qemu-utils # Some cleanup diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py index fa597de8a..6e0d82683 100644 --- a/ironic_python_agent/extensions/standby.py +++ b/ironic_python_agent/extensions/standby.py @@ -154,7 +154,9 @@ def _message_format(msg, image_info, device, partition_uuids): result_msg = msg + 'root_uuid={}' message = result_msg.format(image_info['id'], device, root_uuid) else: - message = result_msg.format(image_info['id'], device) + root_uuid = disk_utils.get_disk_identifier(device) + result_msg = msg + 'root_uuid={}' + message = result_msg.format(image_info['id'], device, root_uuid) return message diff --git a/ironic_python_agent/tests/unit/extensions/test_standby.py b/ironic_python_agent/tests/unit/extensions/test_standby.py index 5ad718c01..8187bb8fd 100644 --- a/ironic_python_agent/tests/unit/extensions/test_standby.py +++ b/ironic_python_agent/tests/unit/extensions/test_standby.py @@ -29,7 +29,8 @@ def _build_fake_image_info(): 'urls': [ 'http://example.org', ], - 'checksum': 'abc123' + 'checksum': 'abc123', + 'image_type': 'whole-disk-image', } @@ -374,6 +375,8 @@ class TestStandbyExtension(base.IronicAgentTest): standby._verify_image, image_info, image_location, checksum) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', autospec=True) @mock.patch('ironic_python_agent.extensions.standby._write_image', @@ -395,8 +398,9 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension.cached_image_id) self.assertEqual('SUCCEEDED', async_result.command_status) self.assertIn('result', async_result.command_result) - cmd_result = ('cache_image: image ({}) cached to device ' - '{} ').format(image_info['id'], 'manager') + cmd_result = ('cache_image: image ({}) cached to device {} ' + 'root_uuid={}').format(image_info['id'], 'manager', + 'ROOT') self.assertEqual(cmd_result, async_result.command_result['result']) @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @@ -425,6 +429,8 @@ class TestStandbyExtension(base.IronicAgentTest): 'root_uuid') self.assertEqual(cmd_result, async_result.command_result['result']) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', autospec=True) @mock.patch('ironic_python_agent.extensions.standby._write_image', @@ -449,10 +455,12 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension.cached_image_id) self.assertEqual('SUCCEEDED', async_result.command_status) self.assertIn('result', async_result.command_result) - cmd_result = ('cache_image: image ({}) cached to device ' - '{} ').format(image_info['id'], 'manager') + cmd_result = ('cache_image: image ({}) cached to device {} ' + 'root_uuid=ROOT').format(image_info['id'], 'manager') self.assertEqual(cmd_result, async_result.command_result['result']) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', autospec=True) @mock.patch('ironic_python_agent.extensions.standby._write_image', @@ -475,10 +483,12 @@ class TestStandbyExtension(base.IronicAgentTest): self.agent_extension.cached_image_id) self.assertEqual('SUCCEEDED', async_result.command_status) self.assertIn('result', async_result.command_result) - cmd_result = ('cache_image: image ({}) already present on device ' - '{} ').format(image_info['id'], 'manager') + cmd_result = ('cache_image: image ({}) already present on device {} ' + 'root_uuid=ROOT').format(image_info['id'], 'manager') self.assertEqual(cmd_result, async_result.command_result['result']) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_lib.disk_utils.create_config_drive_partition', autospec=True) @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @@ -513,8 +523,8 @@ class TestStandbyExtension(base.IronicAgentTest): self.assertEqual('SUCCEEDED', async_result.command_status) self.assertIn('result', async_result.command_result) - cmd_result = ('prepare_image: image ({}) written to device ' - '{} ').format(image_info['id'], 'manager') + cmd_result = ('prepare_image: image ({}) written to device {} ' + 'root_uuid=ROOT').format(image_info['id'], 'manager') self.assertEqual(cmd_result, async_result.command_result['result']) @mock.patch('ironic_lib.disk_utils.create_config_drive_partition', @@ -575,6 +585,8 @@ class TestStandbyExtension(base.IronicAgentTest): image_info['id'], 'manager', 'root_uuid') self.assertEqual(cmd_result, async_result.command_result['result']) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_lib.disk_utils.create_config_drive_partition', autospec=True) @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @@ -607,10 +619,12 @@ class TestStandbyExtension(base.IronicAgentTest): self.assertEqual(0, configdrive_copy_mock.call_count) self.assertEqual('SUCCEEDED', async_result.command_status) self.assertIn('result', async_result.command_result) - cmd_result = ('prepare_image: image ({}) written to device ' - '{} ').format(image_info['id'], 'manager') + cmd_result = ('prepare_image: image ({}) written to device {} ' + 'root_uuid=ROOT').format(image_info['id'], 'manager') self.assertEqual(cmd_result, async_result.command_result['result']) + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') @mock.patch('ironic_lib.disk_utils.create_config_drive_partition', autospec=True) @mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @@ -819,15 +833,17 @@ class TestStandbyExtension(base.IronicAgentTest): # Assert write was only called once and failed! file_mock.write.assert_called_once_with('some') + @mock.patch('ironic_lib.disk_utils.get_disk_identifier', + lambda dev: 'ROOT') def test__message_format_whole_disk(self): image_info = _build_fake_image_info() - msg = 'image ({}) already present on device {}' + msg = 'image ({}) already present on device {} ' device = '/dev/fake' partition_uuids = {} result_msg = standby._message_format(msg, image_info, device, partition_uuids) expected_msg = ('image (fake_id) already present on device ' - '/dev/fake') + '/dev/fake root_uuid=ROOT') self.assertEqual(expected_msg, result_msg) def test__message_format_partition_bios(self): diff --git a/releasenotes/notes/fix-to-pass-root-uuid-for-whole-disk-image-1c13b70f6b74bce0.yaml b/releasenotes/notes/fix-to-pass-root-uuid-for-whole-disk-image-1c13b70f6b74bce0.yaml new file mode 100644 index 000000000..7a187e4e2 --- /dev/null +++ b/releasenotes/notes/fix-to-pass-root-uuid-for-whole-disk-image-1c13b70f6b74bce0.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue wherein IPA does not return ``root_uuid`` as part of + command status when provisioning of whole disk image is performed + using ``agent`` deploy interface from ironic. See `bug 1713916 + `_ for details.