Merge "Catch OSError thrown when hexdump is missing"
This commit is contained in:
commit
e789ec8898
|
@ -154,9 +154,17 @@ 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:
|
||||
root_uuid = disk_utils.get_disk_identifier(device)
|
||||
result_msg = msg + 'root_uuid={}'
|
||||
message = result_msg.format(image_info['id'], device, root_uuid)
|
||||
try:
|
||||
# NOTE(TheJulia): ironic-lib disk_utils.get_disk_identifier
|
||||
# can raise OSError if hexdump is not found.
|
||||
root_uuid = disk_utils.get_disk_identifier(device)
|
||||
result_msg = msg + 'root_uuid={}'
|
||||
message = result_msg.format(image_info['id'], device, root_uuid)
|
||||
except OSError as e:
|
||||
LOG.warning('Failed to call get_disk_identifier: '
|
||||
'Unable to obtain the root_uuid parameter: '
|
||||
'The hexdump tool may be missing in IPA: %s', e)
|
||||
message = result_msg.format(image_info['id'], device)
|
||||
return message
|
||||
|
||||
|
||||
|
|
|
@ -887,6 +887,21 @@ class TestStandbyExtension(base.IronicAgentTest):
|
|||
'efi_system_partition_uuid=efi_id')
|
||||
self.assertEqual(expected_msg, result_msg)
|
||||
|
||||
@mock.patch('ironic_lib.disk_utils.get_disk_identifier',
|
||||
autospec=True)
|
||||
def test__message_format_whole_disk_missing_oserror(self,
|
||||
ident_mock):
|
||||
ident_mock.side_effect = OSError
|
||||
image_info = _build_fake_image_info()
|
||||
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')
|
||||
self.assertEqual(expected_msg, result_msg)
|
||||
|
||||
|
||||
class TestImageDownload(base.IronicAgentTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue