From 3c474cf9e3837d862167d7c63b6aff43a9bf38e5 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 14 Jan 2021 17:30:50 +0100 Subject: [PATCH] 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. Conflicts: ironic/drivers/modules/redfish/boot.py ironic/tests/unit/drivers/modules/redfish/test_boot.py Change-Id: I37b91f93f8f1ca41b814199ec1c5733611b28299 (cherry picked from commit ad044d9e0b796fe0b8caab8370a8d040b64e506a) --- ironic/drivers/modules/redfish/boot.py | 4 ++-- ironic/tests/unit/drivers/modules/redfish/test_boot.py | 4 +++- releasenotes/notes/redfish-boot-mode-a44fc569f1baca8f.yaml | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/redfish-boot-mode-a44fc569f1baca8f.yaml diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 15c8352d1b..3e7487fb89 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -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') @@ -536,8 +538,6 @@ class RedfishVirtualMediaBoot(base.BootInterface): _eject_vmedia(task, sushy.VIRTUAL_MEDIA_CD) _insert_vmedia(task, iso_ref, sushy.VIRTUAL_MEDIA_CD) - 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 " diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py index 540b99cebd..fb07cf639c 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py @@ -700,12 +700,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: @@ -720,6 +721,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} diff --git a/releasenotes/notes/redfish-boot-mode-a44fc569f1baca8f.yaml b/releasenotes/notes/redfish-boot-mode-a44fc569f1baca8f.yaml new file mode 100644 index 0000000000..b67f709ffa --- /dev/null +++ b/releasenotes/notes/redfish-boot-mode-a44fc569f1baca8f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Boot mode is now correctly handled when using ``redfish-virtual-media`` + boot with locally booted images.