iLO Redfish: Adds support to manage BIOS settings
Adds support to get current BIOS settings, default BIOS settings and pending BIOS settings for redfish based systems. Also provides support to update the BIOS configuration with the given configuration. Change-Id: I309d4226ba456a7df6dc4f1167d5a3f9acd69dd1
This commit is contained in:
parent
2cf3a473c9
commit
d0dd4add5d
|
@ -77,6 +77,10 @@ SUPPORTED_REDFISH_METHODS = [
|
|||
'reset_server',
|
||||
'press_pwr_btn',
|
||||
'hold_pwr_btn',
|
||||
'get_current_bios_settings',
|
||||
'get_default_bios_settings',
|
||||
'get_pending_bios_settings',
|
||||
'set_bios_settings',
|
||||
'get_one_time_boot',
|
||||
'get_pending_boot_mode',
|
||||
'get_current_boot_mode',
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
SUPPORTED_BOOT_MODE_LEGACY_BIOS_ONLY = 'legacy bios only'
|
||||
SUPPORTED_BOOT_MODE_UEFI_ONLY = 'uefi only'
|
||||
SUPPORTED_BOOT_MODE_LEGACY_BIOS_AND_UEFI = 'legacy bios and uefi'
|
||||
SUPPORTED_BIOS_PROPERTIES = {
|
||||
SUPPORTED_BIOS_PROPERTIES = [
|
||||
"AdvancedMemProtection",
|
||||
"AutoPowerOn",
|
||||
"BootMode",
|
||||
|
@ -46,4 +46,7 @@ SUPPORTED_BIOS_PROPERTIES = {
|
|||
"TpmState",
|
||||
"TpmType",
|
||||
"UefiOptimizedBoot"
|
||||
}
|
||||
]
|
||||
SUPPORTED_REDFISH_BIOS_PROPERTIES = SUPPORTED_BIOS_PROPERTIES + [
|
||||
"WorkloadProfile"
|
||||
]
|
||||
|
|
|
@ -33,6 +33,7 @@ from proliantutils.redfish.resources.system import constants as sys_cons
|
|||
from proliantutils.redfish.resources.system.storage \
|
||||
import common as common_storage
|
||||
from proliantutils.redfish import utils as rf_utils
|
||||
from proliantutils import utils as common_utils
|
||||
|
||||
"""
|
||||
Class specific for Redfish APIs.
|
||||
|
@ -1055,3 +1056,115 @@ class RedfishOperations(operations.IloOperations):
|
|||
"""Delete the raid configuration on the hardware."""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
sushy_system.delete_raid()
|
||||
|
||||
def get_current_bios_settings(self, only_allowed_settings=True):
|
||||
"""Get current BIOS settings.
|
||||
|
||||
:param: only_allowed_settings: True when only allowed BIOS settings
|
||||
are to be returned. If False, All the BIOS settings supported
|
||||
by iLO are returned.
|
||||
:return: a dictionary of current BIOS settings is returned. Depending
|
||||
on the 'only_allowed_settings', either only the allowed
|
||||
settings are returned or all the supported settings are
|
||||
returned.
|
||||
:raises: IloError, on an error from iLO
|
||||
"""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
try:
|
||||
current_settings = sushy_system.bios_settings.json
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The current BIOS Settings were not found. Error '
|
||||
'%(error)s') %
|
||||
{'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
attributes = current_settings.get("Attributes")
|
||||
if only_allowed_settings and attributes:
|
||||
return common_utils.apply_bios_properties_filter(
|
||||
attributes, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)
|
||||
return attributes
|
||||
|
||||
def get_pending_bios_settings(self, only_allowed_settings=True):
|
||||
"""Get pending BIOS settings.
|
||||
|
||||
:param: only_allowed_settings: True when only allowed BIOS settings are
|
||||
to be returned. If False, All the BIOS settings supported by
|
||||
iLO are returned.
|
||||
:return: a dictionary of pending BIOS settings is returned. Depending
|
||||
on the 'only_allowed_settings', either only the allowed
|
||||
settings are returned or all the supported settings are
|
||||
returned.
|
||||
:raises: IloError, on an error from iLO.
|
||||
"""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
try:
|
||||
settings = sushy_system.bios_settings.pending_settings.json
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The pending BIOS Settings were not found. Error '
|
||||
'%(error)s') %
|
||||
{'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
attributes = settings.get("Attributes")
|
||||
if only_allowed_settings and attributes:
|
||||
return common_utils.apply_bios_properties_filter(
|
||||
attributes, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)
|
||||
return attributes
|
||||
|
||||
def set_bios_settings(self, data=None, only_allowed_settings=True):
|
||||
"""Sets current BIOS settings to the provided data.
|
||||
|
||||
:param: only_allowed_settings: True when only allowed BIOS settings
|
||||
are to be set. If False, all the BIOS settings supported by
|
||||
iLO and present in the 'data' are set.
|
||||
:param: data: a dictionary of BIOS settings to be applied. Depending
|
||||
on the 'only_allowed_settings', either only the allowed
|
||||
settings are set or all the supported settings that are in the
|
||||
'data' are set.
|
||||
:raises: IloError, on an error from iLO.
|
||||
:raises: IloCommandNotSupportedError, if the command is not supported
|
||||
on the server.
|
||||
"""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
filtered_data = data
|
||||
if only_allowed_settings and data:
|
||||
filtered_data = common_utils.apply_bios_properties_filter(
|
||||
data, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)
|
||||
if filtered_data:
|
||||
try:
|
||||
settings_required = sushy_system.bios_settings.pending_settings
|
||||
settings_required.update_bios_data_by_patch(filtered_data)
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The pending BIOS Settings resource not found.'
|
||||
' Error %(error)s') %
|
||||
{'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
|
||||
def get_default_bios_settings(self, only_allowed_settings=True):
|
||||
"""Get default BIOS settings.
|
||||
|
||||
:param: only_allowed_settings: True when only allowed BIOS settings
|
||||
are to be returned. If False, All the BIOS settings supported
|
||||
by iLO are returned.
|
||||
:return: a dictionary of default BIOS settings(factory settings).
|
||||
Depending on the 'only_allowed_settings', either only the
|
||||
allowed settings are returned or all the supported settings
|
||||
are returned.
|
||||
:raises: IloError, on an error from iLO.
|
||||
"""
|
||||
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID)
|
||||
try:
|
||||
settings = sushy_system.bios_settings.default_settings
|
||||
except sushy.exceptions.SushyError as e:
|
||||
msg = (self._('The default BIOS Settings were not found. Error '
|
||||
'%(error)s') %
|
||||
{'error': str(e)})
|
||||
LOG.debug(msg)
|
||||
raise exception.IloError(msg)
|
||||
if only_allowed_settings:
|
||||
return common_utils.apply_bios_properties_filter(
|
||||
settings, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)
|
||||
return settings
|
||||
|
|
|
@ -69,6 +69,14 @@ class BIOSSettings(base.ResourceBase):
|
|||
self._pending_settings.refresh(force=False)
|
||||
return self._pending_settings
|
||||
|
||||
@property
|
||||
def default_settings(self):
|
||||
"""Property to provide default BIOS settings
|
||||
|
||||
It gets the current default settings on the node.
|
||||
"""
|
||||
return self._get_base_configs().default_config
|
||||
|
||||
@property
|
||||
def boot_settings(self):
|
||||
"""Property to provide reference to bios boot instance
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
"AdjSecPrefetch": "Enabled",
|
||||
"AdminEmail": "",
|
||||
"AdminName": "",
|
||||
"AdminPassword": "password",
|
||||
"AdminOtherInfo": "",
|
||||
"AdminPhone": "",
|
||||
"AdvancedMemProtection": "AdvancedEcc",
|
||||
|
@ -60,6 +61,7 @@
|
|||
"DaylightSavingsTime": "Disabled",
|
||||
"DcuIpPrefetcher": "Enabled",
|
||||
"DcuStreamPrefetcher": "Enabled",
|
||||
"Description": "Default settings",
|
||||
"Dhcpv4": "Enabled",
|
||||
"DynamicPowerCapping": "Disabled",
|
||||
"EmbNicAspm": "Disabled",
|
||||
|
@ -233,6 +235,7 @@
|
|||
"TpmState": "NotPresent",
|
||||
"TpmType": "NoTpm",
|
||||
"UefiOptimizedBoot": "Enabled",
|
||||
"UefiPxeBoot": "Enabled",
|
||||
"UefiSerialDebugLevel": "Disabled",
|
||||
"UefiShellBootOrder": "Disabled",
|
||||
"UefiShellScriptVerification": "Disabled",
|
||||
|
@ -298,8 +301,217 @@
|
|||
"@odata.id": "/redfish/v1/systems/1/bios/settings/",
|
||||
"@odata.type": "#Bios.v1_0_0.Bios",
|
||||
"AttributeRegistry": "BiosAttributeRegistryU31.v1_1_00",
|
||||
"Attributes": {
|
||||
"BootMode": "Uefi"
|
||||
"Attributes":
|
||||
{
|
||||
"AcpiHpet": "Enabled",
|
||||
"AcpiRootBridgePxm": "Enabled",
|
||||
"AcpiSlit": "Enabled",
|
||||
"AdjSecPrefetch": "Enabled",
|
||||
"AdminEmail": "",
|
||||
"AdminName": "Redfish Administrator",
|
||||
"AdminPassword": "newpassword",
|
||||
"AdminOtherInfo": "",
|
||||
"AdminPhone": "",
|
||||
"AdvCrashDumpMode": "Disabled",
|
||||
"AdvancedMemProtection": "AdvancedEcc",
|
||||
"AsrStatus": "Enabled",
|
||||
"AsrTimeoutMinutes": "Timeout10",
|
||||
"AssetTagProtection": "Unlocked",
|
||||
"AutoPowerOn": "RestoreLastState",
|
||||
"BootMode": "Uefi",
|
||||
"BootOrderPolicy": "AttemptOnce",
|
||||
"ChannelInterleaving": "Enabled",
|
||||
"CollabPowerControl": "Enabled",
|
||||
"ConsistentDevNaming": "LomsAndSlots",
|
||||
"CustomPostMessage": "",
|
||||
"DaylightSavingsTime": "Disabled",
|
||||
"DcuIpPrefetcher": "Enabled",
|
||||
"DcuStreamPrefetcher": "Enabled",
|
||||
"Description": "Ilo Redifsh updated",
|
||||
"Dhcpv4": "Enabled",
|
||||
"DynamicPowerCapping": "Disabled",
|
||||
"EmbNicEnable": "Auto",
|
||||
"EmbNicLinkSpeed": "Auto",
|
||||
"EmbNicPCIeOptionROM": "Enabled",
|
||||
"EmbSas1Aspm": "Disabled",
|
||||
"EmbSas1Boot": "TwentyFourTargets",
|
||||
"EmbSas1Enable": "Auto",
|
||||
"EmbSas1LinkSpeed": "Auto",
|
||||
"EmbSas1PcieOptionROM": "Enabled",
|
||||
"EmbSata1Aspm": "Disabled",
|
||||
"EmbSata1PCIeOptionROM": "Enabled",
|
||||
"EmbSata2Aspm": "Disabled",
|
||||
"EmbSata2PCIeOptionROM": "Enabled",
|
||||
"EmbVideoConnection": "Auto",
|
||||
"EmbeddedDiagnostics": "Enabled",
|
||||
"EmbeddedSata": "Ahci",
|
||||
"EmbeddedSerialPort": "Com2Irq3",
|
||||
"EmbeddedUefiShell": "Enabled",
|
||||
"EmsConsole": "Disabled",
|
||||
"EnabledCoresPerProc": 0,
|
||||
"EnergyEfficientTurbo": "Enabled",
|
||||
"EnergyPerfBias": "BalancedPerf",
|
||||
"EraseUserDefaults": "No",
|
||||
"ExtendedAmbientTemp": "Disabled",
|
||||
"ExtendedMemTest": "Disabled",
|
||||
"F11BootMenu": "Enabled",
|
||||
"FCScanPolicy": "CardConfig",
|
||||
"FanFailPolicy": "Shutdown",
|
||||
"FanInstallReq": "EnableMessaging",
|
||||
"FlexLom1Aspm": "Disabled",
|
||||
"FlexLom1LinkSpeed": "Auto",
|
||||
"FlexLom1PCIeOptionROM": "Enabled",
|
||||
"HttpSupport": "Auto",
|
||||
"HwPrefetcher": "Enabled",
|
||||
"IntelDmiLinkFreq": "Auto",
|
||||
"IntelNicDmaChannels": "Enabled",
|
||||
"IntelPerfMonitoring": "Disabled",
|
||||
"IntelProcVtd": "Enabled",
|
||||
"IntelligentProvisioning": "Enabled",
|
||||
"InternalSDCardSlot": "Enabled",
|
||||
"Ipv4Address": "0.0.0.0",
|
||||
"Ipv4Gateway": "0.0.0.0",
|
||||
"Ipv4PrimaryDNS": "0.0.0.0",
|
||||
"Ipv4SecondaryDNS": "0.0.0.0",
|
||||
"Ipv4SubnetMask": "0.0.0.0",
|
||||
"Ipv6Address": "::",
|
||||
"Ipv6ConfigPolicy": "Automatic",
|
||||
"Ipv6Duid": "Auto",
|
||||
"Ipv6Gateway": "::",
|
||||
"Ipv6PrimaryDNS": "::",
|
||||
"Ipv6SecondaryDNS": "::",
|
||||
"LLCDeadLineAllocation": "Enabled",
|
||||
"LlcPrefetch": "Disabled",
|
||||
"LocalRemoteThreshold": "Auto",
|
||||
"MaxMemBusFreqMHz": "Auto",
|
||||
"MaxPcieSpeed": "PerPortCtrl",
|
||||
"MemClearWarmReset": "Disabled",
|
||||
"MemFastTraining": "Enabled",
|
||||
"MemMirrorMode": "Full",
|
||||
"MemPatrolScrubbing": "Enabled",
|
||||
"MemRefreshRate": "Refreshx1",
|
||||
"MemoryControllerInterleaving": "Auto",
|
||||
"MemoryRemap": "NoAction",
|
||||
"MinProcIdlePkgState": "C6Retention",
|
||||
"MinProcIdlePower": "C6",
|
||||
"MixedPowerSupplyReporting": "Enabled",
|
||||
"NVMeDriveBox3Bay1": "Nvme",
|
||||
"NetworkBootRetry": "Enabled",
|
||||
"NetworkBootRetryCount": 20,
|
||||
"NicBoot1": "NetworkBoot",
|
||||
"NicBoot2": "Disabled",
|
||||
"NicBoot3": "Disabled",
|
||||
"NicBoot4": "Disabled",
|
||||
"NodeInterleaving": "Disabled",
|
||||
"NumaGroupSizeOpt": "Flat",
|
||||
"NvmeOptionRom": "Enabled",
|
||||
"OpportunisticSelfRefresh": "Disabled",
|
||||
"PciResourcePadding": "Normal",
|
||||
"PciSlot1Aspm": "Disabled",
|
||||
"PciSlot1LinkSpeed": "Auto",
|
||||
"PciSlot1OptionROM": "Enabled",
|
||||
"PciSlot2Aspm": "Disabled",
|
||||
"PciSlot2LinkSpeed": "Auto",
|
||||
"PciSlot2OptionROM": "Enabled",
|
||||
"PciSlot3Aspm": "Disabled",
|
||||
"PciSlot3LinkSpeed": "Auto",
|
||||
"PciSlot3OptionROM": "Enabled",
|
||||
"PciSlot4Aspm": "Disabled",
|
||||
"PciSlot4LinkSpeed": "Auto",
|
||||
"PciSlot4OptionROM": "Enabled",
|
||||
"PciSlot5Aspm": "Disabled",
|
||||
"PciSlot5LinkSpeed": "Auto",
|
||||
"PciSlot5OptionROM": "Enabled",
|
||||
"PciSlot6Aspm": "Disabled",
|
||||
"PciSlot6LinkSpeed": "Auto",
|
||||
"PciSlot6OptionROM": "Enabled",
|
||||
"PciSlot7Aspm": "Disabled",
|
||||
"PciSlot7LinkSpeed": "Auto",
|
||||
"PciSlot7OptionROM": "Enabled",
|
||||
"PciSlot8Aspm": "Disabled",
|
||||
"PciSlot8LinkSpeed": "Auto",
|
||||
"PciSlot8OptionROM": "Enabled",
|
||||
"PersistentMemAddressRangeScrub": "Enabled",
|
||||
"PersistentMemBackupPowerPolicy": "WaitForBackupPower",
|
||||
"PersistentMemScanMem": "Enabled",
|
||||
"PostBootProgress": "Disabled",
|
||||
"PostDiscoveryMode": "Auto",
|
||||
"PostF1Prompt": "Delayed20Sec",
|
||||
"PowerButton": "Enabled",
|
||||
"PowerOnDelay": "NoDelay",
|
||||
"PowerRegulator": "DynamicPowerSavings",
|
||||
"PreBootNetwork": "Auto",
|
||||
"PrebootNetworkEnvPolicy": "Auto",
|
||||
"PrebootNetworkProxy": "",
|
||||
"ProcAes": "Enabled",
|
||||
"ProcHyperthreading": "Enabled",
|
||||
"ProcTurbo": "Enabled",
|
||||
"ProcVirtualization": "Enabled",
|
||||
"ProcX2Apic": "Enabled",
|
||||
"ProcessorJitterControl": "Disabled",
|
||||
"ProcessorJitterControlFrequency": 0,
|
||||
"ProcessorJitterControlOptimization": "ZeroLatency",
|
||||
"ProductId": "868703-B21",
|
||||
"RedundantPowerSupply": "BalancedMode",
|
||||
"RemovableFlashBootSeq": "ExternalKeysFirst",
|
||||
"RestoreDefaults": "No",
|
||||
"RestoreManufacturingDefaults": "No",
|
||||
"RomSelection": "CurrentRom",
|
||||
"SataSecureErase": "Disabled",
|
||||
"SaveUserDefaults": "No",
|
||||
"SecStartBackupImage": "Disabled",
|
||||
"SecureBootStatus": "Disabled",
|
||||
"SerialConsoleBaudRate": "BaudRate115200",
|
||||
"SerialConsoleEmulation": "Vt100Plus",
|
||||
"SerialConsolePort": "Auto",
|
||||
"SerialNumber": "SGH744YPVS",
|
||||
"ServerAssetTag": "",
|
||||
"ServerName": "",
|
||||
"ServerOtherInfo": "",
|
||||
"ServerPrimaryOs": "",
|
||||
"ServiceEmail": "",
|
||||
"ServiceName": "",
|
||||
"ServiceOtherInfo": "",
|
||||
"ServicePhone": "",
|
||||
"SetupBrowserSelection": "Auto",
|
||||
"Sriov": "Enabled",
|
||||
"StaleAtoS": "Disabled",
|
||||
"SubNumaClustering": "Disabled",
|
||||
"ThermalConfig": "OptimalCooling",
|
||||
"ThermalShutdown": "Enabled",
|
||||
"TimeFormat": "Utc",
|
||||
"TimeZone": "Utc9",
|
||||
"TpmChipId": "None",
|
||||
"TpmFips": "NotSpecified",
|
||||
"TpmState": "NotPresent",
|
||||
"TpmType": "NoTpm",
|
||||
"UefiOptimizedBoot": "Disabled",
|
||||
"UefiPxeBoot": "Enabled",
|
||||
"UefiSerialDebugLevel": "Disabled",
|
||||
"UefiShellBootOrder": "Disabled",
|
||||
"UefiShellScriptVerification": "Disabled",
|
||||
"UefiShellStartup": "Disabled",
|
||||
"UefiShellStartupLocation": "Auto",
|
||||
"UefiShellStartupUrl": "",
|
||||
"UefiShellStartupUrlFromDhcp": "Disabled",
|
||||
"UncoreFreqScaling": "Auto",
|
||||
"UrlBootFile": "",
|
||||
"UrlBootFile2": "",
|
||||
"UrlBootFile3": "",
|
||||
"UrlBootFile4": "",
|
||||
"UsbBoot": "Enabled",
|
||||
"UsbControl": "UsbEnabled",
|
||||
"UserDefaultsState": "Disabled",
|
||||
"UtilityLang": "English",
|
||||
"VirtualInstallDisk": "Disabled",
|
||||
"VirtualSerialPort": "Com1Irq4",
|
||||
"VlanControl": "Disabled",
|
||||
"VlanId": 0,
|
||||
"VlanPriority": 0,
|
||||
"WakeOnLan": "Enabled",
|
||||
"WorkloadProfile": "GeneralPowerEfficientCompute",
|
||||
"XptPrefetcher": "Auto",
|
||||
"iSCSIPolicy": "SoftwareInitiator"
|
||||
},
|
||||
"Id": "settings",
|
||||
"Name": "BIOS Current Settings"
|
||||
|
|
|
@ -41,6 +41,7 @@ from proliantutils.redfish.resources.system.storage import array_controller
|
|||
from proliantutils.redfish.resources.system.storage \
|
||||
import common as common_storage
|
||||
from proliantutils.redfish.resources.system import system as pro_sys
|
||||
from proliantutils import utils
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
|
@ -1448,6 +1449,221 @@ class RedfishOperationsTestCase(testtools.TestCase):
|
|||
'The Redfish controller failed to inject nmi',
|
||||
self.rf_client.inject_nmi)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_current_bios_settings_filter_true(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("Default")
|
||||
type(
|
||||
get_system_mock.return_value.bios_settings).json = (
|
||||
mock.PropertyMock(return_value=jsonval))
|
||||
settings = jsonval.get('Attributes')
|
||||
expected_value = {k: settings[k] for k in (
|
||||
ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES) if k in settings}
|
||||
actual_value = self.rf_client.get_current_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected_value, actual_value)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_current_bios_settings_filter_false(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = False
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("Default")
|
||||
type(
|
||||
get_system_mock.return_value.bios_settings).json = (
|
||||
mock.PropertyMock(return_value=jsonval))
|
||||
settings = jsonval.get('Attributes')
|
||||
expected_value = settings
|
||||
actual_value = self.rf_client.get_current_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected_value, actual_value)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_current_bios_settings_raises_exception(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
bios_mock = mock.PropertyMock()
|
||||
bios_mock.side_effect = sushy.exceptions.SushyError
|
||||
type(get_system_mock.return_value.bios_settings).json = bios_mock
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
'The current BIOS Settings were not found',
|
||||
self.rf_client.get_current_bios_settings,
|
||||
only_allowed_settings)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_pending_bios_settings_filter_true(self, system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("BIOS_pending_settings_default")
|
||||
type(system_mock.return_value.bios_settings.pending_settings).json = (
|
||||
mock.PropertyMock(return_value=jsonval))
|
||||
settings = jsonval.get('Attributes')
|
||||
expected_value = {k: settings[k] for k in (
|
||||
ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES) if k in settings}
|
||||
actual_value = self.rf_client.get_pending_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected_value, actual_value)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_pending_bios_settings_filter_false(self, system_mock):
|
||||
|
||||
only_allowed_settings = False
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("BIOS_pending_settings_default")
|
||||
type(system_mock.return_value.bios_settings.pending_settings).json = (
|
||||
mock.PropertyMock(return_value=jsonval))
|
||||
expected = jsonval.get('Attributes')
|
||||
actual = self.rf_client.get_pending_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_pending_bios_settings_raises_exception(self, system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
bios_mock = mock.PropertyMock()
|
||||
bios_mock.side_effect = sushy.exceptions.SushyError
|
||||
type(system_mock.return_value.bios_settings.pending_settings).json = (
|
||||
bios_mock)
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
'The pending BIOS Settings were not found',
|
||||
self.rf_client.get_pending_bios_settings,
|
||||
only_allowed_settings)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_default_bios_settings_filter_true(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("Default")
|
||||
settings = jsonval.get("Attributes")
|
||||
type(get_system_mock.return_value.bios_settings).default_settings = (
|
||||
mock.PropertyMock(return_value=settings))
|
||||
expected = {k: settings[k] for k in (
|
||||
ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES) if k in settings}
|
||||
actual = self.rf_client.get_default_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_default_bios_settings_filter_false(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = False
|
||||
with open('proliantutils/tests/redfish/'
|
||||
'json_samples/bios.json', 'r') as f:
|
||||
jsonval = json.loads(f.read()).get("Default")
|
||||
settings = jsonval.get("Attributes")
|
||||
type(get_system_mock.return_value.bios_settings).default_settings = (
|
||||
mock.PropertyMock(return_value=settings))
|
||||
expected = settings
|
||||
actual = self.rf_client.get_default_bios_settings(
|
||||
only_allowed_settings)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_default_bios_settings_raises_exception(self, get_system_mock):
|
||||
|
||||
only_allowed_settings = True
|
||||
bios_mock = mock.PropertyMock(side_effect=sushy.exceptions.SushyError)
|
||||
type(get_system_mock.return_value.bios_settings).default_settings = (
|
||||
bios_mock)
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
'The default BIOS Settings were not found',
|
||||
self.rf_client.get_default_bios_settings,
|
||||
only_allowed_settings)
|
||||
|
||||
@mock.patch.object(bios.BIOSPendingSettings, 'update_bios_data_by_patch')
|
||||
@mock.patch.object(utils, 'apply_bios_properties_filter')
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_set_bios_settings_no_data(self, system_mock, bios_filter_mock,
|
||||
update_data_mock):
|
||||
data = None
|
||||
apply_filter = True
|
||||
pending_settings_mock = mock.PropertyMock()
|
||||
type(system_mock.return_value.bios_settings).pending_settings = (
|
||||
pending_settings_mock)
|
||||
self.rf_client.set_bios_settings(data, apply_filter)
|
||||
bios_filter_mock.assert_not_called()
|
||||
pending_settings_mock.assert_not_called()
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_set_bios_settings_filter_true(self, system_mock):
|
||||
apply_filter = True
|
||||
data = {
|
||||
"AdminName": "Administrator",
|
||||
"BootMode": "LEGACY",
|
||||
"ServerName": "Gen9 server",
|
||||
"TimeFormat": "Ist",
|
||||
"BootOrderPolicy": "RetryIndefinitely",
|
||||
"ChannelInterleaving": "Enabled",
|
||||
"CollabPowerControl": "Enabled",
|
||||
"ConsistentDevNaming": "LomsOnly",
|
||||
"CustomPostMessage": ""
|
||||
}
|
||||
expected = {k: data[k] for k in data if k in (
|
||||
ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)}
|
||||
bios_ps_mock = mock.MagicMock(spec=bios.BIOSPendingSettings)
|
||||
pending_settings_mock = mock.PropertyMock(return_value=bios_ps_mock)
|
||||
type(system_mock.return_value.bios_settings).pending_settings = (
|
||||
pending_settings_mock)
|
||||
|
||||
self.rf_client.set_bios_settings(data, apply_filter)
|
||||
bios_ps_mock.update_bios_data_by_patch.assert_called_once_with(
|
||||
expected)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_set_bios_settings_filter_false(self, system_mock):
|
||||
apply_filter = False
|
||||
data = {
|
||||
"AdminName": "Administrator",
|
||||
"BootMode": "LEGACY",
|
||||
"ServerName": "Gen9 server",
|
||||
"TimeFormat": "Ist",
|
||||
"BootOrderPolicy": "RetryIndefinitely",
|
||||
"ChannelInterleaving": "Enabled",
|
||||
"CollabPowerControl": "Enabled",
|
||||
"ConsistentDevNaming": "LomsOnly",
|
||||
"CustomPostMessage": ""
|
||||
}
|
||||
bios_ps_mock = mock.MagicMock(spec=bios.BIOSPendingSettings)
|
||||
pending_settings_mock = mock.PropertyMock(return_value=bios_ps_mock)
|
||||
type(system_mock.return_value.bios_settings).pending_settings = (
|
||||
pending_settings_mock)
|
||||
|
||||
self.rf_client.set_bios_settings(data, apply_filter)
|
||||
bios_ps_mock.update_bios_data_by_patch.assert_called_once_with(data)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_set_bios_settings_raises_exception(self, system_mock):
|
||||
apply_filter = True
|
||||
data = {
|
||||
"BootMode": "LEGACY",
|
||||
"TimeFormat": "Ist",
|
||||
"BootOrderPolicy": "RetryIndefinitely",
|
||||
"CollabPowerControl": "Enabled",
|
||||
}
|
||||
pending_settings_mock = mock.PropertyMock(
|
||||
side_effect=sushy.exceptions.SushyError)
|
||||
type(system_mock.return_value.bios_settings).pending_settings = (
|
||||
pending_settings_mock)
|
||||
self.assertRaisesRegex(
|
||||
exception.IloError,
|
||||
'The pending BIOS Settings resource not found',
|
||||
self.rf_client.set_bios_settings,
|
||||
data,
|
||||
apply_filter)
|
||||
|
||||
@mock.patch.object(redfish.RedfishOperations, '_get_sushy_system')
|
||||
def test_get_host_post_state(self, get_system_mock):
|
||||
post_state = mock.PropertyMock(return_value='poweroff')
|
||||
|
|
|
@ -160,7 +160,7 @@ def apply_bios_properties_filter(settings, filter_to_be_applied):
|
|||
"""Applies the filter to return the dict of filtered BIOS properties.
|
||||
|
||||
:param settings: dict of BIOS settings on which filter to be applied.
|
||||
:param filter_to_be_applied: set of keys to be applied as filter.
|
||||
:param filter_to_be_applied: list of keys to be applied as filter.
|
||||
:returns: A dictionary of filtered BIOS settings.
|
||||
"""
|
||||
if not settings or not filter_to_be_applied:
|
||||
|
|
Loading…
Reference in New Issue