dell / iDRAC-Redfish-Scripting

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

Dell redfish api - Enable uefi pxe boot for all network cards #313

Open asizalt opened 2 days ago

asizalt commented 2 days ago

I have managed with redfish API to enable uefi boot instead of bios via

base_url = f"https://{ip_address}/redfish/v1/Systems/System.Embedded.1" urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

headers = {"Content-Type": "application/json"} payloads ={ "Boot": { "BootSourceOverrideTarget": "UefiTarget", "BootSourceOverrideMode": "UEFI" } } now from the bios I have "network settings" and only the first network card is enabled with "uefi pxe" I want to allow it for all my network cards via redfish API.

It seems I don't have such an option.

texroemer commented 5 hours ago

Hi @asizalt

Please see workflow example below to enable BIOS PXE devices 2, 3 and 4.

  1. First step to get current boot order and per BIOS default settings you should only see NIC PXE device 1 enabled.

root@localhost:~# curl -k -u root:calvin -X GET 'https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/BootOptions?$expand=*($levels=1)' --insecure -H "Content-Type: application/json" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1455 100 1455 0 0 2679 0 --:--:-- --:--:-- --:--:-- 2679 { "@odata.context": "/redfish/v1/$metadata#BootOptionCollection.BootOptionCollection", "@odata.type": "#BootOptionCollection.BootOptionCollection", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions", "Description": "Collection of BootOptions", "Members": [ { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0004", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0004", "Description": "Current settings of the UEFI Boot option", "DisplayName": "AHCI Controller in SL 6: Windows Boot Manager", "Id": "Boot0004", "Name": "Uefi Boot Option", "UefiDevicePath": "HD(1,GPT,D53816C7-E248-40B8-8371-1F611083CB9A,0x800,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi" }, { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0005", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0005", "Description": "Current settings of the UEFI Boot option", "DisplayName": "PXE Device 1: Integrated NIC 1 Port 1 Partition 1", "Id": "Boot0005", "Name": "Uefi Boot Option", "UefiDevicePath": "VenHw(3A191845-5F86-4E78-8FCE-C4CFF59F9DAA)", "RelatedItem": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/NetworkAdapters/NIC.Integrated.1/NetworkDeviceFunctions/NIC.Integrated.1-1-1" } ] } ], "Members@odata.count": 2, "Name": "Boot Options Collection" }

  1. To enable the other 3 network PXE devices in BIOS you will need to use PATCH operation. You're going to use attributes PxeDev2EnDis, PxeDev3EnDis and PxeDev4EnDis to enable the devices and attributes PxeDev2Interface, PxeDev3Interface and PxeDev4Interface to set the network device port. To get supported network port string values for interface attributes, run GET on URI "redfish/v1/Systems/System.Embedded.1/Bios/BiosRegistry" to dump the attribute registry and look for attributes PxeDev2Interface, PxeDev3Interface and PxeDev4Interface.

Example:

{ "AttributeName": "PxeDev2Interface", "CurrentValue": null, "DisplayName": "Interface", "DisplayOrder": 1100, "HelpText": "NIC interface used for this PXE device.", "Hidden": false, "Immutable": false, "MenuPath": "./NetworkSettingsRef/PxeDev2SettingsRef", "ReadOnly": true, "ResetRequired": true, "Type": "Enumeration", "Value": [ { "ValueDisplayName": "Embedded NIC 1 Port 1 Partition 1", "ValueName": "NIC.Embedded.1-1-1" }, { "ValueDisplayName": "Embedded NIC 2 Port 1 Partition 1", "ValueName": "NIC.Embedded.2-1-1" }, { "ValueDisplayName": "Integrated NIC 1 Port 1 Partition 1", "ValueName": "NIC.Integrated.1-1-1" }, { "ValueDisplayName": "Integrated NIC 1 Port 2 Partition 1", "ValueName": "NIC.Integrated.1-2-1" }, { "ValueDisplayName": "NIC in Slot 3 Port 1 Partition 1", "ValueName": "NIC.Slot.3-1-1" }, { "ValueDisplayName": "NIC in Slot 3 Port 2 Partition 1", "ValueName": "NIC.Slot.3-2-1" }, { "ValueDisplayName": "NIC in Slot 3 Port 3 Partition 1", "ValueName": "NIC.Slot.3-3-1" }, { "ValueDisplayName": "NIC in Slot 3 Port 4 Partition 1", "ValueName": "NIC.Slot.3-4-1" } ], "WarningText": null, "WriteOnly": false },

  1. For this workflow example i'll be setting PxeDev2Interface to NIC.Slot.3-1-1, PxeDev3Interface to NIC.Slot.3-2-1 and PxeDev4Interface to NIC.Slot.3-3-1.

root@localhost:~# 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" -d '{"Attributes":{"PxeDev2EnDis":"Enabled","PxeDev3EnDis":"Enabled", "PxeDev4EnDis":"Enabled", "PxeDev2Interface":"NIC.Slot.3-1-1", "PxeDev3Interface":"NIC.Slot.3-2-1", "PxeDev4Interface":"NIC.Slot.3-3-1"}, "@Redfish.SettingsApplyTime":{"ApplyTime":"OnReset"}}' -i HTTP/1.1 202 Accepted Date: Mon, 28 Oct 2024 12:16:40 GMT Server: Apache OData-Version: 4.0 Cache-Control: no-cache X-Frame-Options: DENY Strict-Transport-Security: max-age=31536000; includeSubDomains; preload Location: /redfish/v1/TaskService/Tasks/JID_301178060688 Content-Length: 0 Content-Type: application/json;odata.metadata=minimal;charset=utf-8

  1. Once you run PATCH headers location will return job URI, confirm you see scheduled state.

root@localhost:~# curl -k -u root:calvin -X GET 'https://192.168.0.120/redfish/v1/TaskService/Tasks/JID_301178060688' --insecure -H "Content-Type: application/json" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 907 100 907 0 0 2897 0 --:--:-- --:--:-- --:--:-- 2897 { "@odata.context": "/redfish/v1/$metadata#Task.Task", "@odata.id": "/redfish/v1/TaskService/Tasks/JID_301178060688", "@odata.type": "#Task.v1_7_4.Task", "Description": "Server Configuration and other Tasks running on iDRAC are listed here", "Id": "JID_301178060688", "Messages": [ { "Message": "Task successfully scheduled.", "MessageArgs": [], "MessageArgs@odata.count": 0, "MessageId": "IDRAC.2.9.JCP001" } ], "Messages@odata.count": 1, "Name": "Configure: BIOS.Setup.1-1", "Oem": { "Dell": { "@odata.type": "#DellJob.v1_5_0.DellJob", "CompletionTime": null, "Description": "Job Instance", "EndTime": "TIME_NA", "Id": "JID_301178060688", "JobState": "Scheduled", "JobType": "BIOSConfiguration", "Message": "Task successfully scheduled.", "MessageArgs": [], "MessageId": "IDRAC.2.9.JCP001", "Name": "Configure: BIOS.Setup.1-1", "PercentComplete": 0, "StartTime": "TIME_NOW", "TargetSettingsURI": null } }, "PercentComplete": 0, "TaskState": "Starting", "TaskStatus": "OK" }

  1. Next step is to reboot the server to run the job and apply BIOS attribute changes.

root@localhost:~# curl -k -u root:calvin -X POST 'https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset' --insecure -H "Content-Type: application/json" -d '{"ResetType":"ForceRestart"}' -i

HTTP/1.1 204 No Content Date: Mon, 28 Oct 2024 12:19:14 GMT Server: Apache OData-EntityId: /redfish/v1/Systems/System.Embedded.1 X-Frame-Options: DENY Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

  1. Server should have rebooted, you can now run GET request on the job URI to monitor the status until marked completed.

root@localhost:~# curl -k -u root:calvin -X GET 'https://192.168.0.120/redfish/v1/TaskService/Tasks/JID_301178060688' --insecure -H "Content-Type: application/json" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 878 100 878 0 0 738 0 0:00:01 0:00:01 --:--:-- 737 { "@odata.context": "/redfish/v1/$metadata#Task.Task", "@odata.id": "/redfish/v1/TaskService/Tasks/JID_301178060688", "@odata.type": "#Task.v1_7_4.Task", "Description": "Server Configuration and other Tasks running on iDRAC are listed here", "Id": "JID_301178060688", "Messages": [ { "Message": "Job in progress.", "MessageArgs": [], "MessageArgs@odata.count": 0, "MessageId": "IDRAC.2.9.PR20" } ], "Messages@odata.count": 1, "Name": "Configure: BIOS.Setup.1-1", "Oem": { "Dell": { "@odata.type": "#DellJob.v1_5_0.DellJob", "CompletionTime": null, "Description": "Job Instance", "EndTime": "TIME_NA", "Id": "JID_301178060688", "JobState": "Running", "JobType": "BIOSConfiguration", "Message": "Job in progress.", "MessageArgs": [], "MessageId": "IDRAC.2.9.PR20", "Name": "Configure: BIOS.Setup.1-1", "PercentComplete": 34, "StartTime": "TIME_NOW", "TargetSettingsURI": null } }, "PercentComplete": 34, "TaskState": "Running", "TaskStatus": "OK" } root@localhost:~# curl -k -u root:calvin -X GET 'https://192.168.0.120/redfish/v1/TaskService/Tasks/JID_301178060688' --insecure -H "Content-Type: application/json" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 961 100 961 0 0 3859 0 --:--:-- --:--:-- --:--:-- 3859 { "@odata.context": "/redfish/v1/$metadata#Task.Task", "@odata.id": "/redfish/v1/TaskService/Tasks/JID_301178060688", "@odata.type": "#Task.v1_7_4.Task", "Description": "Server Configuration and other Tasks running on iDRAC are listed here", "EndTime": "2024-10-28T07:25:33-05:00", "Id": "JID_301178060688", "Messages": [ { "Message": "Job completed successfully.", "MessageArgs": [], "MessageArgs@odata.count": 0, "MessageId": "IDRAC.2.9.PR19" } ], "Messages@odata.count": 1, "Name": "Configure: BIOS.Setup.1-1", "Oem": { "Dell": { "@odata.type": "#DellJob.v1_5_0.DellJob", "CompletionTime": "2024-10-28T07:25:33", "Description": "Job Instance", "EndTime": "TIME_NA", "Id": "JID_301178060688", "JobState": "Completed", "JobType": "BIOSConfiguration", "Message": "Job completed successfully.", "MessageArgs": [], "MessageId": "IDRAC.2.9.PR19", "Name": "Configure: BIOS.Setup.1-1", "PercentComplete": 100, "StartTime": "TIME_NOW", "TargetSettingsURI": null } }, "PercentComplete": 100, "TaskState": "Completed", "TaskStatus": "OK" }

  1. Last step is to get BIOS boot order and confirm you now see PXE devices 2, 3 and 4 which should also be assigned to the correct network ports.

root@localhost:~# curl -k -u root:calvin -X GET 'https://192.168.0.120/redfish/v1/Systems/System.Embedded.1/BootOptions?$expand=*($levels=1)' --insecure -H "Content-Type: application/json" | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 3261 100 3261 0 0 12738 0 --:--:-- --:--:-- --:--:-- 12738 { "@odata.context": "/redfish/v1/$metadata#BootOptionCollection.BootOptionCollection", "@odata.type": "#BootOptionCollection.BootOptionCollection", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions", "Description": "Collection of BootOptions", "Members": [ { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0004", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0004", "Description": "Current settings of the UEFI Boot option", "DisplayName": "AHCI Controller in SL 6: Windows Boot Manager", "Id": "Boot0004", "Name": "Uefi Boot Option", "UefiDevicePath": "HD(1,GPT,D53816C7-E248-40B8-8371-1F611083CB9A,0x800,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi" }, { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0005", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0005", "Description": "Current settings of the UEFI Boot option", "DisplayName": "PXE Device 1: Integrated NIC 1 Port 1 Partition 1", "Id": "Boot0005", "Name": "Uefi Boot Option", "UefiDevicePath": "VenHw(3A191845-5F86-4E78-8FCE-C4CFF59F9DAA)", "RelatedItem": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/NetworkAdapters/NIC.Integrated.1/NetworkDeviceFunctions/NIC.Integrated.1-1-1" } ] }, { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0000", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0000", "Description": "Current settings of the UEFI Boot option", "DisplayName": "PXE Device 2: NIC in Slot 3 Port 1 Partition 1", "Id": "Boot0000", "Name": "Uefi Boot Option", "UefiDevicePath": "VenHw(D227C733-F75F-4341-B749-4D1759EC8538)", "RelatedItem": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/NetworkAdapters/NIC.Slot.3/NetworkDeviceFunctions/NIC.Slot.3-1-1" } ] }, { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0003", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0003", "Description": "Current settings of the UEFI Boot option", "DisplayName": "PXE Device 3: NIC in Slot 3 Port 2 Partition 1", "Id": "Boot0003", "Name": "Uefi Boot Option", "UefiDevicePath": "VenHw(56E94A54-7C81-443A-BB9F-C0D240845F54)", "RelatedItem": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/NetworkAdapters/NIC.Slot.3/NetworkDeviceFunctions/NIC.Slot.3-2-1" } ] }, { "@odata.context": "/redfish/v1/$metadata#BootOption.BootOption", "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0006", "@odata.type": "#BootOption.v1_0_6.BootOption", "BootOptionEnabled": true, "BootOptionReference": "Boot0006", "Description": "Current settings of the UEFI Boot option", "DisplayName": "PXE Device 4: NIC in Slot 3 Port 3 Partition 1", "Id": "Boot0006", "Name": "Uefi Boot Option", "UefiDevicePath": "VenHw(D5A9B8FE-4303-4BDA-A6FC-1ACA23B5A2ED)", "RelatedItem": [ { "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/NetworkAdapters/NIC.Slot.3/NetworkDeviceFunctions/NIC.Slot.3-3-1" } ] } ], "Members@odata.count": 5, "Name": "Boot Options Collection" }

Thanks Tex