dell / iDRAC-Redfish-Scripting

Python and PowerShell scripting for Dell EMC PowerEdge iDRAC REST API with DMTF Redfish
GNU General Public License v2.0
598 stars 276 forks source link

questions about messing with the BIOS #249

Closed parmentelat closed 1 year ago

parmentelat commented 1 year ago

Hi

I have a few questions when it comes to tweaking the BIOS; plus: please correct me below if I say anything wrong or stupid :)


changes in the BIOS

consider the following scenario

however I'd like to offer my users a more incremental way of changing bios settings, so:

Q1: is there a way to inspect the job in order to retrieve the Setting1=newvalue1 and Setting2=newvalue2 that were attached to it ?


resetting the BIOS

our scenarios actually involve

and because a reboot is taking some substantial time I was kind of hoping to be able to do all this through a single reboot

however, I'm still in the middle of my tests to assess what's exactly going on here, but it definitely feels like it's not going to be that easy, and that several reboots may be needed to run from that configuration; so

Q4: would you please care to elaborate on what I could expect to work or not in this kind of scenario ?

and as an aside

Q5: is there a way to know that a pending 'reset the bios' request has been sent and not yet honoured ? is there a way to cancel that as well ? (I can't seem to see that in the queue shown by DeleteJobQueue)


many thanks in advance for your answers

texroemer commented 1 year ago

Hi @parmentelat

For setting BIOS pending attribute values, once a config job has been created you are not allowed to set other BIOS pending attribute values until either the config job has been executed or delete the job. But if you delete the job you have to set once again the other attributes before you created the config job along with the new attributes you want to set.

Here's the workflow you should follow if you want to only set pending values and want to set more pending values later before you actually want to apply them. Btw there are already plans to improve this behavior in a future iDRAC release which will allow you to set more attributes even when a config job is already created but you have not rebooted the server.

  1. Set one BIOS attribute. Now don't pass in @Redfish.SettingsApplyTime in the body. By doing this you will only be setting pending values.
[root@SCPexport ~]# curl -k -u root:calvin -X PATCH https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Bios/Settings --insecure -H "Content-Type: application/json" -i -d '{"Attributes":{"MemTest":"Disabled"}}'
HTTP/1.1 200 OK
Date: Mon, 06 Mar 2023 23:36:48 GMT
Server: Apache
OData-Version: 4.0
Access-Control-Allow-Origin: *
Cache-Control: no-cache
X-Frame-Options: DENY
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Content-Length: 506
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8

{"@Message.ExtendedInfo":[{"Message":"The request completed successfully.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"Base.1.12.Success","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"None","Severity":"OK"},{"Message":"The operation successfully completed.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"IDRAC.2.8.SYS413","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"No response action is required.","Severity":"Informational"}]}
  1. GET on URI "redfish/v1/Systems/System.Embedded.1/Bios/Settings", you will see pending attribute values which are currently set.
[root@SCPexport ~]# curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Bios/Settings --i
nsecure | python3.6 -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   780  100   780    0     0   1984      0 --:--:-- --:--:-- --:--:--  1984
{
    "@odata.context": "/redfish/v1/$metadata#Bios.Bios",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios/Settings",
    "@odata.type": "#Bios.v1_2_0.Bios",
    "Id": "Settings",
    "Name": "BIOS Configuration Pending Settings",
    "Description": "BIOS Configuration Pending Settings. These settings will be applied on next system reboot.",
    "AttributeRegistry": "BiosAttributeRegistry.v1_0_3",
    "Attributes": {
        "MemTest": "Disabled"
    },
    "Actions": {
        "Oem": {
            "DellManager.v1_0_0#DellManager.ClearPending": {
                "target": "/redfish/v1/Systems/System.Embedded.1/Bios/Settings/Actions/Oem/DellManager.ClearPending"
            }
        }
    },
    "Oem": {
        "Dell": {
            "@odata.context": "/redfish/v1/$metadata#DellManager.DellManager",
            "@odata.type": "#DellManager.v1_3_0.DellManager",
            "Jobs": {
                "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs"
            }
        }
    }
}
  1. Run PATCH again to set another BIOS attribute.
[root@SCPexport ~]# curl -k -u root:calvin -X PATCH https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Bios/Settings --insecure -H "Content-Type: application/json" -i -d '{"Attributes":{"SysProfile":"Custom"}}'
HTTP/1.1 200 OK
Date: Mon, 06 Mar 2023 23:45:24 GMT
Server: Apache
OData-Version: 4.0
Access-Control-Allow-Origin: *
Cache-Control: no-cache
X-Frame-Options: DENY
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Content-Length: 506
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8

{"@Message.ExtendedInfo":[{"Message":"The request completed successfully.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"Base.1.12.Success","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"None","Severity":"OK"},{"Message":"The operation successfully completed.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"IDRAC.2.8.SYS413","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"No response action is required.","Severity":"Informational"}]}
  1. Check pending settings again to see the new attribute you just set pending for reported.
[root@SCPexport ~]# curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Bios/Settings --insecure | python3.6 -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   802  100   802    0     0   3084      0 --:--:-- --:--:-- --:--:--  3096
{
    "@odata.context": "/redfish/v1/$metadata#Bios.Bios",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios/Settings",
    "@odata.type": "#Bios.v1_2_0.Bios",
    "Id": "Settings",
    "Name": "BIOS Configuration Pending Settings",
    "Description": "BIOS Configuration Pending Settings. These settings will be applied on next system reboot.",
    "AttributeRegistry": "BiosAttributeRegistry.v1_0_3",
    "Attributes": {
        "SysProfile": "Custom",
        "MemTest": "Disabled"
    },
    "Actions": {
        "Oem": {
            "DellManager.v1_0_0#DellManager.ClearPending": {
                "target": "/redfish/v1/Systems/System.Embedded.1/Bios/Settings/Actions/Oem/DellManager.ClearPending"
            }
        }
    },
    "Oem": {
        "Dell": {
            "@odata.context": "/redfish/v1/$metadata#DellManager.DellManager",
            "@odata.type": "#DellManager.v1_3_0.DellManager",
            "Jobs": {
                "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs"
            }
        }
    }
}
  1. Once you're done setting all BIOS pending attribute values, create the config job.
[root@SCPexport ~]# curl -k -u root:calvin -X POST https://192.168.0.120/redfish/v1/Managers/iDRAC.Embedded.1/Jobs --insecure
-H "Content-Type: application/json" -i -d '{"TargetSettingsURI":"/redfish/v1/Systems/System.Embedded.1/Bios/Settings"}'
HTTP/1.1 200 OK
Date: Mon, 06 Mar 2023 23:48:16 GMT
Server: Apache
OData-Version: 4.0
Access-Control-Allow-Origin: *
Cache-Control: no-cache
X-Frame-Options: DENY
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Location: /redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs/JID_781464969632
Content-Length: 506
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8

{"@Message.ExtendedInfo":[{"Message":"The request completed successfully.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"Base.1.12.Success","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"None","Severity":"OK"},{"Message":"The operation successfully completed.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"IDRAC.2.8.SYS413","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"No response action is required.","Severity":"Informational"}]}
  1. Confirm job ID is scheduled.
[root@SCPexport ~]# curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs/JID_781464969632 --insecure
{"@odata.context":"/redfish/v1/$metadata#DellJob.DellJob","@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs/JID_781464969632","@odata.type":"#DellJob.v1_4_0.DellJob","ActualRunningStartTime":null,"ActualRunningStopTime":null,"CompletionTime":null,"Description":"Job Instance","EndTime":"TIME_NA","Id":"JID_781464969632","JobState":"Scheduled","JobType":"BIOSConfiguration","Message":"Task successfully scheduled.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"JCP001","Name":"Configure: BIOS.Setup.1-1","PercentComplete":0,"StartTime":"2023-03-06T17:48:16","TargetSettingsURI":null}
  1. Reboot the server to execute the config job.
[root@SCPexport ~]# curl -k -u root:calvin -X POST https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset --insecure -H "Content-Ty
pe: application/json" -i -d '{"ResetType":"ForceRestart"}'
HTTP/1.1 204 No Content
Strict-Transport-Security: max-age=63072000
OData-Version: 4.0
OData-EntityId: /redfish/v1/Systems/System.Embedded.1
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8
Server: iDRAC/8
Date: Mon, 06 Mar 2023 22:04:32 GMT
Cache-Control: no-cache
Content-Length: 0
Connection: Keep-Alive
Access-Control-Allow-Origin: *
Accept-Ranges: bytes

For resetting the BIOS to default settings (RTD) workflow, there is no way to avoid multiple reboots since BIOS itself needs a reboot after running RTD and applying attribute changes. But you can stack these operations to where you only need to make one reboot action, the other reboots will be queued up by BIOS and iDRAC, run automatically.

Workflow below will:

  1. Attach ISO
  2. Set next onetime boot to virtual CD
  3. Set BIOS RTD
  4. Set BIOS attributes
  5. Reboot the server

Once the server manually reboots it will run BIOS RTD and complete, server will auto reboot. POST starts and BIOS config job will run to change BIOS attributes, server auto reboot. POST starts and once complete will onetime boot to virtual CD.

C:\Python310>python InsertEjectVirtualMediaREDFISH.py -ip 192.168.0.120 -u root -p calvin --action insert --index 1 --uripath http://releases.ubuntu.com/focal/ubuntu-20.04.5-desktop-amd64.iso

- PASS, POST command passed to successfully insert virtual media, status code 204 returned

C:\Python310>python SetNextOneTimeBootVirtualMediaDeviceOemREDFISH.py -ip 192.168.0.120 -u root -p calvin --device 1

- INFO, setting next onetime boot device to Virtual CD
- PASS, successfully set next onetime boot device to Virtual CD
- INFO, argument --reboot not detected. Onetime boot will be applied on next manual server reboot

NOTE: This is how you check to see if BIOS RTD flag is set.

C:\Python310>python GetIdracLcSystemAttributesREDFISH.py -ip 192.168.0.120 -u root -p calvin --group-name lc --attribute-name LCAttributes.1.BIOSRTDRequested

Attribute Name: LCAttributes.1.BIOSRTDRequested, Current Value: False

C:\Python310>python BiosResetToDefaultsREDFISH.py -ip 192.168.0.120 -u root -p calvin --noreboot

- PASS: status code 200 returned for POST command to reset BIOS to default settings
- INFO, --noreboot argument detected. Rest to defaults flag is still set and will happen on next server manual reboot

C:\Python310>python GetIdracLcSystemAttributesREDFISH.py -ip 192.168.0.120 -u root -p calvin --group-name lc --attribute-name LCAttributes.1.BIOSRTDRequested

Attribute Name: LCAttributes.1.BIOSRTDRequested, Current Value: True

C:\Python310>python GetSetBiosAttributesREDFISH.py -ip 192.168.0.120 -u root -p calvin --attribute-names MemTest --attribute-values Enabled --reboot

- INFO, script will be setting BIOS attribute(s) -

Attribute Name: MemTest, setting new value to: Enabled

- PASS: PATCH command passed to set BIOS attribute pending values and create next reboot config job, status code 202 returned
- PASS, BIOS config job ID JID_781503905183 successfully created
- INFO: job status not scheduled, current status: New
- INFO, staged config job marked as scheduled

- INFO, Current server power state is: On
- PASS, POST command passed to gracefully power OFF server
- INFO, script will now verify the server was able to perform a graceful shutdown. If the server was unable to perform a graceful shutdown, forced shutdown will be invoked in 5 minutes
- INFO, unable to perform graceful shutdown, server will now perform forced shutdown
- PASS, POST command passed to perform forced shutdown
- PASS, GET command passed to verify forced shutdown was successful and server is in OFF state
- PASS, POST command passed to power ON server
- INFO, job status not completed, current status: "Task successfully scheduled."
- INFO, job status not completed, current status: "Task successfully scheduled."
- INFO, job status not completed, current status: "Job in progress."
- INFO, job status not completed, current status: "Job in progress."
- INFO, job status not completed, current status: "Job in progress."
- INFO, job status not completed, current status: "Job in progress."
- INFO, job status not completed, current status: "Job in progress."
- INFO, job status not completed, current status: "Job in progress."

--- PASS, Final Detailed Job Status Results ---

('@odata.context', '/redfish/v1/$metadata#DellJob.DellJob')
('@odata.id',
 '/redfish/v1/Managers/iDRAC.Embedded.1/Oem/Dell/Jobs/JID_781503905183')
('@odata.type', '#DellJob.v1_4_0.DellJob')
('ActualRunningStartTime', '2023-03-06T19:04:19')
('ActualRunningStopTime', '2023-03-06T19:08:19')
('CompletionTime', '2023-03-06T19:08:19')
('Description', 'Job Instance')
('EndTime', 'TIME_NA')
('Id', 'JID_781503905183')
('JobState', 'Completed')
('JobType', 'BIOSConfiguration')
('Message', 'Job completed successfully.')
('MessageArgs', [])
('MessageArgs@odata.count', 0)
('MessageId', 'PR19')
('Name', 'Configure: BIOS.Setup.1-1')
('PercentComplete', 100)
('StartTime', '2023-03-06T18:53:10')
('TargetSettingsURI', None)
parmentelat commented 1 year ago

Hello @texroemer Sorry for not having been able to follow-up at the time, as I have undergone surgery in the meanwhile and am only just now catching up on this topic Regardless, I really thank you for the detailed and insightful explanation, it looks like I have all the information I need to achieve my goals :)

texroemer commented 1 year ago

Hi @parmentelat

No worries and hope you're surgery went well :)