Improve boot override handling for Dell

This commit is contained in:
Joshua Boniface 2022-07-07 16:23:29 +00:00
parent fe6f34a3eb
commit a30ac176f4
1 changed files with 33 additions and 9 deletions

View File

@ -620,19 +620,43 @@ def set_boot_override(session, system_root, redfish_vendor, target):
"""
Set the system boot override to the desired target
"""
print(redfish_vendor)
system_details = session.get(system_root)
def set_boot_override_dell():
# BootSourceOverrideEnabled': 'Disabled', 'BootSourceOverrideMode': 'UEFI', 'BootSourceOverrideTarget': 'None', 'UefiTargetBootSourceOverride': None,
try:
system_detail = session.get(system_root)
boot_targets = system_detail["Boot"]["BootSourceOverrideSupported"]
boot_targets = system_detail["Boot"]["BootSourceOverrideTarget@Redfish.AllowableValues"]
except KeyError:
logger.warn(f"Failed to set boot override, no BootSourceOverrideSupported key at {system_detail}")
return False
if target not in boot_targets:
logger.warn(f"Failed to set boot override, key {target} not in {boot_targets}")
return False
session.patch(system_root, {"Boot": {"BootSourceOverrideEnabled": "Enabled", "BootSourceOverrideMode": "UEFI", "UefiTargetBootSourceOverride": target}})
return True
def set_boot_override_generic():
try:
boot_targets = system_detail["Boot"]["BootSourceOverrideSupported"]
except KeyError:
logger.warn(f"Failed to set boot override, no BootSourceOverrideSupported key at {system_detail}")
return False
if target not in boot_targets:
logger.warn(f"Failed to set boot override, key {target} not in {boot_targets}")
return False
session.patch(system_root, {"Boot": {"BootSourceOverrideTarget": target}})
return True
if redfish_vendor in ["dell", "Dell"]:
return set_boot_override_dell()
else:
return set_boot_override_generic()
def check_redfish(config, data):
"""