diff --git a/ironic/drivers/modules/redfish/boot.py b/ironic/drivers/modules/redfish/boot.py index 97a17509c4..c69b6b43f8 100644 --- a/ironic/drivers/modules/redfish/boot.py +++ b/ironic/drivers/modules/redfish/boot.py @@ -296,6 +296,21 @@ def _eject_vmedia(task, managers, boot_device=None): return found +def insert_vmedia(task, image_url, device_type): + """Insert virtual CDs and DVDs + + :param task: A task from TaskManager. + :param image_url: + :param device_type: sushy boot device e.g. `VIRTUAL_MEDIA_CD`, + `VIRTUAL_MEDIA_DVD` or `VIRTUAL_MEDIA_FLOPPY` or `None` to + eject everything (default). + :raises: InvalidParameterValue, if no suitable virtual CD or DVD is + found on the node. + """ + system = redfish_utils.get_system(task.node) + _insert_vmedia(task, system.managers, image_url, device_type) + + def eject_vmedia(task, boot_device=None): """Eject virtual CDs and DVDs diff --git a/ironic/drivers/modules/redfish/management.py b/ironic/drivers/modules/redfish/management.py index acdfd9ac4b..0037ff1dbd 100644 --- a/ironic/drivers/modules/redfish/management.py +++ b/ironic/drivers/modules/redfish/management.py @@ -37,6 +37,7 @@ from ironic.conf import CONF from ironic.drivers import base from ironic.drivers.modules import boot_mode_utils from ironic.drivers.modules import deploy_utils +from ironic.drivers.modules.redfish import boot as redfish_boot from ironic.drivers.modules.redfish import firmware_utils from ironic.drivers.modules.redfish import utils as redfish_utils @@ -1334,3 +1335,27 @@ class RedfishManagement(base.ManagementInterface): % {'node': task.node.uuid, 'exc': exc}) LOG.error(msg) raise exception.RedfishError(error=msg) + + @task_manager.require_exclusive_lock + def attach_virtual_media(self, task, device_type, image_url): + """Attach a virtual media device to the node. + + :param task: A task from TaskManager. + :param device_type: A device type from + :data:`ironic.common.boot_devices.VMEDIA_DEVICES`. + :param image_url: URL of the image to attach, HTTP or HTTPS. + + """ + redfish_boot.insert_vmedia(task, image_url, device_type) + + @task_manager.require_exclusive_lock + def detach_virtual_media(self, task, device_type=None): + """Detach some or all virtual media devices from the node. + + :param task: A task from TaskManager. + :param device_type: A device type from + :data:`ironic.common.boot_devices.VMEDIA_DEVICES`. + If not provided, all devices are detached. + + """ + redfish_boot.eject_vmedia(task, device_type) diff --git a/ironic/drivers/modules/redfish/vendor.py b/ironic/drivers/modules/redfish/vendor.py index b9c1f36fed..35a4d6da16 100644 --- a/ironic/drivers/modules/redfish/vendor.py +++ b/ironic/drivers/modules/redfish/vendor.py @@ -95,6 +95,7 @@ class RedfishVendorPassthru(base.VendorInterface): """Eject a virtual media device. Deprecated in favour of the generic API. + This should be removed during the 2024.2 cycle. :param task: A TaskManager object. :param kwargs: The arguments sent with vendor passthru. The optional diff --git a/releasenotes/notes/redfish-attach-detach-vmedia-0056faf815724d10.yaml b/releasenotes/notes/redfish-attach-detach-vmedia-0056faf815724d10.yaml new file mode 100644 index 0000000000..187771c780 --- /dev/null +++ b/releasenotes/notes/redfish-attach-detach-vmedia-0056faf815724d10.yaml @@ -0,0 +1,9 @@ +--- +features: + - | + Adds implementation of attach/detach generic virtual media device + to the Redfish driver. +deprecations: + - | + The redfish vendor eject vmedia action is now deprecated and it will be + removed during the next cycle in favor of the generic API.