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

how to Change Boot Order via Redfish API for Dell R720 Firmware Version 2.65.65.65 #250

Closed kashif-nawaz closed 1 year ago

kashif-nawaz commented 1 year ago

I am trying to boot Dell R720 from remote virtual media mounted via Redfish

Method:1 (post method failing)

curl -X PATCH -H 'Content-Type: application/json' \ -d ' "Attributes": { "BootSeq": [ { "Enabled": true, "Index": 0, "Name": "Optical.iDRACVirtual.1-1" } ], }' \ -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' \ -k "https://$REDFISH_HOST/redfish/v1/Systems/System.Embedded.1/BootSources/Settings" \ | jq .

Method:2 (post method is successful but node is getting boot local HDD) curl -d '{"Image":"'"http://192.168.24.13:8080/rhcos/discovery_image_ocpd.iso"'", "Inserted": true}' \ -H 'Content-Type: application/json' \ -X POST \ -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' \ -v -k https://192.168.100.121/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia

curl -s -k -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' https://$REDFISH_HOST/redfish/v1/Managers/$REDFISH_MANAGER/VirtualMedia/CD/ | jq . { "@odata.context": "/redfish/v1/$metadata#VirtualMedia.VirtualMedia", "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD", "@odata.type": "#VirtualMedia.v1_2_0.VirtualMedia", "Actions": { "#VirtualMedia.EjectMedia": { "target": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.EjectMedia" }, "#VirtualMedia.InsertMedia": { "target": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia" } }, "ConnectedVia": "URI", "Description": "iDRAC Virtual Media Services Settings", "Id": "CD", "Image": "http://192.168.24.13:8080/rhcos/discovery_image_ocpd.iso", "ImageName": "discovery_image_ocpd.iso", "Inserted": true, "MediaTypes": [ "CD", "DVD" ], "MediaTypes@odata.count": 2, "Name": "Virtual CD", "WriteProtected": true }

curl -X PATCH -H 'Content-Type: application/json' \ -d '{ "Boot": { "BootSourceOverrideTarget": "Cd", "BootSourceOverrideEnabled": "Continuous" } }' \ -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' \ -k "https://$REDFISH_HOST/redfish/v1/Systems/$REDFISH_SYSTEM" \ | jq .

curl -s -k -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' https://$REDFISH_HOST/redfish/v1/Systems/$REDFISH_SYSTEM/ | jq .Boot { "BootOptions": { "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions" }, "BootOrder": [ "Optical.SATAEmbedded.F-1", "HardDisk.List.1-1", "NIC.Integrated.1-4-1", "Floppy.iDRACVirtual.1-1", "Optical.iDRACVirtual.1-1" ], "BootOrder@odata.count": 5, "BootSourceOverrideEnabled": "Continuous", "BootSourceOverrideMode": "Legacy", "BootSourceOverrideTarget": "Cd", "BootSourceOverrideTarget@Redfish.AllowableValues": [ "None", "Pxe", "Cd", "Floppy", "Hdd", "BiosSetup", "Utilities", "UefiTarget", "SDCard", "UefiHttp" ] }

curl -s -k -u ''"$REDFISH_USER"'':''"$REDFISH_PASS"'' https://$REDFISH_HOST/redfish/v1/Managers/$REDFISH_MANAGER/VirtualMedia/CD/ | jq . { "@odata.context": "/redfish/v1/$metadata#VirtualMedia.VirtualMedia", "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD", "@odata.type": "#VirtualMedia.v1_2_0.VirtualMedia", "Actions": { "#VirtualMedia.EjectMedia": { "target": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.EjectMedia" }, "#VirtualMedia.InsertMedia": { "target": "/redfish/v1/Managers/iDRAC.Embedded.1/VirtualMedia/CD/Actions/VirtualMedia.InsertMedia" } }, "ConnectedVia": "URI", "Description": "iDRAC Virtual Media Services Settings", "Id": "CD", "Image": "http://192.168.24.13:8080/rhcos/discovery_image_ocpd.iso", "ImageName": "discovery_image_ocpd.iso", "Inserted": true, "MediaTypes": [ "CD", "DVD" ], "MediaTypes@odata.count": 2, "Name": "Virtual CD", "WriteProtected": true

texroemer commented 1 year ago

Hi @kashif-nawaz

Here's a workflow example of how to change the boot order on 12G server with setting virtual CD as first device in the boot order. Once you run PATCH to set the boot order, this is only setting pending value. You need to create a config job, reboot the server to apply the pending changes.

  1. Get current boot order. My server is currently in UEFI boot mode, first device is "Unknown.Unknown.1-1".
[root@SCPexport ~]# curl -k -u user:calvin -X GET https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/BootSources --insecure | python3.6 -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3470  100  3470    0     0   3800      0 --:--:-- --:--:-- --:--:--  3796
{
    "@Redfish.Settings": {
        "@odata.context": "/redfish/v1/$metadata#Settings.Settings",
        "@odata.type": "#Settings.v1_1_0.Settings",
        "SettingsObject": {
            "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources/Settings"
        },
        "SupportedApplyTimes": [
            "OnReset",
            "AtMaintenanceWindowStart",
            "InMaintenanceWindowOnReset"
        ]
    },
    "@odata.context": "/redfish/v1/$metadata#DellBootSources.DellBootSources",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources",
    "@odata.type": "#DellBootSources.v1_0_0.DellBootSources",
    "AttributeRegistry": "DellBootSourcesRegistry.v1_0_0",
    "Attributes": {
        "BootSeq": [
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Optical.SATAEmbedded.E-1#6ef2870508c6cbc609685e118bc34df3",
                "Index": 0,
                "Name": "Optical.SATAEmbedded.E-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#HardDisk.List.1-1#c9203080df84781e2ca3d512883dee6f",
                "Index": 1,
                "Name": "HardDisk.List.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Floppy.iDRACVirtual.1-1#8fd02749adddb7fe2f0cfd786fd48e84",
                "Index": 2,
                "Name": "Floppy.iDRACVirtual.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Optical.iDRACVirtual.1-1#5750dc922db69eeefcc3a67d73ab1828",
                "Index": 3,
                "Name": "Optical.iDRACVirtual.1-1"
            }
        ],
        "HddSeq": [
            {
                "Id": "BIOS.Setup.1-1#HddSeq#RAID.Integrated.1-1#7af2f9decdf2a27aaa8616db3ad18a60",
                "Index": 0,
                "Name": "RAID.Integrated.1-1"
            }
        ],
        "UefiBootSeq": [
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#UefiBootSeq#Unknown.Unknown.1-1#6a5b6f7087238ab1275889252ad0dffe",
                "Index": 0,
                "Name": "Unknown.Unknown.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#UefiBootSeq#Unknown.Unknown.2-1#b84ffb92d8709ef948daa490efb55611",
                "Index": 1,
                "Name": "Unknown.Unknown.2-1"
            },

2. Run PATCH to set pending boot order, virtual CD as first device.

[root@SCPexport ~]# curl -k -u root:calvin -X PATCH https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/BootSources/Settings --insecure -H "Content-Type: application/json" -i -d '{"Attributes": {"UefiBootSeq":[{"Index": 0, "Enabled": true, "Id": "BIOS.Setup.1-1#UefiBootSeq#Optical.iDRACVirtual.1-1#375d3ecb49f87dd46ca6c60e34f6155d", "Name": "Optical.iDRACVirtual.1-1"}]}}'
HTTP/1.1 200 OK
Strict-Transport-Security: max-age=63072000
OData-Version: 4.0
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8
Server: iDRAC/8
Date: Mon, 06 Mar 2023 21:59:21 GMT
Cache-Control: no-cache
Content-Length: 501
Connection: Keep-Alive
Access-Control-Allow-Origin: *
Accept-Ranges: bytes

{"@Message.ExtendedInfo":[{"Message":"Successfully Completed Request","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"Base.1.2.Success","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"None","Severity":"OK"},{"Message":"The operation successfully completed.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"IDRAC.1.6.SYS413","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"No response action is required.","Severity":"Informational"}]}

3. Create a BIOS config job to apply the new boot order, job ID URI will be returned in the headers output.

[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
Strict-Transport-Security: max-age=63072000
OData-Version: 4.0
Vary: Accept-Encoding
Content-Type: application/json;odata.metadata=minimal;charset=utf-8
Server: iDRAC/8
Location: /redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_781399840295
Date: Mon, 06 Mar 2023 21:59:47 GMT
Cache-Control: no-cache
Content-Length: 501
Connection: Keep-Alive
Access-Control-Allow-Origin: *
Accept-Ranges: bytes

{"@Message.ExtendedInfo":[{"Message":"Successfully Completed Request","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"Base.1.2.Success","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"None","Severity":"OK"},{"Message":"The operation successfully completed.","MessageArgs":[],"MessageArgs@odata.count":0,"MessageId":"IDRAC.1.6.SYS413","RelatedProperties":[],"RelatedProperties@odata.count":0,"Resolution":"No response action is required.","Severity":"Informational"}]}

4. Confirm the job state is marked as scheduled. 

[root@SCPexport ~]# curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_781399840295 --insecure
{"@odata.context":"/redfish/v1/$metadata#DellJob.DellJob","@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_781399840295","@odata.type":"#DellJob.v1_0_1.DellJob","CompletionTime":null,"Description":"Job Instance","EndTime":"TIME_NA","Id":"JID_781399840295","JobState":"Scheduled","JobType":"BIOSConfiguration","Message":"Task successfully scheduled.","MessageArgs":[],"MessageId":"JCP001","Name":"ConfigBIOS:BIOS.Setup.1-1","PercentComplete":0,"StartTime":"TIME_NOW","TargetSettingsURI":null}

5. Reboot the server to execute the 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

6. Poll the job status, confirm it shows completed job state.

curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_781399840295 --insecure
{"@odata.context":"/redfish/v1/$metadata#DellJob.DellJob","@odata.id":"/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_781399840295","@odata.type":"#DellJob.v1_0_1.DellJob","CompletionTime":"2023-03-06T16:13:16","Description":"Job Instance","EndTime":"TIME_NA","Id":"JID_781399840295","JobState":"Completed","JobType":"BIOSConfiguration","Message":"Job completed successfully.","MessageArgs":[],"MessageId":"PR19","Name":"ConfigBIOS:BIOS.Setup.1-1","PercentComplete":100,"StartTime":"TIME_NOW","TargetSettingsURI":null}

7. Get updated boot order, confirm virtual CD is set as first device.

[root@SCPexport ~]# curl -k -u root:calvin -X GET https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/BootSources --
insecure | python3.6 -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2894  100  2894    0     0   2271      0  0:00:01  0:00:01 --:--:--  2450
{
    "@Redfish.Settings": {
        "@odata.context": "/redfish/v1/$metadata#Settings.Settings",
        "@odata.type": "#Settings.v1_1_0.Settings",
        "SettingsObject": {
            "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources/Settings"
        },
        "SupportedApplyTimes": [
            "OnReset",
            "AtMaintenanceWindowStart",
            "InMaintenanceWindowOnReset"
        ]
    },
    "@odata.context": "/redfish/v1/$metadata#DellBootSources.DellBootSources",
    "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources",
    "@odata.type": "#DellBootSources.v1_0_0.DellBootSources",
    "AttributeRegistry": "DellBootSourcesRegistry.v1_0_0",
    "Attributes": {
        "BootSeq": [
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Optical.SATAEmbedded.E-1#6ef2870508c6cbc609685e118bc34df3",
                "Index": 0,
                "Name": "Optical.SATAEmbedded.E-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#HardDisk.List.1-1#c9203080df84781e2ca3d512883dee6f",
                "Index": 1,
                "Name": "HardDisk.List.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Floppy.iDRACVirtual.1-1#8fd02749adddb7fe2f0cfd786fd48e84",
                "Index": 2,
                "Name": "Floppy.iDRACVirtual.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#BootSeq#Optical.iDRACVirtual.1-1#5750dc922db69eeefcc3a67d73ab1828",
                "Index": 3,
                "Name": "Optical.iDRACVirtual.1-1"
            }
        ],
        "HddSeq": [
            {
                "Id": "BIOS.Setup.1-1#HddSeq#RAID.Integrated.1-1#7af2f9decdf2a27aaa8616db3ad18a60",
                "Index": 0,
                "Name": "RAID.Integrated.1-1"
            }
        ],
        "UefiBootSeq": [
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#UefiBootSeq#Optical.iDRACVirtual.1-1#375d3ecb49f87dd46ca6c60e34f6155d",
                "Index": 0,
                "Name": "Optical.iDRACVirtual.1-1"
            },
            {
                "Enabled": true,
                "Id": "BIOS.Setup.1-1#UefiBootSeq#Unknown.Unknown.2-1#0c8187f4a92a87cafc07b249375b7ea8",
                "Index": 1,
                "Name": "Unknown.Unknown.2-1"
            },

Thanks Tex