From 377a8a96c07b4cfb7c8e26f3e9f0deffd7f736fd Mon Sep 17 00:00:00 2001 From: vmud213 Date: Tue, 4 Sep 2018 16:52:46 +0530 Subject: [PATCH] Adds API to get the results of the BIOS settings This commit adds an API to get the results of the BIOS settings applied prior to the latest power cycle. Change-Id: Ia6786889b717105e9af67faa15da815ad2f4e4cb Closes-Bug: 1790776 --- proliantutils/ilo/client.py | 11 + proliantutils/ilo/operations.py | 9 + proliantutils/ilo/ribcl.py | 9 + proliantutils/ilo/ris.py | 12 + proliantutils/redfish/redfish.py | 19 + .../redfish/resources/system/bios.py | 1 + proliantutils/tests/ilo/ris_sample_outputs.py | 226 +++++++- proliantutils/tests/ilo/test_client.py | 18 + proliantutils/tests/ilo/test_ribcl.py | 7 + proliantutils/tests/ilo/test_ris.py | 57 ++ .../tests/redfish/json_samples/bios.json | 9 - .../redfish/json_samples/bios_failed.json | 535 ++++++++++++++++++ proliantutils/tests/redfish/test_redfish.py | 59 ++ 13 files changed, 955 insertions(+), 17 deletions(-) create mode 100644 proliantutils/tests/redfish/json_samples/bios_failed.json diff --git a/proliantutils/ilo/client.py b/proliantutils/ilo/client.py index 3d6af0d0..7b336cc8 100644 --- a/proliantutils/ilo/client.py +++ b/proliantutils/ilo/client.py @@ -28,6 +28,7 @@ SUPPORTED_RIS_METHODS = [ 'create_raid_configuration', 'delete_raid_configuration', 'eject_virtual_media', + 'get_bios_settings_result', 'get_current_bios_settings', 'get_current_boot_mode', 'get_host_post_state', @@ -80,6 +81,7 @@ SUPPORTED_REDFISH_METHODS = [ 'reset_server', 'press_pwr_btn', 'hold_pwr_btn', + 'get_bios_settings_result', 'get_current_bios_settings', 'get_default_bios_settings', 'get_pending_bios_settings', @@ -792,3 +794,12 @@ class IloClient(operations.IloOperations): """ return self._call_method('get_default_bios_settings', only_allowed_settings) + + def get_bios_settings_result(self): + """Gets the result of the bios settings applied + + :raises: IloError, on an error from iLO. + :raises: IloCommandNotSupportedError, if the command is + not supported on the server. + """ + return self._call_method('get_bios_settings_result') diff --git a/proliantutils/ilo/operations.py b/proliantutils/ilo/operations.py index 9093a016..7d7dcc33 100644 --- a/proliantutils/ilo/operations.py +++ b/proliantutils/ilo/operations.py @@ -488,3 +488,12 @@ class IloOperations(object): not supported on the server. """ raise exception.IloCommandNotSupportedError(ERRMSG) + + def get_bios_settings_result(self): + """Gets the result of the bios settings applied + + :raises: IloError, on an error from iLO. + :raises: IloCommandNotSupportedError, if the command is + not supported on the server. + """ + raise exception.IloCommandNotSupportedError(ERRMSG) diff --git a/proliantutils/ilo/ribcl.py b/proliantutils/ilo/ribcl.py index ccd8fcc9..6e675458 100644 --- a/proliantutils/ilo/ribcl.py +++ b/proliantutils/ilo/ribcl.py @@ -1252,6 +1252,15 @@ class RIBCLOperations(operations.IloOperations): """ self._raise_command_not_supported("create_raid_configuration") + def get_bios_settings_result(self): + """Gets the result of the bios settings applied + + :raises: IloError, on an error from iLO. + :raises: IloCommandNotSupportedError, if the command is + not supported on the server. + """ + self._raise_command_not_supported("get_bios_settings_result") + # The below block of code is there only for backward-compatibility # reasons (before commit 47608b6 for ris-support). diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py index 2aef1cea..e57c82c1 100755 --- a/proliantutils/ilo/ris.py +++ b/proliantutils/ilo/ris.py @@ -2031,3 +2031,15 @@ class RISOperations(rest.RestConnectorBase, operations.IloOperations): :raises: IloCommandNotSupportedError """ self._raise_command_not_supported("create_raid_configuration") + + def get_bios_settings_result(self): + """Gets the result of the bios settings applied + + :raises: IloError, on an error from iLO. + :raises: IloCommandNotSupportedError, if the command is + not supported on the server. + """ + headers, bios_uri, bios_settings = self._check_bios_resource() + settings_result = bios_settings.get("SettingsResult").get("Messages") + status = "failed" if len(settings_result) > 1 else "success" + return {"status": status, "results": settings_result} diff --git a/proliantutils/redfish/redfish.py b/proliantutils/redfish/redfish.py index 1ba3ee07..acef9df3 100644 --- a/proliantutils/redfish/redfish.py +++ b/proliantutils/redfish/redfish.py @@ -1210,3 +1210,22 @@ class RedfishOperations(operations.IloOperations): """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) sushy_system.create_raid(raid_config) + + def get_bios_settings_result(self): + """Gets the result of the bios settings applied + + :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) + try: + settings_result = sushy_system.bios_settings.messages + except sushy.exceptions.SushyError as e: + msg = (self._('The BIOS Settings results were not found. Error ' + '%(error)s') % + {'error': str(e)}) + LOG.debug(msg) + raise exception.IloError(msg) + status = "failed" if len(settings_result) > 1 else "success" + return {"status": status, "results": settings_result} diff --git a/proliantutils/redfish/resources/system/bios.py b/proliantutils/redfish/resources/system/bios.py index 98425f9c..c45b7c45 100644 --- a/proliantutils/redfish/resources/system/bios.py +++ b/proliantutils/redfish/resources/system/bios.py @@ -35,6 +35,7 @@ BOOT_SOURCE_TARGET_TO_PARTIAL_STRING_MAP = { class BIOSSettings(base.ResourceBase): """Class that defines the functionality for BIOS Resources.""" + messages = base.Field(['@Redfish.Settings', 'Messages']) boot_mode = base.MappedField(["Attributes", "BootMode"], mappings.GET_BIOS_BOOT_MODE_MAP) diff --git a/proliantutils/tests/ilo/ris_sample_outputs.py b/proliantutils/tests/ilo/ris_sample_outputs.py index 819f728c..539bbb0b 100755 --- a/proliantutils/tests/ilo/ris_sample_outputs.py +++ b/proliantutils/tests/ilo/ris_sample_outputs.py @@ -1401,14 +1401,6 @@ GET_BIOS_SETTINGS = """ "ETag": "5E0136E3", "Messages": [ - { - "MessageArgs": - [ - "Disable", - "TpmOperation" - ], - "MessageID": "Base.1.0:PropertyValueTypeError" - }, { "MessageArgs": [ @@ -1476,6 +1468,224 @@ GET_BIOS_SETTINGS = """ """ +GET_BIOS_SETTINGS_FAILED = """ + { + "AcpiRootBridgePxm": "Enabled", + "AcpiSlit": "Enabled", + "AdjSecPrefetch": "Enabled", + "AdminEmail": "", + "AdminName": "", + "AdminOtherInfo": "", + "AdminPassword": null, + "AdminPhone": "", + "AdvancedMemProtection": "AdvancedEcc", + "AsrStatus": "Enabled", + "AsrTimeoutMinutes": "10", + "AssetTagProtection": "Unlocked", + "AttributeRegistry": "HpBiosAttributeRegistryI36.1.0.40", + "BootMode": "Uefi", + "BootOrderPolicy": "RetryIndefinitely", + "ChannelInterleaving": "Enabled", + "CollabPowerControl": "Enabled", + "ConsistentDevNaming": "LomsOnly", + "CustomPostMessage": "", + "DcuIpPrefetcher": "Enabled", + "DcuStreamPrefetcher": "Enabled", + "Description": "This is the Platform/BIOS Configuration (RBSU)\ + Current Settings", + "Dhcpv4": "Enabled", + "DynamicPowerCapping": "Auto", + "DynamicPowerResponse": "Fast", + "EmbNicEnable": "Enabled", + "EmbSasEnable": "Enabled", + "EmbSata1Enable": "Enabled", + "EmbSata2Enable": "Enabled", + "EmbVideoConnection": "Auto", + "EmbeddedDiagnostics": "Enabled", + "EmbeddedDiagsMode": "Auto", + "EmbeddedSata": "Ahci", + "EmbeddedSerialPort": "Com2Irq3", + "EmbeddedUefiShell": "Enabled", + "EmbeddedUserPartition": "Disabled", + "EmsConsole": "Com1Irq4", + "EnergyPerfBias": "BalancedPerf", + "EraseUserDefaults": "No", + "ExtendedAmbientTemp": "Disabled", + "ExtendedMemTest": "Disabled", + "F11BootMenu": "Enabled", + "FCScanPolicy": "AllTargets", + "FanFailPolicy": "Shutdown", + "FanInstallReq": "EnableMessaging", + "FlexLom1Enable": "Enabled", + "HwPrefetcher": "Enabled", + "IntelDmiLinkFreq": "Auto", + "IntelNicDmaChannels": "Enabled", + "IntelPerfMonitoring": "Disabled", + "IntelProcVtd": "Enabled", + "IntelQpiFreq": "Auto", + "IntelQpiLinkEn": "Auto", + "IntelQpiPowerManagement": "Enabled", + "IntelTxt": "Disabled", + "IntelligentProvisioning": "Enabled", + "InternalSDCardSlot": "Enabled", + "IoNonPostedPrefetching": "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", + "MaxMemBusFreqMHz": "Auto", + "MaxPcieSpeed": "MaxSupported", + "MemFastTraining": "Enabled", + "MinProcIdlePkgState": "C6Retention", + "MinProcIdlePower": "C6", + "MixedPowerSupplyReporting": "Enabled", + "Modified": "2015-03-13T21:50:42+00:00", + "Name": "BIOS Current Settings", + "NetworkBootRetry": "Enabled", + "NicBoot1": "NetworkBoot", + "NicBoot2": "Disabled", + "NicBoot3": "Disabled", + "NicBoot4": "Disabled", + "NicBoot5": "Disabled", + "NicBoot6": "Disabled", + "NicBoot7": "Disabled", + "NicBoot8": "Disabled", + "NmiDebugButton": "Enabled", + "NodeInterleaving": "Disabled", + "NumaGroupSizeOpt": "Clustered", + "NvDimmNMemFunctionality": "Enabled", + "OldAdminPassword": null, + "OldPowerOnPassword": null, + "PciBusPadding": "Enabled", + "PostF1Prompt": "Delayed20Sec", + "PowerButton": "Enabled", + "PowerOnDelay": "None", + "PowerOnLogo": "Enabled", + "PowerOnPassword": null, + "PowerProfile": "BalancedPowerPerf", + "PowerRegulator": "DynamicPowerSavings", + "PreBootNetwork": "Auto", + "ProcAes": "Enabled", + "ProcCoreDisable": 0, + "ProcNoExecute": "Enabled", + "ProcVirtualization": "Enabled", + "ProcX2Apic": "Enabled", + "ProductId": "727021-B21", + "QpiBandwidthOpt": "Balanced", + "QpiSnoopConfig": "Standard", + "RemovableFlashBootSeq": "ExternalKeysFirst", + "RestoreDefaults": "No", + "RestoreManufacturingDefaults": "No", + "RomSelection": "CurrentRom", + "SataSecureErase": "Disabled", + "SaveUserDefaults": "No", + "SecureBootStatus": "Disabled", + "SerialConsoleBaudRate": "115200", + "SerialConsoleEmulation": "Vt100Plus", + "SerialConsolePort": "Auto", + "SerialNumber": "SGH449WNL3", + "ServerAssetTag": "", + "ServerName": "", + "ServerOtherInfo": "", + "ServerPrimaryOs": "", + "ServiceEmail": "", + "ServiceName": "", + "ServiceOtherInfo": "", + "ServicePhone": "", + "SettingsResult": + { + "ETag": "5E0136E3", + "Messages": [ + { + "MessageArgs": [ + "MinProcIdlePkgState" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "MinProcIdlePower" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "EnergyPerfBias" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "PowerRegulator" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [], + "MessageID": "Base.1.0:Success" + } + ], + "Time": "2015-03-09T17:50:09+00:00" + }, + "Sriov": "Enabled", + "ThermalConfig": "OptimalCooling", + "ThermalShutdown": "Enabled", + "TimeFormat": "Utc", + "TimeZone": "Unspecified", + "Tpm2Operation": "NoAction", + "Tpm2Visibility": "Visible", + "TpmBinding": "Disabled", + "TpmState": "NotPresent", + "TpmType": "NoTpm", + "TpmUefiOpromMeasuring": "Enabled", + "TpmVisibility": "Visible", + "Type": "HpBios.1.1.0", + "UefiPxeBoot": "Auto", + "UefiShellBootOrder": "Disabled", + "UefiShellStartup": "Disabled", + "UefiShellStartupLocation": "Auto", + "UefiShellStartupUrl": "", + "UrlBootFile": "", + "Usb3Mode": "Auto", + "UsbBoot": "Enabled", + "UsbControl": "UsbEnabled", + "UtilityLang": "English", + "VideoOptions": "BothVideoEnabled", + "VirtualInstallDisk": "Disabled", + "VirtualSerialPort": "Com1Irq4", + "WakeOnLan": "Disabled", + "links": + { + "BaseConfigs": + { + "href": "/rest/v1/systems/1/bios/BaseConfigs" + }, + "Boot": + { + "href": "/rest/v1/systems/1/bios/Boot" + }, + "Mappings": + { + "href": "/rest/v1/systems/1/bios/Mappings" + }, + "Settings": + { + "href": "/rest/v1/systems/1/bios/Settings" + }, + "iScsi": + { + "href": "/rest/v1/systems/1/bios/iScsi" + }, + "self": + { + "href": "/rest/v1/systems/1/bios" + } + } + } + +""" + GET_BIOS_PENDING_SETTINGS = """ { diff --git a/proliantutils/tests/ilo/test_client.py b/proliantutils/tests/ilo/test_client.py index 1968b734..4e73a85b 100644 --- a/proliantutils/tests/ilo/test_client.py +++ b/proliantutils/tests/ilo/test_client.py @@ -1162,6 +1162,24 @@ class IloClientTestCase(testtools.TestCase): self.client.get_host_post_state() get_host_post_state_mock.assert_called_once_with() + @mock.patch.object(client.IloClient, '_call_method') + def test_get_bios_settings_result(self, call_mock): + self.client.get_bios_settings_result() + call_mock.assert_called_once_with('get_bios_settings_result') + + @mock.patch.object(ris.RISOperations, 'get_bios_settings_result') + def test_get_bios_settings_result_gen9(self, get_bios_settings_mock): + self.client.model = 'Gen9' + self.client.get_bios_settings_result() + get_bios_settings_mock.assert_called_once_with() + + @mock.patch.object(ribcl.RIBCLOperations, 'get_product_name') + def test_get_bios_settings_result_gen8(self, product_mock): + self.client.model = 'Gen8' + self.assertRaisesRegexp(exception.IloCommandNotSupportedError, + 'not supported', + self.client.get_bios_settings_result) + class IloRedfishClientTestCase(testtools.TestCase): diff --git a/proliantutils/tests/ilo/test_ribcl.py b/proliantutils/tests/ilo/test_ribcl.py index ce37fca5..403e7774 100644 --- a/proliantutils/tests/ilo/test_ribcl.py +++ b/proliantutils/tests/ilo/test_ribcl.py @@ -1082,5 +1082,12 @@ class IloRibclTestCaseBeforeRisSupport(unittest.TestCase): self.ilo.create_raid_configuration, raid_config) + @mock.patch.object(ribcl.RIBCLOperations, 'get_product_name') + def test_get_bios_settings_result(self, product_name_mock): + product_name_mock.return_value = constants.GET_PRODUCT_NAME + self.assertRaisesRegexp(exception.IloCommandNotSupportedError, + 'ProLiant DL380 G7', + self.ilo.get_bios_settings_result) + if __name__ == '__main__': unittest.main() diff --git a/proliantutils/tests/ilo/test_ris.py b/proliantutils/tests/ilo/test_ris.py index f23e8deb..8516bcec 100755 --- a/proliantutils/tests/ilo/test_ris.py +++ b/proliantutils/tests/ilo/test_ris.py @@ -1565,6 +1565,63 @@ class IloRisTestCase(testtools.TestCase): self.client.set_bios_settings(data, apply_filter) change_bios_mock.assert_called_once_with(data) + @mock.patch.object(ris.RISOperations, '_check_bios_resource') + def test_get_bios_settings_result_failed(self, check_bios_mock): + bios_uri = '/rest/v1/systems/1/bios' + settings = json.loads(ris_outputs.GET_BIOS_SETTINGS_FAILED) + check_bios_mock.return_value = (ris_outputs.GET_HEADERS, + bios_uri, settings) + actual_results = [ + { + "MessageArgs": [ + "MinProcIdlePkgState" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "MinProcIdlePower" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "EnergyPerfBias" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "PowerRegulator" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [], + "MessageID": "Base.1.0:Success" + } + ] + actual = {"status": "failed", "results": actual_results} + expected = self.client.get_bios_settings_result() + check_bios_mock.assert_called_once_with() + self.assertEqual(expected, actual) + + @mock.patch.object(ris.RISOperations, '_check_bios_resource') + def test_get_bios_settings_result_success(self, check_bios_mock): + bios_uri = '/rest/v1/systems/1/bios' + settings = json.loads(ris_outputs.GET_BIOS_SETTINGS) + actual_results = [ + { + "MessageArgs": [], + "MessageID": "Base.1.0:Success" + } + ] + actual = {"status": "success", "results": actual_results} + check_bios_mock.return_value = (ris_outputs.GET_HEADERS, + bios_uri, settings) + expected = self.client.get_bios_settings_result() + self.assertEqual(expected, actual) + class TestRISOperationsPrivateMethods(testtools.TestCase): diff --git a/proliantutils/tests/redfish/json_samples/bios.json b/proliantutils/tests/redfish/json_samples/bios.json index 10a2f724..afe095cf 100644 --- a/proliantutils/tests/redfish/json_samples/bios.json +++ b/proliantutils/tests/redfish/json_samples/bios.json @@ -6,15 +6,6 @@ "Messages": [ { "MessageId": "Base.1.0.Success" - }, - { - "MessageArgs": [ - "NumaGroupSizeOpt" - ], - "MessageId": "Base.1.0.PropertyNotWritable", - "RelatedProperties": [ - "#/NumaGroupSizeOpt" - ] } ], "SettingsObject": { diff --git a/proliantutils/tests/redfish/json_samples/bios_failed.json b/proliantutils/tests/redfish/json_samples/bios_failed.json new file mode 100644 index 00000000..b56290ef --- /dev/null +++ b/proliantutils/tests/redfish/json_samples/bios_failed.json @@ -0,0 +1,535 @@ +{ + "Default": { + "@Redfish.Settings": { + "@odata.type": "#Settings.v1_0_0.Settings", + "ETag": "C4690603", + "Messages": [ + { + "MessageArgs": [ + "MinProcIdlePkgState" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "MinProcIdlePower" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "EnergyPerfBias" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "PowerRegulator" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [], + "MessageID": "Base.1.0:Success" + } + ], + "SettingsObject": { + "@odata.id": "/redfish/v1/systems/1/bios/settings/" + }, + "Time": "2017-06-10T07:40:44+00:00" + }, + "@odata.context": "/redfish/v1/$metadata#Bios.Bios", + "@odata.etag": "W/\"EC55BACC2FF03737379F24EEF1948CE0\"", + "@odata.id": "/redfish/v1/systems/1/bios/", + "@odata.type": "#Bios.v1_0_0.Bios", + "Actions": { + "#Bios.ChangePassword": { + "target": "/redfish/v1/systems/1/bios/settings/Actions/Bios.ChangePasswords/" + }, + "#Bios.ResetBios": { + "target": "/redfish/v1/systems/1/bios/settings/Actions/Bios.ResetBios/" + } + }, + "AttributeRegistry": "BiosAttributeRegistryU31.v1_1_00", + "Attributes": { + "AcpiHpet": "Enabled", + "AcpiRootBridgePxm": "Enabled", + "AcpiSlit": "Enabled", + "AdjSecPrefetch": "Enabled", + "AdminEmail": "", + "AdminName": "", + "AdminPassword": "password", + "AdminOtherInfo": "", + "AdminPhone": "", + "AdvancedMemProtection": "AdvancedEcc", + "AsrStatus": "Enabled", + "AsrTimeoutMinutes": "Timeout10", + "AssetTagProtection": "Unlocked", + "AutoPowerOn": "RestoreLastState", + "BootMode": "Uefi", + "BootOrderPolicy": "RetryIndefinitely", + "ChannelInterleaving": "Enabled", + "Chipset_TpmFeatureEnableOrDisable": "Disabled", + "Chipset_TpmFeatureType": "Chipset-TpmFeature:NONE", + "CollabPowerControl": "Enabled", + "ConsistentDevNaming": "LomsAndSlots", + "CustomPostMessage": "", + "DaylightSavingsTime": "Disabled", + "DcuIpPrefetcher": "Enabled", + "DcuStreamPrefetcher": "Enabled", + "Description": "Default settings", + "Dhcpv4": "Enabled", + "DynamicPowerCapping": "Disabled", + "EmbNicAspm": "Disabled", + "EmbNicEnable": "Auto", + "EmbNicLinkSpeed": "Auto", + "EmbNicPCIeOptionROM": "Enabled", + "EmbSas1Aspm": "Disabled", + "EmbSas1LinkSpeed": "Auto", + "EmbSas1PcieOptionROM": "Enabled", + "EmbSata1Enable": "Auto", + "EmbSata1PCIeOptionROM": "Enabled", + "EmbSata2Enable": "Auto", + "EmbSata2PCIeOptionROM": "Enabled", + "EmbVideoConnection": "Auto", + "EmbeddedDiagnostics": "Enabled", + "EmbeddedDiagsMode": "Auto", + "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", + "HpeScalablePmemBackupState": "Complete", + "HpeScalablePmemConfigurationRestoration": "Disabled", + "HpeScalablePmemFunctionalityEnabled": "Disabled", + "HpeScalablePmemStorageInitialize": "Disabled", + "HttpSupport": "Auto", + "HwPrefetcher": "Enabled", + "IntelDmiLinkFreq": "Auto", + "IntelNicDmaChannels": "Enabled", + "IntelPerfMonitoring": "Disabled", + "IntelProcVtd": "Enabled", + "IntelUpiFreq": "Auto", + "IntelUpiLinkEn": "Auto", + "IntelUpiPowerManagement": "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": "::", + "LocalRemoteThreshold": "Auto", + "MaxMemBusFreqMHz": "Auto", + "MaxPcieSpeed": "PerPortCtrl", + "MemClearWarmReset": "Disabled", + "MemFastTraining": "Enabled", + "MemMirrorMode": "Full", + "MemPatrolScrubbing": "Enabled", + "MemRefreshRate": "Refreshx2", + "MemoryRemap": "NoAction", + "MinProcIdlePkgState": "C6Retention", + "MinProcIdlePower": "C6", + "MixedPowerSupplyReporting": "Enabled", + "NetworkBootRetry": "Enabled", + "NetworkBootRetryCount": 20, + "NicBoot1": "NetworkBoot", + "NicBoot3": "Disabled", + "NicBoot4": "Disabled", + "NodeInterleaving": "Disabled", + "NumaGroupSizeOpt": "Clustered", + "NvDimmNMemInterleaving": "Disabled", + "NvmeOptionRom": "Enabled", + "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", + "PersistentMemAddressRangeScrub": "Enabled", + "PersistentMemBackupPowerPolicy": "WaitForBackupPower", + "PersistentMemScanMem": "Enabled", + "PostBootProgress": "Disabled", + "PostDiscoveryMode": "ForceFullDiscovery", + "PostF1Prompt": "Delayed20Sec", + "PowerButton": "Enabled", + "PowerOnDelay": "NoDelay", + "PowerOnLogo": "Enabled", + "PowerRegulator": "DynamicPowerSavings", + "PreBootNetwork": "Auto", + "PrebootNetworkEnvPolicy": "Auto", + "PrebootNetworkProxy": "", + "ProcAes": "Enabled", + "ProcHyperthreading": "Enabled", + "ProcTurbo": "Enabled", + "ProcVirtualization": "Enabled", + "ProcX2Apic": "Enabled", + "Processor1LogicalNvdimm1SizeGiB": 0, + "Processor1LogicalNvdimm2SizeGiB": 0, + "Processor1ScalablePmemAvailableGiB": 0, + "Processor2LogicalNvdimm1SizeGiB": 0, + "Processor2LogicalNvdimm2SizeGiB": 0, + "Processor2ScalablePmemAvailableGiB": 0, + "Processor3LogicalNvdimm1SizeGiB": 0, + "Processor3LogicalNvdimm2SizeGiB": 0, + "Processor3ScalablePmemAvailableGiB": 0, + "Processor4LogicalNvdimm1SizeGiB": 0, + "Processor4LogicalNvdimm2SizeGiB": 0, + "Processor4ScalablePmemAvailableGiB": 0, + "ProcessorJitterControl": "Disabled", + "ProcessorJitterControlFrequency": 0, + "ProductId": "", + "RedundantPowerSupply": "BalancedMode", + "RemovableFlashBootSeq": "ExternalKeysFirst", + "RestoreDefaults": "No", + "RestoreManufacturingDefaults": "No", + "RomSelection": "CurrentRom", + "SataSecureErase": "Disabled", + "SaveUserDefaults": "No", + "ScalablePmemCapacity": 0, + "SecureBootStatus": "Disabled", + "SerialConsoleBaudRate": "BaudRate115200", + "SerialConsoleEmulation": "Vt100Plus", + "SerialConsolePort": "Auto", + "SerialNumber": "", + "ServerAssetTag": "", + "ServerName": "", + "ServerOtherInfo": "", + "ServerPrimaryOs": "", + "ServiceEmail": "", + "ServiceName": "", + "ServiceOtherInfo": "", + "ServicePhone": "", + "SetupBrowserSelection": "Auto", + "SpannedLogicalNvdimm1AvailableMemoryGiB": 0, + "SpannedLogicalNvdimm1SizeGiB": 0, + "SpannedLogicalNvdimm1StartingDomainId": 0, + "SpannedLogicalNvdimm1StartingDomainSize": 0, + "SpannedLogicalNvdimm2AvailableMemoryGiB": 0, + "SpannedLogicalNvdimm2SizeGiB": 0, + "SpannedLogicalNvdimm2StartingDomainId": 0, + "SpannedLogicalNvdimm2StartingDomainSize": 0, + "Sriov": "Enabled", + "SubNumaClustering": "Disabled", + "ThermalConfig": "OptimalCooling", + "ThermalShutdown": "Enabled", + "TimeFormat": "Utc", + "TimeZone": "Utc0", + "TpmChipId": "None", + "TpmFips": "NotSpecified", + "TpmState": "NotPresent", + "TpmType": "NoTpm", + "UefiOptimizedBoot": "Enabled", + "UefiPxeBoot": "Enabled", + "UefiSerialDebugLevel": "Disabled", + "UefiShellBootOrder": "Disabled", + "UefiShellScriptVerification": "Disabled", + "UefiShellStartup": "Disabled", + "UefiShellStartupLocation": "Auto", + "UefiShellStartupUrl": "", + "UefiShellStartupUrlFromDhcp": "Disabled", + "UncoreFreqScaling": "Auto", + "UpiPrefetcher": "Enabled", + "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": "Enabled", + "iSCSIPolicy": "SoftwareInitiator" + }, + "Id": "bios", + "Name": "BIOS Current Settings", + "Oem": { + "Hpe": { + "@odata.type": "#HpeBiosExt.v2_0_0.HpeBiosExt", + "Links": { + "BaseConfigs": { + "@odata.id": "/redfish/v1/systems/1/bios/baseconfigs/" + }, + "Boot": { + "@odata.id": "/redfish/v1/systems/1/bios/boot/" + }, + "Mappings": { + "@odata.id": "/redfish/v1/systems/1/bios/mappings/" + }, + "ScalablePmem": { + "@odata.id": "/redfish/v1/systems/1/bios/hpescalablepmem/" + }, + "TlsConfig": { + "@odata.id": "/redfish/v1/systems/1/bios/tlsconfig/" + }, + "iScsi": { + "@odata.id": "/redfish/v1/systems/1/bios/iscsi/" + } + }, + "SettingsObject": { + "UnmodifiedETag": "W/\"7F2D028BA2542B2B2B2AF4CFFD358F35\"" + } + } + } + }, + + "BIOS_pending_settings_default": { + "@odata.context": "/redfish/v1/$metadata#Bios.Bios", + "@odata.etag": "W/\"7F2D028BA2542B2B2B2AF4CFFD358F35\"", + "@odata.id": "/redfish/v1/systems/1/bios/settings/", + "@odata.type": "#Bios.v1_0_0.Bios", + "AttributeRegistry": "BiosAttributeRegistryU31.v1_1_00", + "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" + } +} diff --git a/proliantutils/tests/redfish/test_redfish.py b/proliantutils/tests/redfish/test_redfish.py index 3a397212..148af463 100644 --- a/proliantutils/tests/redfish/test_redfish.py +++ b/proliantutils/tests/redfish/test_redfish.py @@ -1725,3 +1725,62 @@ class RedfishOperationsTestCase(testtools.TestCase): expected = [('HPE Smart Array P408i-p SR Gen10', config)] get_system_mock.return_value.read_raid.return_value = expected self.assertEqual(expected, self.rf_client.read_raid_configuration()) + + @mock.patch.object(redfish.RedfishOperations, '_get_sushy_system') + def test_get_bios_settings_result_failed(self, get_system_mock): + with open('proliantutils/tests/redfish/' + 'json_samples/bios_failed.json', 'r') as f: + jsonval = json.loads(f.read()).get("Default") + + type(get_system_mock.return_value.bios_settings).messages = ( + jsonval['@Redfish.Settings']['Messages']) + + expected_settings = [ + { + "MessageArgs": [ + "MinProcIdlePkgState" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "MinProcIdlePower" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "EnergyPerfBias" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [ + "PowerRegulator" + ], + "MessageID": "Base.1.0:PropertyNotWritable" + }, + { + "MessageArgs": [], + "MessageID": "Base.1.0:Success" + } + ] + expected = {"status": "failed", "results": expected_settings} + actual = self.rf_client.get_bios_settings_result() + self.assertEqual(expected, actual) + + @mock.patch.object(redfish.RedfishOperations, '_get_sushy_system') + def test_get_bios_settings_result_success(self, get_system_mock): + with open('proliantutils/tests/redfish/' + 'json_samples/bios.json', 'r') as f: + jsonval = json.loads(f.read()).get("Default") + actual_settings = [ + { + "MessageId": "Base.1.0.Success" + } + ] + type(get_system_mock.return_value.bios_settings).messages = ( + jsonval['@Redfish.Settings']['Messages']) + actual = self.rf_client.get_bios_settings_result() + expected = {"status": "success", "results": actual_settings} + self.assertEqual(expected, actual)