Merge "Changing boot device string for vmedia on SuperMicro"

This commit is contained in:
Zuul 2021-11-18 14:19:17 +00:00 committed by Gerrit Code Review
commit eda4ea115c
5 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Changing boot device string for virtual media from "Cd" to "UsbCd" on
SuperMicro machines to match their specific naming convention.

View File

@ -88,6 +88,15 @@ BOOT_SOURCE_TARGET_UEFI_SHELL = 'uefi shell'
BOOT_SOURCE_TARGET_UEFI_HTTP = 'uefi http'
"""Boot from a UEFI HTTP network location"""
BOOT_SOURCE_TARGET_USB_CD = 'usb cd'
"""Boot from a USB CD device as specified by the system BIOS.
NOTE(janders): This is NOT a standard value.
On SuperMicro X11 and X12 machines, virtual media is presented as an USB CD
drive as opposed to a CD drive. Both are present in the list of boot
devices, however only selecting UsbCd as the boot source results in a
successful boot from vMedia. If CD is selected, boot fails even if vMedia
is inserted."""
# Boot source mode constants
BOOT_SOURCE_MODE_BIOS = 'bios'

View File

@ -30,6 +30,7 @@ BOOT_SOURCE_TARGET_MAP = {
'UefiTarget': sys_cons.BOOT_SOURCE_TARGET_UEFI_TARGET,
'UefiShell': sys_cons.BOOT_SOURCE_TARGET_UEFI_SHELL,
'UefiHttp': sys_cons.BOOT_SOURCE_TARGET_UEFI_HTTP,
'UsbCd': sys_cons.BOOT_SOURCE_TARGET_USB_CD,
}
BOOT_SOURCE_TARGET_MAP_REV = utils.revert_dictionary(BOOT_SOURCE_TARGET_MAP)

View File

@ -236,6 +236,26 @@ class System(base.ResourceBase):
valid_values=valid_targets)
fishy_target = sys_maps.BOOT_SOURCE_TARGET_MAP_REV[target]
# NOTE(janders) on SuperMicro X11 and X12 machines, virtual media
# is presented as an "USB CD" drive as opposed to a CD drive. Both
# are present in the list of boot devices, however only selecting
# UsbCd as the boot source results in a successful boot from
# vMedia. If "CD" is selected, boot fails even if vMedia is
# inserted. This code detects a case where a SuperMicro machine is
# about to attempt boot from CD and overrides the boot device to
# UsbCd instead which makes boot from vMedia work as expected.
if (self.manufacturer and self.manufacturer.lower() == 'supermicro'
and fishy_target == sys_maps.BOOT_SOURCE_TARGET_MAP_REV[
sys_cons.BOOT_SOURCE_TARGET_CD]
and sys_maps.BOOT_SOURCE_TARGET_MAP_REV[
sys_cons.BOOT_SOURCE_TARGET_USB_CD]
in self.boot.allowed_values):
fishy_target = sys_maps.BOOT_SOURCE_TARGET_MAP_REV[
sys_cons.BOOT_SOURCE_TARGET_USB_CD]
LOG.debug('Boot from vMedia was requested on a SuperMicro'
'machine. Overriding boot device from %s to %s.',
sys_cons.BOOT_SOURCE_TARGET_CD,
fishy_target)
data['Boot']['BootSourceOverrideTarget'] = fishy_target

View File

@ -259,6 +259,7 @@ class SystemTestCase(base.TestCase):
sushy.BOOT_SOURCE_TARGET_PXE,
sushy.BOOT_SOURCE_TARGET_CD,
sushy.BOOT_SOURCE_TARGET_USB,
sushy.BOOT_SOURCE_TARGET_USB_CD,
sushy.BOOT_SOURCE_TARGET_HDD,
sushy.BOOT_SOURCE_TARGET_BIOS_SETUP,
sushy.BOOT_SOURCE_TARGET_UTILITIES,
@ -330,6 +331,33 @@ class SystemTestCase(base.TestCase):
sushy.BOOT_SOURCE_TARGET_HDD,
enabled='invalid-enabled')
def test_set_system_boot_options_supermicro_usb_cd_boot(self):
(self.json_doc["Boot"]
["BootSourceOverrideTarget@Redfish.AllowableValues"]).append("UsbCd")
self.sys_inst._parse_attributes(self.json_doc)
self.sys_inst.manufacturer = "supermicro"
self.sys_inst.set_system_boot_options(
target=sushy.BOOT_SOURCE_TARGET_CD,
enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
self.sys_inst._conn.patch.assert_called_once_with(
'/redfish/v1/Systems/437XR1138R2',
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
'BootSourceOverrideTarget': 'UsbCd'}})
def test_set_system_boot_options_supermicro_no_usb_cd_boot(self):
self.sys_inst.manufacturer = "supermicro"
self.sys_inst.set_system_boot_options(
target=sushy.BOOT_SOURCE_TARGET_CD,
enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
self.sys_inst._conn.patch.assert_called_once_with(
'/redfish/v1/Systems/437XR1138R2',
data={'Boot': {'BootSourceOverrideEnabled': 'Once',
'BootSourceOverrideTarget': 'Cd'}})
def test_set_system_boot_source(self):
self.sys_inst.set_system_boot_source(
sushy.BOOT_SOURCE_TARGET_PXE,