Merge "Fix to return 'root_uuid' as part of command status"

This commit is contained in:
Zuul 2017-10-25 23:06:17 +00:00 committed by Gerrit Code Review
commit 3e1724ca86
4 changed files with 40 additions and 15 deletions

View File

@ -25,7 +25,7 @@ RUN proxy.sh apt-get update && \
proxy.sh apt-get -y upgrade && \ proxy.sh apt-get -y upgrade && \
proxy.sh apt-get install -y --no-install-recommends gdisk python2.7 python2.7-dev \ 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 \ 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 proxy.sh apt-get --only-upgrade -t jessie-backports install -y qemu-utils
# Some cleanup # Some cleanup

View File

@ -154,7 +154,9 @@ def _message_format(msg, image_info, device, partition_uuids):
result_msg = msg + 'root_uuid={}' result_msg = msg + 'root_uuid={}'
message = result_msg.format(image_info['id'], device, root_uuid) message = result_msg.format(image_info['id'], device, root_uuid)
else: 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 return message

View File

@ -29,7 +29,8 @@ def _build_fake_image_info():
'urls': [ 'urls': [
'http://example.org', 'http://example.org',
], ],
'checksum': 'abc123' 'checksum': 'abc123',
'image_type': 'whole-disk-image',
} }
@ -374,6 +375,8 @@ class TestStandbyExtension(base.IronicAgentTest):
standby._verify_image, standby._verify_image,
image_info, image_location, checksum) 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', @mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.extensions.standby._write_image', @mock.patch('ironic_python_agent.extensions.standby._write_image',
@ -395,8 +398,9 @@ class TestStandbyExtension(base.IronicAgentTest):
self.agent_extension.cached_image_id) self.agent_extension.cached_image_id)
self.assertEqual('SUCCEEDED', async_result.command_status) self.assertEqual('SUCCEEDED', async_result.command_status)
self.assertIn('result', async_result.command_result) self.assertIn('result', async_result.command_result)
cmd_result = ('cache_image: image ({}) cached to device ' cmd_result = ('cache_image: image ({}) cached to device {} '
'{} ').format(image_info['id'], 'manager') 'root_uuid={}').format(image_info['id'], 'manager',
'ROOT')
self.assertEqual(cmd_result, async_result.command_result['result']) self.assertEqual(cmd_result, async_result.command_result['result'])
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
@ -425,6 +429,8 @@ class TestStandbyExtension(base.IronicAgentTest):
'root_uuid') 'root_uuid')
self.assertEqual(cmd_result, async_result.command_result['result']) 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', @mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.extensions.standby._write_image', @mock.patch('ironic_python_agent.extensions.standby._write_image',
@ -449,10 +455,12 @@ class TestStandbyExtension(base.IronicAgentTest):
self.agent_extension.cached_image_id) self.agent_extension.cached_image_id)
self.assertEqual('SUCCEEDED', async_result.command_status) self.assertEqual('SUCCEEDED', async_result.command_status)
self.assertIn('result', async_result.command_result) self.assertIn('result', async_result.command_result)
cmd_result = ('cache_image: image ({}) cached to device ' cmd_result = ('cache_image: image ({}) cached to device {} '
'{} ').format(image_info['id'], 'manager') 'root_uuid=ROOT').format(image_info['id'], 'manager')
self.assertEqual(cmd_result, async_result.command_result['result']) 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', @mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.extensions.standby._write_image', @mock.patch('ironic_python_agent.extensions.standby._write_image',
@ -475,10 +483,12 @@ class TestStandbyExtension(base.IronicAgentTest):
self.agent_extension.cached_image_id) self.agent_extension.cached_image_id)
self.assertEqual('SUCCEEDED', async_result.command_status) self.assertEqual('SUCCEEDED', async_result.command_status)
self.assertIn('result', async_result.command_result) self.assertIn('result', async_result.command_result)
cmd_result = ('cache_image: image ({}) already present on device ' cmd_result = ('cache_image: image ({}) already present on device {} '
'{} ').format(image_info['id'], 'manager') 'root_uuid=ROOT').format(image_info['id'], 'manager')
self.assertEqual(cmd_result, async_result.command_result['result']) 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', @mock.patch('ironic_lib.disk_utils.create_config_drive_partition',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @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.assertEqual('SUCCEEDED', async_result.command_status)
self.assertIn('result', async_result.command_result) self.assertIn('result', async_result.command_result)
cmd_result = ('prepare_image: image ({}) written to device ' cmd_result = ('prepare_image: image ({}) written to device {} '
'{} ').format(image_info['id'], 'manager') 'root_uuid=ROOT').format(image_info['id'], 'manager')
self.assertEqual(cmd_result, async_result.command_result['result']) self.assertEqual(cmd_result, async_result.command_result['result'])
@mock.patch('ironic_lib.disk_utils.create_config_drive_partition', @mock.patch('ironic_lib.disk_utils.create_config_drive_partition',
@ -575,6 +585,8 @@ class TestStandbyExtension(base.IronicAgentTest):
image_info['id'], 'manager', 'root_uuid') image_info['id'], 'manager', 'root_uuid')
self.assertEqual(cmd_result, async_result.command_result['result']) 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', @mock.patch('ironic_lib.disk_utils.create_config_drive_partition',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @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(0, configdrive_copy_mock.call_count)
self.assertEqual('SUCCEEDED', async_result.command_status) self.assertEqual('SUCCEEDED', async_result.command_status)
self.assertIn('result', async_result.command_result) self.assertIn('result', async_result.command_result)
cmd_result = ('prepare_image: image ({}) written to device ' cmd_result = ('prepare_image: image ({}) written to device {} '
'{} ').format(image_info['id'], 'manager') 'root_uuid=ROOT').format(image_info['id'], 'manager')
self.assertEqual(cmd_result, async_result.command_result['result']) 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', @mock.patch('ironic_lib.disk_utils.create_config_drive_partition',
autospec=True) autospec=True)
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers', @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! # Assert write was only called once and failed!
file_mock.write.assert_called_once_with('some') 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): def test__message_format_whole_disk(self):
image_info = _build_fake_image_info() image_info = _build_fake_image_info()
msg = 'image ({}) already present on device {}' msg = 'image ({}) already present on device {} '
device = '/dev/fake' device = '/dev/fake'
partition_uuids = {} partition_uuids = {}
result_msg = standby._message_format(msg, image_info, result_msg = standby._message_format(msg, image_info,
device, partition_uuids) device, partition_uuids)
expected_msg = ('image (fake_id) already present on device ' expected_msg = ('image (fake_id) already present on device '
'/dev/fake') '/dev/fake root_uuid=ROOT')
self.assertEqual(expected_msg, result_msg) self.assertEqual(expected_msg, result_msg)
def test__message_format_partition_bios(self): def test__message_format_partition_bios(self):

View File

@ -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
<https://bugs.launchpad.net/ironic/+bug/1713916>`_ for details.