summaryrefslogtreecommitdiff
path: root/ironic_python_agent/extensions
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@protonmail.com>2020-06-17 14:38:58 +0200
committerDmitry Tantsur <dtantsur@protonmail.com>2020-06-17 14:38:58 +0200
commit6d7ec350ff3f880fa85cb58da91216053e4b4375 (patch)
tree0654568dea5a9b40dcf7ea3cb320695fec6a0b1f /ironic_python_agent/extensions
parent1609551a907a7cffee2a80b5a94847f34fbf74bd (diff)
downloadironic-python-agent-6d7ec350ff3f880fa85cb58da91216053e4b4375.tar.gz
Make get_partition_uuids work with whole disk images
We used to popular root UUID inside the message formatting function, move it to actual prepare_image/cache_image calls. Change-Id: Ifb22220dfd49633e8623dd76f7a6a128f5874b78
Diffstat (limited to 'ironic_python_agent/extensions')
-rw-r--r--ironic_python_agent/extensions/standby.py57
1 files changed, 33 insertions, 24 deletions
diff --git a/ironic_python_agent/extensions/standby.py b/ironic_python_agent/extensions/standby.py
index d6621634..d238d76f 100644
--- a/ironic_python_agent/extensions/standby.py
+++ b/ironic_python_agent/extensions/standby.py
@@ -224,31 +224,21 @@ def _message_format(msg, image_info, device, partition_uuids):
"""Helper method to get and populate different messages."""
message = None
result_msg = msg
- if image_info.get('image_type') == 'partition':
- root_uuid = partition_uuids.get('root uuid')
- efi_system_partition_uuid = (
- partition_uuids.get('efi system partition uuid'))
- if (image_info.get('deploy_boot_mode') == 'uefi'
- and image_info.get('boot_option') == 'local'):
- result_msg = msg + 'root_uuid={} efi_system_partition_uuid={}'
- message = result_msg.format(image_info['id'], device,
- root_uuid,
- efi_system_partition_uuid)
- else:
- result_msg = msg + 'root_uuid={}'
- message = result_msg.format(image_info['id'], device, root_uuid)
+
+ root_uuid = partition_uuids.get('root uuid')
+ efi_system_partition_uuid = (
+ partition_uuids.get('efi system partition uuid'))
+ if (image_info.get('deploy_boot_mode') == 'uefi'
+ and image_info.get('boot_option') == 'local'
+ and efi_system_partition_uuid):
+ result_msg = msg + 'root_uuid={} efi_system_partition_uuid={}'
+ message = result_msg.format(image_info['id'], device,
+ root_uuid,
+ efi_system_partition_uuid)
else:
- 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)
+ result_msg = msg + 'root_uuid={}'
+ message = result_msg.format(image_info['id'], device, root_uuid)
+
return message
@@ -546,6 +536,22 @@ class StandbyExtension(base.BaseAgentExtension):
# Note: the catch internal to the helper method logs any errors.
pass
+ def _fix_up_partition_uuids(self, image_info, device):
+ if self.partition_uuids is None:
+ self.partition_uuids = {}
+
+ if image_info.get('image_type') == 'partition':
+ return
+
+ try:
+ root_uuid = disk_utils.get_disk_identifier(device)
+ 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)
+ else:
+ self.partition_uuids['root uuid'] = root_uuid
+
@base.async_command('cache_image', _validate_image_info)
def cache_image(self, image_info=None, force=False):
"""Asynchronously caches specified image to the local OS device.
@@ -571,6 +577,7 @@ class StandbyExtension(base.BaseAgentExtension):
self._cache_and_write_image(image_info, device)
msg = 'image ({}) cached to device {} '
+ self._fix_up_partition_uuids(image_info, device)
result_msg = _message_format(msg, image_info, device,
self.partition_uuids)
@@ -640,6 +647,8 @@ class StandbyExtension(base.BaseAgentExtension):
disk_utils.create_config_drive_partition(node_uuid,
device,
configdrive)
+
+ self._fix_up_partition_uuids(image_info, device)
msg = 'image ({}) written to device {} '
result_msg = _message_format(msg, image_info, device,
self.partition_uuids)