Implement generic redfish vmedia attach detach

This patch adds implementation of attach/detach generic virtual
media device to the Redfish driver.
Also the redfish vendor eject vmedia action is now deprecated
and it will be removed during the next cycle in favor of the
generic API.

Change-Id: I9daff59128f537a3da2e882adf5c97be9c4ab8d9
This commit is contained in:
Riccardo Pittau 2024-03-11 15:09:21 +01:00
parent c139b22e8a
commit 237510ae2c
4 changed files with 50 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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.