Fix redfish-virtual-media boot mode handling ordering

Currently sync_boot_mode does not happen for nodes with local boot
because of an early return. This patches fixes it.

Change-Id: I37b91f93f8f1ca41b814199ec1c5733611b28299
This commit is contained in:
Dmitry Tantsur 2021-01-14 17:30:50 +01:00
parent 07bdccea58
commit ad044d9e0b
3 changed files with 10 additions and 3 deletions

View File

@ -505,6 +505,8 @@ class RedfishVirtualMediaBoot(base.BootInterface):
"""
node = task.node
boot_mode_utils.sync_boot_mode(task)
boot_option = deploy_utils.get_boot_option(node)
self.clean_up_instance(task)
iwdi = node.driver_internal_info.get('is_whole_disk_image')
@ -547,8 +549,6 @@ class RedfishVirtualMediaBoot(base.BootInterface):
_('Cannot attach configdrive for node %s: no suitable '
'virtual USB slot has been found') % node.uuid)
boot_mode_utils.sync_boot_mode(task)
self._set_boot_device(task, boot_devices.CDROM, persistent=True)
LOG.debug("Node %(node)s is set to permanently boot from "

View File

@ -710,12 +710,13 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
mock_boot_mode_utils.sync_boot_mode.assert_called_once_with(task)
@mock.patch.object(boot_mode_utils, 'sync_boot_mode', autospec=True)
@mock.patch.object(redfish_boot, 'eject_vmedia', autospec=True)
@mock.patch.object(image_utils, 'cleanup_iso_image', autospec=True)
@mock.patch.object(redfish_boot, 'manager_utils', autospec=True)
def _test_prepare_instance_local_boot(
self, mock_manager_utils,
mock_cleanup_iso_image, mock__eject_vmedia):
mock_cleanup_iso_image, mock__eject_vmedia, mock_sync_boot_mode):
with task_manager.acquire(self.context, self.node.uuid,
shared=True) as task:
@ -730,6 +731,7 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase):
mock_cleanup_iso_image.assert_called_once_with(task)
mock__eject_vmedia.assert_called_once_with(
task, sushy.VIRTUAL_MEDIA_CD)
mock_sync_boot_mode.assert_called_once_with(task)
def test_prepare_instance_local_whole_disk_image(self):
self.node.driver_internal_info = {'is_whole_disk_image': True}

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Boot mode is now correctly handled when using ``redfish-virtual-media``
boot with locally booted images.