From b73420ec5302f7b37c66d29f10f87da1cc31bb01 Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Mon, 22 Jul 2019 19:48:19 +0200 Subject: [PATCH] Add set_boot_device hook in `redfish` boot interface Added `_set_boot_device()` method to `redfish` boot interface to let future fishy hardware types reusing standard `redfish` implementation modulo setting boot device procedure. With Redfish, it seems, setting node to boot from Cd implies booting from either virtual or physical CD depending on media presence in either of the devices. Change-Id: I576b90be46f9cadf1a051e17c95a98aefc83fe1f --- ironic/drivers/modules/redfish/boot.py | 25 ++++++++++++++++--- .../unit/drivers/modules/redfish/test_boot.py | 4 +-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 263649939d..2d5295b2ef 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -613,7 +613,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): boot_mode_utils.sync_boot_mode(task) - manager_utils.node_set_boot_device(task, boot_devices.CDROM) + self._set_boot_device(task, boot_devices.CDROM) LOG.debug("Node %(node)s is set to one time boot from " "%(device)s", {'node': task.node.uuid, @@ -672,7 +672,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): self.clean_up_instance(task) iwdi = node.driver_internal_info.get('is_whole_disk_image') if boot_option == "local" or iwdi: - manager_utils.node_set_boot_device( + self._set_boot_device( task, boot_devices.DISK, persistent=True) LOG.debug("Node %(node)s is set to permanently boot from local " @@ -690,7 +690,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): "The UUID of the root partition could not be found for " "node %s. Booting instance from disk anyway.", node.uuid) - manager_utils.node_set_boot_device( + self._set_boot_device( task, boot_devices.DISK, persistent=True) return @@ -704,7 +704,7 @@ class RedfishVirtualMediaBoot(base.BootInterface): boot_mode_utils.sync_boot_mode(task) - manager_utils.node_set_boot_device( + self._set_boot_device( task, boot_devices.CDROM, persistent=True) LOG.debug("Node %(node)s is set to permanently boot from " @@ -816,3 +816,20 @@ class RedfishVirtualMediaBoot(base.BootInterface): for v_media in manager.virtual_media.get_members(): if boot_device in v_media.media_types: return True + + @classmethod + def _set_boot_device(cls, task, device, persistent=False): + """Set the boot device for a node. + + This is a hook to allow other boot interfaces, inheriting from standard + `redfish` boot interface, implement their own weird ways of setting + boot device. + + :param task: a TaskManager instance. + :param device: Boot device. Values are vendor-specific. + :param persistent: Whether to set next-boot, or make the change + permanent. Default: False. + :raises: InvalidParameterValue if the validation of the + ManagementInterface fails. + """ + manager_utils.node_set_boot_device(task, device, persistent) diff --git a/ironic/tests/unit/drivers/modules/redfish/test_boot.py b/ironic/tests/unit/drivers/modules/redfish/test_boot.py index 7e0d24766b..82aba08494 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_boot.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_boot.py @@ -432,7 +432,7 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase): task, expected_params, 'deploy') mock_manager_utils.node_set_boot_device.assert_called_once_with( - task, boot_devices.CDROM) + task, boot_devices.CDROM, False) mock_boot_mode_utils.sync_boot_mode.assert_called_once_with(task) @@ -501,7 +501,7 @@ class RedfishVirtualMediaBootTestCase(db_base.DbTestCase): task, expected_params, 'deploy') mock_manager_utils.node_set_boot_device.assert_called_once_with( - task, boot_devices.CDROM) + task, boot_devices.CDROM, False) mock_boot_mode_utils.sync_boot_mode.assert_called_once_with(task)