
Examples
Note
Successful creation, modification or deletion of a resource will usually result in a response code of 200 or 201. An unsuccessful attempt will likely result in a 400 error code with a more detailed error message within the body of the response, ‘@Message.ExtendedInfo’.
Note
Examples showcasing Redfish standard properties and Actions will work for any BMC implementing Redfish. Any HPE OEM extensions are labeled in the examples as such.
The Redfish and Legacy_Rest folders contain many examples for performing different iLO tasks using the Redfish API and Legacy RESTful API respectively.
Redfish Example Reference Table
Example |
Link |
Add an iLO Manager Account |
|
Revert the BIOs to default values |
|
Change the BIOs settings. |
|
Change the boot order for HPE iLO systems. |
|
Change the temporary boot order. |
|
Clear AHS data for HPE iLO systems. |
|
Clear IEL or IML Logs for HPE iLO systems. |
|
Gather the computer system details. |
|
Configure SNMP for HPE iLO systems. |
|
Enable NTP servers for HPE iLO systems. |
|
Enable secure boot. |
|
Expand data responses. |
|
Clear IEL or IML Logs for HPE iLO systems. |
|
Generate a certificate signing request for |
|
Gather ESKM data for HPE iLO systems. |
|
Gather the Logical Drives on an HPE iLO system. |
|
Gather the Smart Array encryption settings on |
|
Gather AHS data for HPE iLO systems. |
|
Obtain the base message registry. |
|
Obtain the Manager IP. |
|
Obtain the Manager NIC data. |
|
Obtain an iLO license key for HPE iLO systems. |
|
Obtain the power metrics average on HPE iLO |
|
Obtain iLO information. |
|
Obtain iLO utility information, such as iLO |
|
Obtain schema data on any BMC with schemas |
|
Import an SSL certificate for HPE iLO systems. |
|
Modify a user account. |
|
Mount virtual media for HPE iLO systems. |
|
Create Redfish client. |
|
Reboot a server. |
|
Remove a user account. |
|
Reset the ESKM event log for HPE iLO systems. |
|
Reset a Manager. |
|
Reset a sever. |
|
Manually manage sessions with Redfish |
|
Set the primary ESKM key server properties |
|
Set the ESKM username and password for HPE |
|
Set active Manager NIC. |
|
Set an ISCSI boot instance for HPE iLO |
|
Set the BIOS password for HPE iLO systems. |
|
Set the Manager ethernet interface static IP. |
|
Set the NTP servers for HPE iLO systems. |
|
Set the time zone for HPE iLO systems. |
|
Add a license key for HPE iLO systems. |
|
Set the server asset tag. |
|
Configure SNMP alert for HPE iLO systems. |
|
Set the UID light. |
|
Provide the firmware inventory on HPE iLO |
|
Test a connection to the ESKM system for HPE |
|
Update the firmware by using an HTTP URL. |
|
Upload the firmware to the iLO Repository for |
|
Upload a firmware component with a size less |
Legacy Rest Example Reference Table
Example |
Link |
Add an iLO user account. |
|
Revert the BIOs to default values. |
|
Change the BIOs settings. |
|
Change the boot order for HPE iLO systems. |
|
Change the temporary boot order. |
|
Clear the AHS data. |
|
Clear IEL or IML Logs for HPE iLO systems. |
|
Clear the IML. |
|
Gather the computer system details. |
|
Configure SNMP for HPE iLO systems. |
|
Dump the ESKM event log. |
|
Dump the iLO event log. |
|
Dump the Manager NIC data. |
|
Dump the IML. |
|
Enables secure boot. |
|
Clear IEL or IML Logs for HPE iLO systems. |
|
Generate a certificate signing request for |
|
Gather ESKM data for HPE iLO systems. |
|
Gather the encryption settings on HPE iLO systems. |
|
Obtain the logical drives. |
|
Gather AHS data for HPE iLO systems. |
|
Obtain the base message registry. |
|
Obtain the CSR. |
|
Obtain the Manager IP. |
|
Obtain the Manager NIC data. |
|
Obtain an iLO license key for HPE iLO systems. |
|
Obtain the power metrics average on HPE iLO |
|
Obtain the iLO information, such as iLO |
|
Obtain the schema data on any system with |
|
Import an SSL certificate for HPE iLO systems. |
|
Modify a user account. |
|
Mount virtual media for HPE iLO systems. |
|
Remove an iLO user account. |
|
Reset the ESKM event log for HPE iLO systems. |
|
Reset iLO. |
|
Reset a sever. |
|
Create a session. |
|
Set active Manager NIC. |
|
Set the DHCP boot instance for HPE iLO systems. |
|
Set the primary ESKM key server for HPE iLO |
|
Set the ESKM username and password for HPE iLO |
|
Set the NTP servers for HPE iLO systems. |
|
Set an ISCSI boot instance for HPE iLO systems. |
|
Set the BIOS password for HPE iLO systems. |
|
Set the BIOS service. |
|
Set the UEFI shell startup. |
|
Set the URL boot file. |
|
Set the time zone for HPE iLO systems. |
|
Add a license key for HPE iLO systems. |
|
Set the server asset tag. |
|
Set the UID light. |
|
Test a connection to the ESKM system for HPE |
|
Update the firmware by using an HTTP URL. |
Add iLO Manager Account
Add an iLO Manager Account based on permissions (iLO 4 and iLO 5) or role ID (iLO 5).
1def add_ilo_user_account(_redfishobj, new_loginname, new_username, new_password, role_id, \
2 privilege_dict):
3resource_instances = get_resource_directory(_redfishobj)
4
5if DISABLE_RESOURCE_DIR or not resource_instances:
6 #resource directory is not available so we will navigate through paths manually to obtain
7 #account info
8 account_service_uri = _redfishobj.root.obj['AccountService']['@odata.id']
9 account_service_response = _redfishobj.get(account_service_uri)
10 account_collection_uri = account_service_response.obj['Accounts']['@odata.id']
11 #Add via role id
12 body = {"RoleId": role_id}
13else:
14 #obtain all account instances from resource directory
15 for instance in resource_instances:
16 if '#ManagerAccountCollection.' in instance['@odata.type']:
17 account_collection_uri = instance['@odata.id']
18 body = {"Oem": {"Hpe": {"Privileges": {}}}}
19 #HPE server, so add via privileges
20 for priv in privilege_dict:
21 body["Oem"]["Hpe"]["Privileges"][priv] = privilege_dict[priv]
22 #Add login name
23 body["Oem"]["Hpe"]["LoginName"] = new_loginname
24
25#Fill in the rest of the payload
26body["UserName"] = new_username
27body["Password"] = new_password
28
29#We pass the URI and the dictionary as a POST command (part of the redfish object)
30resp = _redfishobj.post(account_collection_uri, body)
31
32#If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
33#error message to see what went wrong
34if resp.status == 400:
35 try:
36 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
37 except Exception:
38 sys.stderr.write("A response error occurred, unable to access iLO Extended Message "\
39 "Info...")
40elif not resp.status in [200, 201]:
41 sys.stderr.write("An http response of '%s' was returned.\n" % resp.status)
42else:
43 print("Success!\n")
44 print(json.dumps(resp.dict, indent=4, sort_keys=True))
BIOS Revert Default
Set all BIOS attributes to their respective factory default states.
1def bios_revert_default(_redfishobj):
2
3 bios_reset_action_uri = None
4 resource_instances = get_resource_directory(_redfishobj)
5
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 bios_uri = systems_members_response.obj['Bios']['@odata.id']
14 bios_response = _redfishobj.get(bios_uri)
15 bios_reset_action_uri = bios_response.obj['Actions']['#Bios.ResetBios']['target']
16 else:
17 #Use Resource directory to find the relevant URI
18 for instance in resource_instances:
19 if '#Bios.' in instance['@odata.type']:
20 bios_uri = instance['@odata.id']
21 bios_data = _redfishobj.get(bios_uri)
22 bios_reset_action_uri = bios_data.obj['Actions']['#Bios.ResetBios']['target']
23 break
24
25 body = {'Action': 'Bios.ResetBios', 'ResetType':'default'}
26 resp = _redfishobj.post(bios_reset_action_uri, body)
27
28 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
29 #error message to see what went wrong
30 if resp.status == 400:
31 try:
32 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
33 except Exception:
34 sys.stderr.write("A response error occurred, unable to access iLO Extended Message "\
35 "Info...")
36 elif resp.status != 200:
37 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
38 else:
39 print("Success!\n")
40 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Change BIOS Setting
Alter one ore more BIOS attributes.
1def change_bios_setting(_redfishobj, bios_property, property_value, bios_password):
2
3 bios_uri = None
4 bios_data = None
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 bios_uri = systems_members_response.obj['Bios']['@odata.id']
14 bios_data = _redfishobj.get(bios_uri)
15 else:
16 #Use Resource directory to find the relevant URI
17 for instance in resource_instances:
18 if '#Bios.' in instance['@odata.type']:
19 bios_uri = instance['@odata.id']
20 bios_data = _redfishobj.get(bios_uri)
21 break
22
23 if bios_data:
24 print("\n\nShowing bios attributes before changes:\n\n")
25 print(json.dumps(bios_data.dict, indent=4, sort_keys=True))
26
27 if bios_uri:
28 #Bios settings URI is needed
29 bios_settings_uri = bios_data.obj['@Redfish.Settings']['SettingsObject']['@odata.id']
30 body = {'Attributes': {bios_property: property_value}}
31 #update bios password
32 if bios_password:
33 _redfishobj.bios_password = bios_password
34 resp = _redfishobj.patch(bios_settings_uri, body)
35
36 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
37 #error message to see what went wrong
38 if resp.status == 400:
39 try:
40 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
41 sort_keys=True))
42 except Exception:
43 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
44 "Message Info...")
45 elif resp.status != 200:
46 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
47 else:
48 print("\nSuccess!\n")
49 print(json.dumps(resp.dict, indent=4, sort_keys=True))
50 #uncomment if you would like to see the full list of attributes
51 #print("\n\nShowing bios attributes after changes:\n\n")
52 #bios_data = _redfishobj.get(bios_uri)
53 #print(json.dumps(bios_data.dict, indent=4, sort_keys=True))
Change Temporary Boot Order
Alter the temporary boot order.
1def change_temporary_boot_order(_redfishobj, boottarget):
2
3 systems_members_uri = None
4 systems_members_response = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
9 systems_response = _redfishobj.get(systems_uri)
10 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
11 systems_members_response = _redfishobj.get(systems_members_uri)
12 else:
13 for instance in resource_instances:
14 if '#ComputerSystem.' in instance['@odata.type']:
15 systems_members_uri = instance['@odata.id']
16 systems_members_response = _redfishobj.get(systems_members_uri)
17
18 if systems_members_response:
19 print("\n\nShowing bios attributes before changes:\n\n")
20 print(json.dumps(systems_members_response.dict.get('Boot'), indent=4, sort_keys=True))
21 body = {'Boot': {'BootSourceOverrideTarget': boottarget}}
22 resp = _redfishobj.patch(systems_members_uri, body)
23
24 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
25 #error message to see what went wrong
26 if resp.status == 400:
27 try:
28 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
29 except Exception as excp:
30 sys.stderr.write("A response error occurred, unable to access iLO Extended Message "\
31 "Info...")
32 elif resp.status != 200:
33 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
34 else:
35 print("\nSuccess!\n")
36 print(json.dumps(resp.dict, indent=4, sort_keys=True))
37 if systems_members_response:
38 print("\n\nShowing boot override target:\n\n")
39 print(json.dumps(systems_members_response.dict.get('Boot'), indent=4, sort_keys=True))
Example of the Boot Object
The folowing JSON output can be obtained first by noting the systems_members_response on line 42 above.
else:
for instance in resource_instances:
if '#ComputerSystem.' in instance['@odata.type']:
systems_members_uri = instance['@odata.id']
systems_members_response = _redfishobj.get(systems_members_uri)
if systems_members_response:
print("\n\nShowing bios attributes before changes:\n\n")
print(json.dumps(systems_members_response.dict.get('Boot'), indent=4, sort_keys=True))
The user can preview the data prior:
1{
2 "BootOptions": {
3 "@odata.id": "/redfish/v1/Systems/1/BootOptions/"
4 },
5 "BootOrder": [
6 "Boot0011",
7 "Boot0019",
8 "Boot0009",
9 "Boot0012",
10 "Boot0010",
11 "Boot0014",
12 "Boot000C",
13 "Boot000E",
14 "Boot000F",
15 "Boot0017",
16 "Boot000D",
17 "Boot0013"
18 ],
19 "BootSourceOverrideEnabled": "Disabled",
20 "BootSourceOverrideMode": "UEFI",
21 "BootSourceOverrideTarget": "None",
22 "BootSourceOverrideTarget@Redfish.AllowableValues": [
23 "None",
24 "Cd",
25 "Hdd",
26 "Usb",
27 "SDCard",
28 "Utilities",
29 "Diags",
30 "BiosSetup",
31 "Pxe",
32 "UefiShell",
33 "UefiHttp",
34 "UefiTarget"
35 ],
36 "UefiTargetBootSourceOverride": "None",
37 "UefiTargetBootSourceOverride@Redfish.AllowableValues": [
38 "HD(1,GPT,0940C33C-EAF1-43CD-8C8F-4426672227FE,0x800,0x4E000)/\\EFI\\sles\\shim.efi",
39 "HD(1,GPT,22F62F69-47E7-4334-BCE6-A0B321810BA1,0x800,0x64000)/\\EFI\\redhat\\shimx64.efi",
40 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)/Uri()",
41 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)",
42 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()",
43 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)",
44 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x0)",
45 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x1)",
46 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x2)",
47 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x3)",
48 "PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x0)",
49 "PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x1)"
50 ]
51}
Change Boot Order
Alter the default boot order.
1def change_boot_order(_redfishobj, bios_password):
2
3 bios_boot_uri = None
4 bios_boot_response = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
11 systems_response = _redfishobj.get(systems_uri)
12 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
13 systems_members_response = _redfishobj.get(systems_members_uri)
14 bios_uri = systems_members_response.obj['Bios']['@odata.id']
15 bios_response = _redfishobj.get(bios_uri)
16 bios_boot_uri = bios_response.obj.Oem.Hpe.Links.Boot['@odata.id']
17 else:
18 #Use Resource directory to find the relevant URI
19 for instance in resource_instances:
20 if '#HpeServerBootSettings.' in instance['@odata.type']:
21 bios_boot_uri = instance['@odata.id']
22 break
23
24 if bios_boot_uri:
25 bios_boot_response = _redfishobj.get(bios_boot_uri)
26 #Bios boot settings URI is needed
27 bios_boot_settings_uri = bios_boot_response.obj['@Redfish.Settings']['SettingsObject']\
28 ['@odata.id']
29 #update bios password
30 if bios_password:
31 _redfishobj.bios_password = bios_password
32 sys.stdout.write("Rotating the first boot device to the end of the boot order.\n")
33 sys.stdout.write('Current Order:\n')
34 boot_order = bios_boot_response.obj['DefaultBootOrder']
35 for indx, boot_device in enumerate(boot_order):
36 sys.stdout.write('Pos ' + str(indx) + ' : ' + boot_device + '\n')
37 device = boot_order.pop(0)
38 sys.stdout.write("Rotating device: \'%s\' to the end of the boot order.\n" % device)
39 boot_order.append(device)
40
41 body = {'DefaultBootOrder': boot_order}
42 resp = _redfishobj.patch(bios_boot_settings_uri, body)
43
44 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
45 #error message to see what went wrong
46 if resp.status == 400:
47 try:
48 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
49 sort_keys=True))
50 except Exception as excp:
51 sys.stderr.write("A response error occurred, unable to access iLO Extended Message"\
52 " Info...")
53 elif resp.status != 200:
54 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
55 else:
56 print("Success! Your system may need to be restarted.\n")
57 print(json.dumps(resp.dict, indent=4, sort_keys=True))
58 else:
59 sys.stderr.write("Unable to find Boot Order URI.\n")
Clear AHS Data
Clear Active Health System log data.
1def clear_ahs_data(_redfishobj):
2
3 active_health_system_clear_log_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
8 managers_response = _redfishobj.get(managers_uri)
9 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
10 managers_members_response = _redfishobj.get(managers_members_uri)
11 active_health_system_uri = managers_members_response.obj.Oem.Hpe.Links\
12 ['ActiveHealthSystem']['@odata.id']
13 active_health_system_response = _redfishobj.get(active_health_system_uri)
14 active_health_system_clear_log_uri = active_health_system_response.obj['Actions']\
15 ['#HpeiLOActiveHealthSystem.ClearLog']['target']
16 else:
17 for instance in resource_instances:
18 if '#HpeiLOActiveHealthSystem.' in instance['@odata.type']:
19 active_health_system_uri = instance['@odata.id']
20 active_health_system_response = _redfishobj.get(active_health_system_uri)
21 active_health_system_clear_log_uri = active_health_system_response['Actions']\
22 ['#HpeiLOActiveHealthSystem.ClearLog']['target']
23 break
24
25 if active_health_system_clear_log_uri:
26 body = {"Action": "HpeiLOActiveHealthSystem.ClearLog"}
27 resp = _redfishobj.redfish_client.post(active_health_system_clear_log_uri, body)
28
29 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
30 #error message to see what went wrong
31 if resp.status == 400:
32 try:
33 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4,\
34 sort_keys=True))
35 except Exception:
36 sys.stderr.write("A response error occurred, unable to access iLO Extended " \
37 "Message Info...")
38 elif resp.status != 200:
39 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
40 else:
41 print("Success!\n")
42 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Clear IEL/IML Data
Clear iLO event log and management log data.
1def clear_ilo_event_log(_redfishobj, clear_IML_IEL):
2
3clear_log_services_uri = []
4
5resource_instances = get_resource_directory(_redfishobj)
6if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 log_services_uri = systems_members_response.obj['LogServices']['@odata.id']
14 log_services_response = _redfishobj.get(log_services_uri)
15 log_services_uris = log_services_response.obj['Members']
16 for log_services_uri in log_services_uris:
17 log_services_response = _redfishobj.get(log_services_uri['@odata.id'])
18 clear_log_services_uri.append(log_services_response.obj['Actions']\
19 ['#LogService.ClearLog']['target'])
20else:
21 for instance in resource_instances:
22 #Use Resource directory to find the relevant URI
23 if '#LogService.' in instance['@odata.type']:
24 log_service_uri = instance['@odata.id']
25 clear_log_services_uri.append(_redfishobj.get(log_service_uri).dict['Actions']\
26 ['#LogService.ClearLog']['target'])
27
28if clear_log_services_uri:
29 body = {"Action": "LogService.ClearLog"}
30 for path in clear_log_services_uri:
31 if ("IEL" in clear_IML_IEL and "IEL" in path) or ("IML" in clear_IML_IEL and \
32 "IML" in path):
33 if "IEL" in path:
34 sys.stdout.write("Clearing IEL log.\n")
35 else:
36 sys.stdout.write("Clearing IML log.\n")
37 resp = _redfishobj.post(path, body)
38 else:
39 continue
40 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended
41 #info error message to see what went wrong
42 if resp.status == 400:
43 try:
44 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
45 sort_keys=True))
46 except Exception as excp:
47 sys.stderr.write("A response error occurred, unable to access iLO "\
48 "Extended Message Info...\n")
49 elif resp.status != 200:
50 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
51 else:
52 print("Success!\n")
53 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Clear IEL/IML Data
Print computer system JSON data.
1def computer_details(_redfishobj):
2 systems_members_uri = None
3 systems_members_response = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 else:
14 for instance in resource_instances:
15 #Use Resource directory to find the relevant URI
16 if '#ComputerSystem.' in instance['@odata.type']:
17 systems_members_uri = instance['@odata.id']
18 systems_members_response = _redfishobj.get(systems_members_uri)
19
20 print("\n\nPrinting computer system details:\n\n")
21 print(json.dumps(systems_members_response.dict, indent=4, sort_keys=True))
Computer System Data
The folowing JSON output is obtained when accessing type ComputerSystem. Values may vary from system to system, and key entries may differ based on the schema version for #ComputerSystem.
The user can preview the data prior:
1{
2 "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem",
3 "@odata.etag": "W/\"7010F715\"",
4 "@odata.id": "/redfish/v1/Systems/1/",
5 "@odata.type": "#ComputerSystem.v1_10_0.ComputerSystem",
6 "Actions": {
7 "#ComputerSystem.Reset": {
8 "ResetType@Redfish.AllowableValues": [
9 "On",
10 "ForceOff",
11 "GracefulShutdown",
12 "ForceRestart",
13 "Nmi",
14 "PushPowerButton"
15 ],
16 "target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/"
17 }
18 },
19 "AssetTag": "",
20 "Bios": {
21 "@odata.id": "/redfish/v1/systems/1/bios/"
22 },
23 "BiosVersion": "U32 v2.22 (11/13/2019)",
24 "Boot": {
25 "BootOptions": {
26 "@odata.id": "/redfish/v1/Systems/1/BootOptions/"
27 },
28 "BootOrder": [
29 "Boot0011",
30 "Boot0019",
31 "Boot0009",
32 "Boot0012",
33 "Boot0010",
34 "Boot0014",
35 "Boot000C",
36 "Boot000E",
37 "Boot000F",
38 "Boot0017",
39 "Boot000D",
40 "Boot0013"
41 ],
42 "BootSourceOverrideEnabled": "Once",
43 "BootSourceOverrideMode": "UEFI",
44 "BootSourceOverrideTarget": "Hdd",
45 "BootSourceOverrideTarget@Redfish.AllowableValues": [
46 "None",
47 "Cd",
48 "Hdd",
49 "Usb",
50 "SDCard",
51 "Utilities",
52 "Diags",
53 "BiosSetup",
54 "Pxe",
55 "UefiShell",
56 "UefiHttp",
57 "UefiTarget"
58 ],
59 "UefiTargetBootSourceOverride": "None",
60 "UefiTargetBootSourceOverride@Redfish.AllowableValues": [
61 "HD(1,GPT,0940C33C-EAF1-43CD-8C8F-4426672227FE,0x800,0x4E000)/\\EFI\\sles\\shim.efi",
62 "HD(1,GPT,22F62F69-47E7-4334-BCE6-A0B321810BA1,0x800,0x64000)/\\EFI\\redhat\\shimx64.efi",
63 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)/Uri()",
64 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)",
65 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()",
66 "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)",
67 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x0)",
68 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x1)",
69 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x2)",
70 "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x3)",
71 "PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x0)",
72 "PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x1)"
73 ]
74 },
75 "EthernetInterfaces": {
76 "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/"
77 },
78 "HostName": "localhost.americas.hpqcorp.net",
79 "Id": "1",
80 "IndicatorLED": "Off",
81 "Links": {
82 "Chassis": [
83 {
84 "@odata.id": "/redfish/v1/Chassis/1/"
85 }
86 ],
87 "ManagedBy": [
88 {
89 "@odata.id": "/redfish/v1/Managers/1/"
90 }
91 ]
92 },
93 "LogServices": {
94 "@odata.id": "/redfish/v1/Systems/1/LogServices/"
95 },
96 "Manufacturer": "HPE",
97 "Memory": {
98 "@odata.id": "/redfish/v1/Systems/1/Memory/"
99 },
100 "MemoryDomains": {
101 "@odata.id": "/redfish/v1/Systems/1/MemoryDomains/"
102 },
103 "MemorySummary": {
104 "Status": {
105 "HealthRollup": "OK"
106 },
107 "TotalSystemMemoryGiB": 32,
108 "TotalSystemPersistentMemoryGiB": 0
109 },
110 "Model": "ProLiant DL360 Gen10",
111 "Name": "Computer System",
112 "NetworkInterfaces": {
113 "@odata.id": "/redfish/v1/Systems/1/NetworkInterfaces/"
114 },
115 "Oem": {
116 "Hpe": {
117 "@odata.context": "/redfish/v1/$metadata#HpeComputerSystemExt.HpeComputerSystemExt",
118 "@odata.type": "#HpeComputerSystemExt.v2_9_0.HpeComputerSystemExt",
119 "Actions": {
120 "#HpeComputerSystemExt.PowerButton": {
121 "PushType@Redfish.AllowableValues": [
122 "Press",
123 "PressAndHold"
124 ],
125 "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.PowerButton/"
126 },
127 "#HpeComputerSystemExt.SecureSystemErase": {
128 "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SecureSystemErase/"
129 },
130 "#HpeComputerSystemExt.SystemReset": {
131 "ResetType@Redfish.AllowableValues": [
132 "ColdBoot",
133 "AuxCycle"
134 ],
135 "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SystemReset/"
136 }
137 },
138 "AggregateHealthStatus": {
139 "AgentlessManagementService": "Unavailable",
140 "BiosOrHardwareHealth": {
141 "Status": {
142 "Health": "OK"
143 }
144 },
145 "FanRedundancy": "Redundant",
146 "Fans": {
147 "Status": {
148 "Health": "OK"
149 }
150 },
151 "Memory": {
152 "Status": {
153 "Health": "OK"
154 }
155 },
156 "Network": {
157 "Status": {
158 "Health": "OK"
159 }
160 },
161 "PowerSupplies": {
162 "PowerSuppliesMismatch": false,
163 "Status": {
164 "Health": "OK"
165 }
166 },
167 "Processors": {
168 "Status": {
169 "Health": "OK"
170 }
171 },
172 "Storage": {
173 "Status": {
174 "Health": "Warning"
175 }
176 },
177 "Temperatures": {
178 "Status": {
179 "Health": "OK"
180 }
181 }
182 },
183 "Bios": {
184 "Backup": {
185 "Date": "11/13/2019",
186 "Family": "U32",
187 "VersionString": "U32 v2.22 (11/13/2019)"
188 },
189 "Current": {
190 "Date": "11/13/2019",
191 "Family": "U32",
192 "VersionString": "U32 v2.22 (11/13/2019)"
193 },
194 "UefiClass": 2
195 },
196 "CriticalTempRemainOff": false,
197 "CurrentPowerOnTimeSeconds": null,
198 "DeviceDiscoveryComplete": {
199 "AMSDeviceDiscovery": "NoAMS",
200 "DeviceDiscovery": "vMainDeviceDiscoveryComplete",
201 "SmartArrayDiscovery": "Complete"
202 },
203 "ElapsedEraseTimeInMinutes": 0,
204 "EndOfPostDelaySeconds": null,
205 "EstimatedEraseTimeInMinutes": 0,
206 "IntelligentProvisioningAlwaysOn": true,
207 "IntelligentProvisioningIndex": 8,
208 "IntelligentProvisioningLocation": "System Board",
209 "IntelligentProvisioningVersion": "3.60.12",
210 "IsColdBooting": false,
211 "Links": {
212 "EthernetInterfaces": {
213 "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/"
214 },
215 "HpeIpProvider": {
216 "@odata.id": "/redfish/v1/systems/1/hpeip/"
217 },
218 "NetworkAdapters": {
219 "@odata.id": "/redfish/v1/Systems/1/BaseNetworkAdapters/"
220 },
221 "PCIDevices": {
222 "@odata.id": "/redfish/v1/Systems/1/PCIDevices/"
223 },
224 "PCISlots": {
225 "@odata.id": "/redfish/v1/Systems/1/PCISlots/"
226 },
227 "SUT": {
228 "@odata.id": "/redfish/v1/systems/1/hpsut/"
229 },
230 "SecureEraseReportService": {
231 "@odata.id": "/redfish/v1/Systems/1/SecureEraseReportService/"
232 },
233 "SmartStorage": {
234 "@odata.id": "/redfish/v1/Systems/1/SmartStorage/"
235 },
236 "USBDevices": {
237 "@odata.id": "/redfish/v1/Systems/1/USBDevices/"
238 },
239 "USBPorts": {
240 "@odata.id": "/redfish/v1/Systems/1/USBPorts/"
241 },
242 "WorkloadPerformanceAdvisor": {
243 "@odata.id": "/redfish/v1/Systems/1/WorkloadPerformanceAdvisor/"
244 }
245 },
246 "PCAPartNumber": "847479-001",
247 "PCASerialNumber": "PVZEK0ARHA014I",
248 "PostDiscoveryCompleteTimeStamp": null,
249 "PostDiscoveryMode": null,
250 "PostMode": null,
251 "PostState": "FinishedPost",
252 "PowerAllocationLimit": 500,
253 "PowerAutoOn": "Restore",
254 "PowerOnDelay": "Minimum",
255 "PowerOnMinutes": 80051,
256 "PowerRegulatorMode": "OSControl",
257 "PowerRegulatorModesSupported": [
258 "OSControl",
259 "Dynamic",
260 "Max",
261 "Min"
262 ],
263 "ProcessorJitterControl": {
264 "ConfiguredFrequencyLimitMHz": 0,
265 "Mode": "Disabled"
266 },
267 "SMBIOS": {
268 "extref": "/smbios"
269 },
270 "ServerFQDN": "",
271 "SmartStorageConfig": [
272 {
273 "@odata.id": "/redfish/v1/systems/1/smartstorageconfig/"
274 }
275 ],
276 "SystemROMAndiLOEraseComponentStatus": {
277 "BIOSSettingsEraseStatus": "Idle",
278 "iLOSettingsEraseStatus": "Idle"
279 },
280 "SystemROMAndiLOEraseStatus": "Idle",
281 "UserDataEraseComponentStatus": {},
282 "UserDataEraseStatus": "Idle",
283 "VirtualProfile": "Inactive"
284 }
285 },
286 "PowerState": "On",
287 "ProcessorSummary": {
288 "Count": 1,
289 "Model": "Intel(R) Xeon(R) Bronze 3106 CPU @ 1.70GHz",
290 "Status": {
291 "HealthRollup": "OK"
292 }
293 },
294 "Processors": {
295 "@odata.id": "/redfish/v1/Systems/1/Processors/"
296 },
297 "SKU": "DL3000GEN10",
298 "SecureBoot": {
299 "@odata.id": "/redfish/v1/Systems/1/SecureBoot/"
300 },
301 "SerialNumber": "TX86NP0121",
302 "Status": {
303 "Health": "Warning",
304 "HealthRollup": "Warning",
305 "State": "Enabled"
306 },
307 "Storage": {
308 "@odata.id": "/redfish/v1/Systems/1/Storage/"
309 },
310 "SystemType": "Physical",
311 "TrustedModules": [
312 {
313 "Oem": {
314 "Hpe": {
315 "@odata.context": "/redfish/v1/$metadata#HpeTrustedModuleExt.HpeTrustedModuleExt",
316 "@odata.type": "#HpeTrustedModuleExt.v2_0_0.HpeTrustedModuleExt"
317 }
318 },
319 "Status": {
320 "State": "Absent"
321 }
322 }
323 ],
324 "UUID": "30334C44-3030-5854-3836-4E5030313231"
325}
Configure SNMP
Configure iLO Simple Network Management Protocol.
1def configure_snmp(_redfishobj, read_communities, snmp_alerts):
2
3 snmp_service_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 snmp_service_uri = managers_members_response.obj.Oem.Hpe.Links['Snmp']['@odata.id']
14 else:
15 for instance in resource_instances:
16 #Use Resource directory to find the relevant URI
17 if '#HpeiLOSnmpService.' in instance['@odata.type']:
18 snmp_service_uri = instance['@odata.id']
19
20 if snmp_service_uri:
21 body = {"AlertsEnabled": snmp_alerts, "ReadCommunities": read_communities}
22 resp = _redfishobj.patch(snmp_service_uri, body)
23
24 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
25 #error message to see what went wrong
26 if resp.status == 400:
27 try:
28 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
29 sort_keys=True))
30 except Exception as excp:
31 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
32 "Message Info...")
33 elif resp.status != 200:
34 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
35 else:
36 print("Success!\n")
37 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Enable NTP
In order to configure iLO Network Time Protocol, certain settings must be in-place on the iLO Management NIC(s) including settings the value of the OEM/HPE object key-value pair UseNTPServers to True.
Note
An iLO Reset will be required in order for the change to be applied.
1def enable_ntp(_redfishobj, ntp_servers):
2
3 ethernet_data = {}
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
14 ['@odata.id']
15 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
16 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
17 obj['Members']
18 for _member in manager_ethernet_interfaces_members:
19 _tmp = _redfishobj.get(_member['@odata.id']).obj
20 ethernet_data[_member['@odata.id']] = _tmp
21 else:
22 #Use Resource directory to find the relevant URI
23 for instance in resource_instances:
24 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
25 instance['@odata.id']:
26 ethernet_uri = instance['@odata.id']
27 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
28 for _ethernet_interface in ethernet_interfaces:
29 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
30 get(_ethernet_interface['@odata.id']).dict
31 break
32
33 if ethernet_data:
34 print("\n\nShowing all available ethernet management interfaces before changes:\n\n")
35 print(json.dumps(ethernet_data, indent=4, sort_keys=True))
36
37 body = {"Oem": {"Hpe": {"DHCPv4": {"UseNTPServers": ntp_servers}, \
38 "DHCPv6": {"UseNTPServers": ntp_servers}}}}
39 for ethernet in ethernet_data:
40 resp = _redfishobj.patch(ethernet, body)
41 if resp.status == 400:
42 try:
43 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
44 sort_keys=True))
45 except Exception as excp:
46 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
47 "Message Info...")
48 elif resp.status != 200:
49 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
50 else:
51 print("Success!\n")
52 print(json.dumps(resp.dict, indent=4, sort_keys=True))
53 _data = _redfishobj.get(ethernet).dict
54 sys.stdout.write("\nShowing \'%s\' interface after changes:\n" % ethernet)
55 print(json.dumps(_data, indent=4, sort_keys=True))
Enable Secure Boot
Enable/Disable Secure Boot.
1def enable_secure_boot(_redfishobj, secure_boot_enable):
2
3 secure_boot_uri = None
4 secure_boot_data = None
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 secure_boot_uri = systems_members_response.obj['SecureBoot']['@odata.id']
14 secure_boot_data = _redfishobj.get(secure_boot_uri)
15 else:
16 #Use Resource directory to find the relevant URI
17 for instance in resource_instances:
18 if '#SecureBoot.' in instance['@odata.type']:
19 secure_boot_uri = instance['@odata.id']
20 secure_boot_data = _redfishobj.get(secure_boot_uri)
21
22 if secure_boot_data:
23 print("\n\nShowing Secure Boot properties before changes:\n\n")
24 print(json.dumps(secure_boot_data.dict, indent=4, sort_keys=True))
25
26 if secure_boot_uri:
27 body = {'SecureBootEnable': secure_boot_enable}
28 resp = _redfishobj.patch(secure_boot_uri, body)
29 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
30 #error message to see what went wrong
31 if resp.status == 400:
32 try:
33 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
34 sort_keys=True))
35 except Exception:
36 sys.stderr.write("A response error occurred, unable to access iLO Extended " \
37 "Message Info...")
38 elif resp.status != 200:
39 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
40 else:
41 print("\nSuccess!\n")
42 print(json.dumps(resp.dict, indent=4, sort_keys=True))
43 print("\n\nShowing Secure Boot properties after changes:\n\n")
44 secure_boot_data = _redfishobj.get(secure_boot_uri)
45 print(json.dumps(secure_boot_data.dict, indent=4, sort_keys=True))
Expand Data
JSON data is typically provided in a collapsed/compactted state. Use $expand as a query string on the desired URI.
1def expand_data(_redfishobj, expand_url="/redfish/v1/"):
2
3 response = _redfishobj.get(expand_url)
4 exp_response = _redfishobj.get(expand_url+'?$expand=.')
5 sys.stdout.write('Standard response:\n')
6 sys.stdout.write('\t'+str(response.dict)+'\n')
7 sys.stdout.write('Expanded response:\n')
8 sys.stdout.write('\t'+str(exp_response.dict)+'\n')
Response Example
Standard response:
{'@odata.context': '/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection', '@odata.etag': 'W/"AA6D42B0"', '@odata.id': '/redfish/v1/Systems/', '@odata.type': '#ComputerSystemCollection.ComputerSystemCollection', 'Description': 'Computer Systems view', 'Name': 'Computer Systems', 'Members': [{'@odata.id': '/redfish/v1/Systems/1/'}], 'Members@odata.count': 1}
Expanded response:
{'@odata.context': '/redfish/v1/$metadata#ComputerSystemCollection.ComputerSystemCollection', '@odata.etag': 'W/"5737F79D"', '@odata.id': '/redfish/v1/Systems/', '@odata.type': '#ComputerSystemCollection.ComputerSystemCollection', 'Description': 'Computer Systems view', 'Name': 'Computer Systems', 'Members': [{'@odata.context': '/redfish/v1/$metadata#ComputerSystem.ComputerSystem', '@odata.id': '/redfish/v1/Systems/1/', '@odata.type': '#ComputerSystem.v1_10_0.ComputerSystem', 'Id': '1', 'Actions': {'#ComputerSystem.Reset': {'ResetType@Redfish.AllowableValues': ['On', 'ForceOff', 'GracefulShutdown', 'ForceRestart', 'Nmi', 'PushPowerButton'], 'target': '/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/'}}, 'AssetTag': '', 'Bios': {'@odata.id': '/redfish/v1/systems/1/bios/'}, 'BiosVersion': 'U32 v2.22 (11/13/2019)', 'Boot': {'BootOptions': {'@odata.id': '/redfish/v1/Systems/1/BootOptions/'}, 'BootOrder': ['Boot0011', 'Boot0019', 'Boot0009', 'Boot0012', 'Boot0010', 'Boot0014', 'Boot000C', 'Boot000E', 'Boot000F', 'Boot0017', 'Boot000D', 'Boot0013'], 'BootSourceOverrideEnabled': 'Once', 'BootSourceOverrideMode': 'UEFI', 'BootSourceOverrideTarget': 'Hdd', 'BootSourceOverrideTarget@Redfish.AllowableValues': ['None', 'Cd', 'Hdd', 'Usb', 'SDCard', 'Utilities', 'Diags', 'BiosSetup', 'Pxe', 'UefiShell', 'UefiHttp', 'UefiTarget'], 'UefiTargetBootSourceOverride': 'None', 'UefiTargetBootSourceOverride@Redfish.AllowableValues': ['HD(1,GPT,0940C33C-EAF1-43CD-8C8F-4426672227FE,0x800,0x4E000)/\\EFI\\sles\\shim.efi', 'HD(1,GPT,22F62F69-47E7-4334-BCE6-A0B321810BA1,0x800,0x64000)/\\EFI\\redhat\\shimx64.efi', 'PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)/Uri()', 'PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv4(0.0.0.0)', 'PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()', 'PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(98F2B32CB4A8,0x0)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)', 'PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x0)', 'PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x1)', 'PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x2)', 'PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x3)', 'PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x0)', 'PciRoot(0x0)/Pci(0x14,0x0)/USB(0xD,0x0)/USB(0x1,0x1)']}, 'EthernetInterfaces': {'@odata.id': '/redfish/v1/Systems/1/EthernetInterfaces/'}, 'HostName': 'localhost.americas.hpqcorp.net', 'IndicatorLED': 'Off', 'Links': {'ManagedBy': [{'@odata.id': '/redfish/v1/Managers/1/'}], 'Chassis': [{'@odata.id': '/redfish/v1/Chassis/1/'}]}, 'LogServices': {'@odata.id': '/redfish/v1/Systems/1/LogServices/'}, 'Manufacturer': 'HPE', 'Memory': {'@odata.id': '/redfish/v1/Systems/1/Memory/'}, 'MemoryDomains': {'@odata.id': '/redfish/v1/Systems/1/MemoryDomains/'}, 'MemorySummary': {'Status': {'HealthRollup': 'OK'}, 'TotalSystemMemoryGiB': 32, 'TotalSystemPersistentMemoryGiB': 0}, 'Model': 'ProLiant DL360 Gen10', 'Name': 'Computer System', 'NetworkInterfaces': {'@odata.id': '/redfish/v1/Systems/1/NetworkInterfaces/'}, 'Oem': {'Hpe': {'@odata.context': '/redfish/v1/$metadata#HpeComputerSystemExt.HpeComputerSystemExt', '@odata.type': '#HpeComputerSystemExt.v2_9_0.HpeComputerSystemExt', 'Actions': {'#HpeComputerSystemExt.PowerButton': {'PushType@Redfish.AllowableValues': ['Press', 'PressAndHold'], 'target': '/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.PowerButton/'}, '#HpeComputerSystemExt.SecureSystemErase': {'target': '/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SecureSystemErase/'}, '#HpeComputerSystemExt.SystemReset': {'ResetType@Redfish.AllowableValues': ['ColdBoot', 'AuxCycle'], 'target': '/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SystemReset/'}}, 'AggregateHealthStatus': {'AgentlessManagementService': 'Unavailable', 'BiosOrHardwareHealth': {'Status': {'Health': 'OK'}}, 'FanRedundancy': 'Redundant', 'Fans': {'Status': {'Health': 'OK'}}, 'Memory': {'Status': {'Health': 'OK'}}, 'Network': {'Status': {'Health': 'OK'}}, 'PowerSupplies': {'PowerSuppliesMismatch': False, 'Status': {'Health': 'OK'}}, 'Processors': {'Status': {'Health': 'OK'}}, 'Storage': {'Status': {'Health': 'Warning'}}, 'Temperatures': {'Status': {'Health': 'OK'}}}, 'Bios': {'Backup': {'Date': '11/13/2019', 'Family': 'U32', 'VersionString': 'U32 v2.22 (11/13/2019)'}, 'Current': {'Date': '11/13/2019', 'Family': 'U32', 'VersionString': 'U32 v2.22 (11/13/2019)'}, 'UefiClass': 2}, 'CriticalTempRemainOff': False, 'CurrentPowerOnTimeSeconds': None, 'DeviceDiscoveryComplete': {'AMSDeviceDiscovery': 'NoAMS', 'DeviceDiscovery': 'vMainDeviceDiscoveryComplete', 'SmartArrayDiscovery': 'Complete'}, 'ElapsedEraseTimeInMinutes': 0, 'EndOfPostDelaySeconds': None, 'EstimatedEraseTimeInMinutes': 0, 'IntelligentProvisioningAlwaysOn': True, 'IntelligentProvisioningIndex': 8, 'IntelligentProvisioningLocation': 'System Board', 'IntelligentProvisioningVersion': '3.60.12', 'IsColdBooting': False, 'Links': {'HpeIpProvider': {'@odata.id': '/redfish/v1/systems/1/hpeip/'}, 'SUT': {'@odata.id': '/redfish/v1/systems/1/hpsut/'}, 'PCIDevices': {'@odata.id': '/redfish/v1/Systems/1/PCIDevices/'}, 'PCISlots': {'@odata.id': '/redfish/v1/Systems/1/PCISlots/'}, 'NetworkAdapters': {'@odata.id': '/redfish/v1/Systems/1/BaseNetworkAdapters/'}, 'SmartStorage': {'@odata.id': '/redfish/v1/Systems/1/SmartStorage/'}, 'USBPorts': {'@odata.id': '/redfish/v1/Systems/1/USBPorts/'}, 'USBDevices': {'@odata.id': '/redfish/v1/Systems/1/USBDevices/'}, 'EthernetInterfaces': {'@odata.id': '/redfish/v1/Systems/1/EthernetInterfaces/'}, 'WorkloadPerformanceAdvisor': {'@odata.id': '/redfish/v1/Systems/1/WorkloadPerformanceAdvisor/'}, 'SecureEraseReportService': {'@odata.id': '/redfish/v1/Systems/1/SecureEraseReportService/'}}, 'PCAPartNumber': '847479-001', 'PCASerialNumber': 'PVZEK0ARHA014I', 'PostDiscoveryCompleteTimeStamp': None, 'PostDiscoveryMode': None, 'PostMode': None, 'PostState': 'FinishedPost', 'PowerAllocationLimit': 500, 'PowerAutoOn': 'Restore', 'PowerOnDelay': 'Minimum', 'PowerOnMinutes': 80090, 'PowerRegulatorMode': 'OSControl', 'PowerRegulatorModesSupported': ['OSControl', 'Dynamic', 'Max', 'Min'], 'ProcessorJitterControl': {'ConfiguredFrequencyLimitMHz': 0, 'Mode': 'Disabled'}, 'SMBIOS': {'extref': '/smbios'}, 'ServerFQDN': '', 'SmartStorageConfig': [{'@odata.id': '/redfish/v1/systems/1/smartstorageconfig/'}], 'SystemROMAndiLOEraseComponentStatus': {'BIOSSettingsEraseStatus': 'Idle', 'iLOSettingsEraseStatus': 'Idle'}, 'SystemROMAndiLOEraseStatus': 'Idle', 'UserDataEraseComponentStatus': {}, 'UserDataEraseStatus': 'Idle', 'VirtualProfile': 'Inactive'}}, 'PowerState': 'On', 'ProcessorSummary': {'Count': 1, 'Model': 'Intel(R) Xeon(R) Bronze 3106 CPU @ 1.70GHz', 'Status': {'HealthRollup': 'OK'}}, 'Processors': {'@odata.id': '/redfish/v1/Systems/1/Processors/'}, 'SKU': 'DL3000GEN10', 'SecureBoot': {'@odata.id': '/redfish/v1/Systems/1/SecureBoot/'}, 'SerialNumber': 'TX86NP0121', 'Status': {'Health': 'Warning', 'HealthRollup': 'Warning', 'State': 'Enabled'}, 'Storage': {'@odata.id': '/redfish/v1/Systems/1/Storage/'}, 'SystemType': 'Physical', 'TrustedModules': [{'Oem': {'Hpe': {'@odata.context': '/redfish/v1/$metadata#HpeTrustedModuleExt.HpeTrustedModuleExt', '@odata.type': '#HpeTrustedModuleExt.v2_0_0.HpeTrustedModuleExt'}}, 'Status': {'State': 'Absent'}}], 'UUID': '30334C44-3030-5854-3836-4E5030313231'}], 'Members@odata.count': 1}
Find iLO MAC Address
Retrieve MAC Addresses for iLO Management Network Interfaces.
1def find_ilo_mac_address(_redfishobj):
2
3 ethernet_data = {}
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
14 ['@odata.id']
15 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
16 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
17 obj['Members']
18 for _member in manager_ethernet_interfaces_members:
19 _tmp = _redfishobj.get(_member['@odata.id']).obj
20 ethernet_data[_member['@odata.id']] = _tmp
21 else:
22 #Use Resource directory to find the relevant URI
23 for instance in resource_instances:
24 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
25 instance['@odata.id']:
26 ethernet_uri = instance['@odata.id']
27 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
28 for _ethernet_interface in ethernet_interfaces:
29 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
30 get(_ethernet_interface['@odata.id']).dict
31 for iface in ethernet_data:
32 sys.stdout.write("iLO Network Manager Interface: \'%s\'\n" % ethernet_data[iface]['Id'])
33 sys.stdout.write("\tiLO Mac Address: \'%s\'\n" % ethernet_data[iface].get('MACAddress'))
Response Example
Standard response:
iLO Network Manager Interface: '1'
iLO Mac Address: '98:F2:B3:21:7B:48'
iLO Network Manager Interface: '2'
iLO Mac Address: '98:F2:B3:21:7B:49'
iLO Network Manager Interface: '3'
iLO Mac Address: '0A:CA:FE:F0:0D:04'
Get Certificate Signing Request
Obtain an iLO Certificate Signing Request for use with Secure Socket Layer (SSL)/Transport Layer Security (TLS) Certificate.
Note
This process may take some time to complete on iLO (~5 minutes).
1def generate_csr(_redfishobj, csr_file, csr_properties):
2
3 csr_uri = None
4 generate_csr_uri = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links\
15 ['SecurityService']['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 csr_uri = security_service_response.obj.Links['HttpsCert']['@odata.id']
18 https_cert_response = _redfishobj.get(csr_uri)
19 generate_csr_uri = https_cert_response.obj['Actions']['#HpeHttpsCert.GenerateCSR']\
20 ['target']
21 else:
22 #Use Resource directory to find the relevant URI
23 for instance in resource_instances:
24 if '#HpeHttpsCert.' in instance['@odata.type']:
25 csr_uri = instance['@odata.id']
26 generate_csr_uri = _redfishobj.get(csr_uri).obj['Actions']\
27 ['#HpeHttpsCert.GenerateCSR']['target']
28 break
29
30 if generate_csr_uri:
31 body = dict()
32 body["Action"] = "HpeHttpsCert.GenerateCSR"
33 body["City"] = csr_properties["City"]
34 body["CommonName"] = csr_properties["CommonName"]
35 body["Country"] = csr_properties["Country"]
36 body["OrgName"] = csr_properties["OrgName"]
37 body["OrgUnit"] = csr_properties["OrgUnit"]
38 body["State"] = csr_properties["State"]
39 resp = _redfishobj.post(generate_csr_uri, body)
40 if resp.status in [200, 201]:
41 sys.stdout.write("Generating CSR, this may take a few minutes\n")
42 sys.stdout.write("Sleeping for 5 minutes...\n")
43 time.sleep(600)
44 csr_resp = _redfishobj.get(csr_uri).dict['CertificateSigningRequest']
45 with open(csr_file, 'wb') as csroutput:
46 csroutput.write(csr_resp)
47 sys.stdout.write("CSR Data saved to file: '%s'\n" % csr_file)
48 else:
49 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended
50 #info error message to see what went wrong
51 if resp.status not in [200, 201]:
52 try:
53 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
54 sort_keys=True))
55 except Exception as excp:
56 sys.stderr.write("A response error occurred, unable to access iLO "\
57 "Extended Message Info...\n")
Get AHS Data
Obtain Active Health System Data.
Note
AHS data is saved to a file, the contents of which are encoded. The use of an AHS Viewer to decode and parse is required. Please review Active Health System Viewer Documentation for further details: https://support.hpe.com/hpesc/public/docDisplay?docId=c05384164
1def get_ahs_data(_redfishobj, logfile):
2
3 active_health_system_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 active_health_system_uri = managers_members_response.obj.Oem.Hpe.Links\
14 ['ActiveHealthSystem']['@odata.id']
15 else:
16 #Use Resource directory to find the relevant URI
17 for instance in resource_instances:
18 if '#HpeiLOActiveHealthSystem.' in instance['@odata.type']:
19 active_health_system_uri = instance['@odata.id']
20
21 if active_health_system_uri:
22 active_health_system_response = _redfishobj.get(active_health_system_uri)
23 active_health_system_log_uri = active_health_system_response.obj.Links['AHSLocation']\
24 ['extref']
25 active_health_system_log_resp = _redfishobj.get(active_health_system_log_uri)
26 if active_health_system_log_resp.status == 400:
27 try:
28 print(json.dumps(active_health_system_log_resp.obj['error']\
29 ['@Message.ExtendedInfo'], indent=4, sort_keys=True))
30 except Exception:
31 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
32 "Message Info...")
33 elif active_health_system_log_resp.status != 200:
34 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
35 else:
36 print("Success!\n")
37 with open(logfile, 'wb') as ahsoutput:
38 ahsoutput.write(active_health_system_log_resp.ori)
39 ahsoutput.close()
40 sys.stdout.write("AHS Data saved successfully as: \'%s\'" % logfile)
Get Base Registries
Obtain Registry Providers. Registry providers allow for the transaction of data between properties and firmware.
1def get_base_registry(_redfishobj):
2
3registries_uri = _redfishobj.root.obj['Registries']['@odata.id']
4
5if registries_uri:
6 registries_members = _redfishobj.get(registries_uri).obj['Members']
7 for registry in registries_members:
8 sys.stdout.write("Registry URI at '%s'\n" % registry['@odata.id'])
Get ESKM
Obtain HPE Enterprise Secure Key Manager Encryption Data.
1def get_ESKM(_redfishobj):
2
3 security_service_eskm_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 security_service_uri = managers_members_response.obj.Oem.Hpe.Links\
14 ['SecurityService']['@odata.id']
15 security_service_response = _redfishobj.get(security_service_uri)
16 security_service_eskm_uri = security_service_response.obj.Links['ESKM']['@odata.id']
17 else:
18 for instance in resource_instances:
19 #Use Resource directory to find the relevant URI
20 if '#HpeESKM.' in instance['@odata.type']:
21 security_service_eskm_uri = instance['@odata.id']
22 break
23
24 if security_service_eskm_uri:
25 security_service_eskm_resp = _redfishobj.get(security_service_eskm_uri)
26 print(json.dumps(security_service_eskm_resp.dict, indent=4, sort_keys=True))
Response Example
1{
2 "@odata.context": "/redfish/v1/$metadata#HpeESKM.HpeESKM",
3 "@odata.etag": "W/\"87058EB1\"",
4 "@odata.id": "/redfish/v1/Managers/1/SecurityService/ESKM/",
5 "@odata.type": "#HpeESKM.v2_0_0.HpeESKM",
6 "Actions": {
7 "#HpeESKM.ClearESKMLog": {
8 "target": "/redfish/v1/Managers/1/SecurityService/ESKM/Actions/HpeESKM.ClearESKMLog/"
9 },
10 "#HpeESKM.TestESKMConnections": {
11 "target": "/redfish/v1/Managers/1/SecurityService/ESKM/Actions/HpeESKM.TestESKMConnections/"
12 }
13 },
14 "Id": "ESKM",
15 "KeyManagerConfig": {
16 "AccountGroup": "",
17 "AccountName": "ilo-98f2b3217b48",
18 "ESKMLocalCACertificateName": "",
19 "ImportedCertificateIssuer": "",
20 "ImportedCertificateSubject": ""
21 },
22 "KeyServerRedundancyReq": false,
23 "PrimaryKeyServerAddress": null,
24 "PrimaryKeyServerPort": null,
25 "SecondaryKeyServerAddress": null,
26 "SecondaryKeyServerPort": null
27}
Get iLO IP
Obtain iLO Network Management Interface(s) IP Address(s).
1def get_ilo_ip(_redfishobj):
2 ethernet_data = {}
3
4 resource_instances = get_resource_directory(_redfishobj)
5 if DISABLE_RESOURCE_DIR or not resource_instances:
6 #if we do not have a resource directory or want to force it's non use to find the
7 #relevant URI
8 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
9 managers_response = _redfishobj.get(managers_uri)
10 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
11 managers_members_response = _redfishobj.get(managers_members_uri)
12 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
13 ['@odata.id']
14 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
15 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
16 obj['Members']
17 for _member in manager_ethernet_interfaces_members:
18 _tmp = _redfishobj.get(_member['@odata.id']).obj
19 ethernet_data[_member['@odata.id']] = _tmp
20 else:
21 for instance in resource_instances:
22 #Use Resource directory to find the relevant URI
23 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
24 instance['@odata.id']:
25 ethernet_uri = instance['@odata.id']
26 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
27 for _ethernet_interface in ethernet_interfaces:
28 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
29 get(_ethernet_interface['@odata.id']).dict
30 break
31
32 if ethernet_data:
33 for ethernet_interface in ethernet_data:
34 sys.stdout.write("\n\nShowing iLO IPv4 Address Info on: %s\n\n" % ethernet_interface)
35 print(json.dumps(ethernet_data[ethernet_interface]['IPv4Addresses'],\
36 indent=4, sort_keys=True))
Response Example
Response data for each available network management interface is parsed for the Redfish IPv4 Data including: IP Address, Address Origin (Static/DHCP), Network Gateway, and Network Subnet Mask
Get iLO NIC
Obtain iLO Network Management Interface(s) Interface Enabled states. Modify lines 34-37 to display relevant desired data or all key-value pairs.
1def get_ilo_nic(_redfishobj, get_enabled):
2 ethernet_data = {}
3
4 resource_instances = get_resource_directory(_redfishobj)
5 if DISABLE_RESOURCE_DIR or not resource_instances:
6 #if we do not have a resource directory or want to force it's non use to find the
7 #relevant URI
8 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
9 managers_response = _redfishobj.get(managers_uri)
10 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
11 managers_members_response = _redfishobj.get(managers_members_uri)
12 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
13 ['@odata.id']
14 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
15 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
16 obj['Members']
17 for _member in manager_ethernet_interfaces_members:
18 _tmp = _redfishobj.get(_member['@odata.id']).obj
19 ethernet_data[_member['@odata.id']] = _tmp
20 else:
21 for instance in resource_instances:
22 #Use Resource directory to find the relevant URI
23 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
24 instance['@odata.id']:
25 ethernet_uri = instance['@odata.id']
26 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
27 for _ethernet_interface in ethernet_interfaces:
28 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
29 get(_ethernet_interface['@odata.id']).dict
30 break
31
32 if ethernet_data:
33 for ethernet_interface in ethernet_data:
34 sys.stdout.write("\n\nShowing iLO IPv4 Address Info on: %s\n\n" % ethernet_interface)
35 sys.stdout.write("\n\'Interface_Enabled\': \'%s\'\n" % json.dumps(ethernet_data\
36 [ethernet_interface][get_enabled], indent=4, sort_keys=True))
Response Example
Response data for each available network management interface is parsed for the Redfish IPv4 Data including: IP Address, Address Origin (Static/DHCP), Network Gateway, and Network Subnet Mask
Get License Key
Obtain iLO Licensing Key Information.
1def get_license_key(_redfishobj):
2 license_uri = None
3 license_data = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 hp_hpe = next(iter(managers_members_response.obj.Oem))
14 license_collection_uri = managers_members_response.obj.Oem[hp_hpe].Links['LicenseService']\
15 ['@odata.id']
16 license_collection_response = _redfishobj.get(license_collection_uri)
17 license_collection_members_uri = next(iter(license_collection_response.obj\
18 ['Members']))['@odata.id']
19 license_data = _redfishobj.get(license_collection_members_uri).dict
20 license_uri = _redfishobj.get(license_collection_members_uri).dict['@odata.id']
21 else:
22 for instance in resource_instances:
23 #Use Resource directory to find the relevant URI
24 if '#HpeiLOLicense.' in instance['@odata.type']:
25 license_uri = instance['@odata.id']
26 license_data = _redfishobj.get(license_uri).dict
27 break
28
29 if license_data:
30 try:
31 sys.stdout.write("\n\'License Info\': \'%s\'\n" % \
32 json.dumps(license_data['ConfirmationRequest']['EON'], indent=4, sort_keys=True))
33 except KeyError:
34 sys.stdout.write("\n\'License Info\': \'%s\'\n" % \
35 json.dumps(license_data['LicenseKey'], indent=4, sort_keys=True))
Response Example
Response Data will include the License Type, License Key (iLO 5) and State.
Get Logical Drives
List all logical drives associated with a smart array controller.
1def get_SmartArray_LogicalDrives(_redfishobj):
2
3 smartstorage_response = []
4 smartarraycontrollers = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
11 systems_response = _redfishobj.get(systems_uri)
12 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
13 systems_members_response = _redfishobj.get(systems_members_uri)
14 smart_storage_uri = systems_members_response.obj.Oem.Hpe.Links\
15 ['SmartStorage']['@odata.id']
16 smart_storage_arraycontrollers_uri = _redfishobj.get(smart_storage_uri).obj.Links\
17 ['ArrayControllers']['@odata.id']
18 smartstorage_response = _redfishobj.get(smart_storage_arraycontrollers_uri).obj['Members']
19 else:
20 for instance in resource_instances:
21 #Use Resource directory to find the relevant URI
22 if '#HpeSmartStorageArrayController.' in instance['@odata.type']:
23 smartstorage_uri = instance['@odata.id']
24 smartstorage_resp = _redfishobj.get(smartstorage_uri).obj
25 sys.stdout.write("Logical Drive URIs for Smart Storage Array Controller " \
26 "'%s\' : \n" % smartstorage_resp.get('Id'))
27 logicaldrives_uri = smartstorage_resp.Links['LogicalDrives']['@odata.id']
28 logicaldrives_resp = _redfishobj.get(logicaldrives_uri)
29 if not logicaldrives_resp.dict['Members']:
30 sys.stderr.write("\tLogical drives are not available for this controller.\n")
31 for drives in logicaldrives_resp.dict['Members']:
32 sys.stdout.write("\t An associated logical drive: %s\n" % drives)
33 drive_data = _redfishobj.get(drives['@odata.id']).dict
34 print(json.dumps(drive_data, indent=4, sort_keys=True))
Response Example
Logical drives listed
Get Power Metrics
Obtain Redfish power metrics.
1def get_powermetrics_average(_redfishobj):
2
3 power_metrics_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 chassis_uri = _redfishobj.root.obj['Chassis']['@odata.id']
10 chassis_response = _redfishobj.get(chassis_uri)
11 chassis_members_uri = next(iter(chassis_response.obj['Members']))['@odata.id']
12 chassis_members_response = _redfishobj.get(chassis_members_uri)
13 power_metrics_uri = chassis_members_response.obj.Oem.Hpe['Power']['@odata.id']
14 else:
15 for instance in resource_instances:
16 #Use Resource directory to find the relevant URI
17 if '#Power.' in instance['@odata.type']:
18 power_metrics_uri = instance['@odata.id']
19 break
20
21 if power_metrics_uri:
22 power_metrics_data = _redfishobj.get(power_metrics_uri).obj.Oem.Hpe
23 print("\n\nPower Data:\n\n")
24 print(json.dumps(power_metrics_data, indent=4, sort_keys=True))
Response Example
Power Metric Data
Get Resource Directory
Obtain iLO Resource Directory, quick access to all ‘@odata.type’ references and respective ‘@odata.id’.
Note
This resource is only available on iLO systems.
1def get_resource_directory(redfishobj):
2
3 try:
4 resource_uri = redfishobj.root.obj.Oem.Hpe.Links.ResourceDirectory['@odata.id']
5 except KeyError:
6 sys.stderr.write("Resource directory is only available on HPE servers.\n")
7 return None
8
9 response = redfishobj.get(resource_uri)
10 resources = []
11
12 if response.status == 200:
13 sys.stdout.write("\tFound resource directory at /redfish/v1/resourcedirectory" + "\n\n")
14 resources = response.dict["Instances"]
15 else:
16 sys.stderr.write("\tResource directory missing at /redfish/v1/resourcedirectory" + "\n")
17
18 return resources
Response Example
Snippet of Resource directory
Get Schemas
Obtain schema data.
1def get_schema(_redfishobj):
2 schema_members_uris = []
3 schema_members_expanded = {}
4
5 schema_uri = _redfishobj.root.obj['JsonSchemas']['@odata.id']
6 schema_response = _redfishobj.get(schema_uri)
7 schema_members_uris = schema_response.obj['Members']
8 for member in schema_members_uris:
9 data = _redfishobj.get(member['@odata.id']).dict
10 instance_id = data['Location'].index(next(iter(data['Location'])))
11 schema_uri = data['Location'][instance_id]['Uri']
12 schema = _redfishobj.get(schema_uri).dict
13 #I am just replacing the URI link for the sub-schema with the actual schema. You will
14 #see EVERYTHING
15 _tmp = {schema_uri + ' ->': schema}
16 data['Location'][instance_id]['Uri'] = _tmp
17 schema_members_expanded[member['@odata.id']] = data
18
19 print(json.dumps(schema_members_expanded, indent=4, sort_keys=True))
Response Example
Snippet of schema data for HpeiLOManagerNetworkService
Get Smart Array Encryption
Obtain Smart Array controller encryption property data.
1def get_SmartArray_EncryptionSettings(_redfishobj, desired_properties):
2
3 smartstorage_response = []
4 smartarraycontrollers = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
11 systems_response = _redfishobj.get(systems_uri)
12 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
13 systems_members_response = _redfishobj.get(systems_members_uri)
14 smart_storage_uri = systems_members_response.obj.Oem.Hpe.Links\
15 ['SmartStorage']['@odata.id']
16 smart_storage_arraycontrollers_uri = _redfishobj.get(smart_storage_uri).obj.Links\
17 ['ArrayControllers']['@odata.id']
18 smartstorage_response = _redfishobj.get(smart_storage_arraycontrollers_uri).obj['Members']
19 else:
20 for instance in resource_instances:
21 #Use Resource directory to find the relevant URI
22 if '#HpeSmartStorageArrayControllerCollection.' in instance['@odata.type']:
23 smartstorage_uri = instance['@odata.id']
24 smartstorage_response = _redfishobj.get(smartstorage_uri).obj['Members']
25 break
26
27 for controller in smartstorage_response:
28 smartarraycontrollers[controller['@odata.id']] = _redfishobj.get(controller['@odata.id']).\
29 obj
30 sys.stdout.write("Encryption Properties for Smart Storage Array Controller \'%s\' : \n" \
31 % smartarraycontrollers[controller['@odata.id']].get('Id'))
32 for data in smartarraycontrollers[controller['@odata.id']]:
33 if data in desired_properties:
34 sys.stdout.write("\t %s : %s\n" % (data, smartarraycontrollers[controller\
35 ['@odata.id']].get(data)))
Response Example
1{
2 "@odata.context": "/redfish/v1/$metadata#HpeESKM.HpeESKM",
3 "@odata.etag": "W/\"87058EB1\"",
4 "@odata.id": "/redfish/v1/Managers/1/SecurityService/ESKM/",
5 "@odata.type": "#HpeESKM.v2_0_0.HpeESKM",
6 "Actions": {
7 "#HpeESKM.ClearESKMLog": {
8 "target": "/redfish/v1/Managers/1/SecurityService/ESKM/Actions/HpeESKM.ClearESKMLog/"
9 },
10 "#HpeESKM.TestESKMConnections": {
11 "target": "/redfish/v1/Managers/1/SecurityService/ESKM/Actions/HpeESKM.TestESKMConnections/"
12 }
13 },
14 "Id": "ESKM",
15 "KeyManagerConfig": {
16 "AccountGroup": "",
17 "AccountName": "ilo-98f2b3217b48",
18 "ESKMLocalCACertificateName": "",
19 "ImportedCertificateIssuer": "",
20 "ImportedCertificateSubject": ""
21 },
22 "KeyServerRedundancyReq": false,
23 "PrimaryKeyServerAddress": null,
24 "PrimaryKeyServerPort": null,
25 "SecondaryKeyServerAddress": null,
26 "SecondaryKeyServerPort": null
27}
Import SSL Certificate
Import Secure Socket Layer Certificate.
1def import_ssl(_redfishobj, ssl_file_path):
2
3 https_cert_uri = None
4 body = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links['SecurityService']\
15 ['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 https_cert_uri = security_service_response.obj.Links['HttpsCert']['@odata.id']
18 else:
19 for instance in resource_instances:
20 #Use Resource directory to find the relevant URI
21 if '#HpeHttpsCert.' in instance['@odata.type']:
22 https_cert_uri = instance['@odata.id']
23 break
24
25 if https_cert_uri:
26 https_cert_import_uri = _redfishobj.get(https_cert_uri).obj['Actions']\
27 ['#HpeHttpsCert.ImportCertificate']['target']
28 body = dict()
29 body["Action"] = "HpeHttpsCert.ImportCertificate"
30 body["Certificate"] = ssl_cert
31 resp = _redfishobj.post(https_cert_import_uri, body)
32 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
33 #error message to see what went wrong
34 if resp.status == 400:
35 try:
36 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
37 sort_keys=True))
38 except Exception as excp:
39 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
40 "Message Info...")
41 elif resp.status != 200:
42 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
43 else:
44 print("Success!\n")
45 print(json.dumps(resp.dict, indent=4, sort_keys=True))
46 print("\nImporting SSL Certificate may take a few minutes...\n "\
47 "iLO will reset with new changes.\n")
Modify iLO Management User Account
Modify a management interface user account.
1def modify_ilo_user_account(_redfishobj, username_to_modify, new_loginname, new_username, \
2 new_password, role_id, privilege_dict):
3
4 account_collection_uri = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7
8 if DISABLE_RESOURCE_DIR or not resource_instances:
9 #resource directory is not available so we will navigate through paths manually to obtain
10 #account info
11 account_service_uri = _redfishobj.root.obj['AccountService']['@odata.id']
12 account_service_response = _redfishobj.get(account_service_uri)
13 account_collection_uri = account_service_response.obj['Accounts']['@odata.id']
14 #modify role id
15 if role_id:
16 body = {"RoleId": role_id}
17 else:
18 #obtain all account instances from resource directory
19 for instance in resource_instances:
20 if '#ManagerAccountCollection.' in instance['@odata.type']:
21 account_collection_uri = instance['@odata.id']
22 if privilege_dict:
23 #HPE server, so modify privileges
24 body = {"Oem": {"Hpe": {"Privileges": {}}}}
25 for priv in privilege_dict:
26 body["Oem"]["Hpe"]["Privileges"][priv] = privilege_dict[priv]
27 if new_loginname:
28 #modify login name
29 body["Oem"]["Hpe"]["LoginName"] = new_loginname
30
31 if new_username:
32 body["UserName"] = new_username
33 if new_password:
34 body["Password"] = new_password
35
36 #find the account to modify
37 account_uri_to_modify = None
38 account_uris = REDFISHOBJ.get(account_collection_uri)
39 for account_uri in account_uris.dict['Members']:
40 account = REDFISHOBJ.get(account_uri['@odata.id'])
41 if account.dict['UserName'] == username_to_modify:
42 account_uri_to_modify = account_uri['@odata.id']
43 break
44
45 if not account_uri_to_modify:
46 sys.stderr.write("Cannot find account to modify")
47 return
48
49 #modify the account
50 resp = REDFISHOBJ.patch(account_uri_to_modify, body)
51
52 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
53 #error message to see what went wrong
54 if resp.status == 400:
55 try:
56 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
57 except Exception as excp:
58 sys.stderr.write("A response error occurred, unable to access iLO Extended Message "\
59 "Info...")
60 elif resp.status != 200:
61 sys.stderr.write("An http response of '%s' was returned.\n" % resp.status)
62 else:
63 print("Success!\n")
64 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
An example Redfish response error message.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.AccountModified"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Modify Virtual Media
Modify a virtual media entry.
1def mount_virtual_media_iso(_redfishobj, iso_url, media_type, boot_on_next_server_reset):
2
3 virtual_media_uri = None
4 virtual_media_response = []
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 virtual_media_uri = managers_members_response.obj['VirtualMedia']['@odata.id']
15 else:
16 for instance in resource_instances:
17 #Use Resource directory to find the relevant URI
18 if '#VirtualMediaCollection.' in instance['@odata.type']:
19 virtual_media_uri = instance['@odata.id']
20
21 if virtual_media_uri:
22 virtual_media_response = _redfishobj.get(virtual_media_uri)
23 for virtual_media_slot in virtual_media_response.obj['Members']:
24 data = _redfishobj.get(virtual_media_slot['@odata.id'])
25 if media_type in data.dict['MediaTypes']:
26 virtual_media_mount_uri = data.obj['Actions']['#VirtualMedia.InsertMedia']['target']
27 post_body = {"Image": iso_url}
28
29 if iso_url:
30 resp = _redfishobj.post(virtual_media_mount_uri, post_body)
31 if boot_on_next_server_reset is not None:
32 patch_body = {}
33 patch_body["Oem"] = {"Hpe": {"BootOnNextServerReset": \
34 boot_on_next_server_reset}}
35 boot_resp = _redfishobj.patch(data.obj['@odata.id'], patch_body)
36 if not boot_resp.status == 200:
37 sys.stderr.write("Failure setting BootOnNextServerReset")
38 if resp.status == 400:
39 try:
40 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
41 sort_keys=True))
42 except Exception as excp:
43 sys.stderr.write("A response error occurred, unable to access iLO"
44 "Extended Message Info...")
45 elif resp.status != 200:
46 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
47 else:
48 print("Success!\n")
49 print(json.dumps(resp.dict, indent=4, sort_keys=True))
50 break
Response Example
An example Redfish response error message following a successful modification of a user account.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Reboot Server
Reboot a server.
1def reboot_server(_redfishobj):
2
3 systems_members_response = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 else:
14 for instance in resource_instances:
15 #Use Resource directory to find the relevant URI
16 if '#ComputerSystem.' in instance['@odata.type']:
17 systems_members_uri = instance['@odata.id']
18 systems_members_response = _redfishobj.get(systems_uri)
19
20 if systems_members_response:
21 system_reboot_uri = systems_members_response.obj['Actions']['#ComputerSystem.Reset']\
22 ['target']
23 body = dict()
24 body['Action'] = 'ComputerSystem.Reset'
25 body['ResetType'] = "ForceRestart"
26 resp = _redfishobj.post(system_reboot_uri, body)
27 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
28 #error message to see what went wrong
29 if resp.status == 400:
30 try:
31 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
32 sort_keys=True))
33 except Exception as excp:
34 sys.stderr.write("A response error occurred, unable to access iLO Extended "
35 "Message Info...")
36 elif resp.status != 200:
37 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
38 else:
39 print("Success!\n")
40 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
An example Redfish response error message following a successful application of virtual media.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Remove an iLO User Management Account
Delete an iLO User Management Account
1def reboot_server(_redfishobj):
2
3 systems_members_response = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 else:
14 for instance in resource_instances:
15 #Use Resource directory to find the relevant URI
16 if '#ComputerSystem.' in instance['@odata.type']:
17 systems_members_uri = instance['@odata.id']
18 systems_members_response = _redfishobj.get(systems_uri)
19
20 if systems_members_response:
21 system_reboot_uri = systems_members_response.obj['Actions']['#ComputerSystem.Reset']\
22 ['target']
23 body = dict()
24 body['Action'] = 'ComputerSystem.Reset'
25 body['ResetType'] = "ForceRestart"
26 resp = _redfishobj.post(system_reboot_uri, body)
27 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
28 #error message to see what went wrong
29 if resp.status == 400:
30 try:
31 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
32 sort_keys=True))
33 except Exception as excp:
34 sys.stderr.write("A response error occurred, unable to access iLO Extended "
35 "Message Info...")
36 elif resp.status != 200:
37 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
38 else:
39 print("Success!\n")
40 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
An example Redfish response error message following a successful application of virtual media.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Reset ESKM Event log
Reset Enterprise Secure Key Manager event log.
1def reset_ESKM_eventlog(_redfishobj):
2
3 body = dict()
4 security_service_eskm_uri = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links\
15 ['SecurityService']['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 security_service_eskm_uri = security_service_response.obj.Links['ESKM']['@odata.id']
18 else:
19 #Use Resource directory to find the relevant URI
20 for instance in resource_instances:
21 if '#HpeESKM.' in instance['@odata.type']:
22 security_service_eskm_uri = instance['@odata.id']
23 break
24
25 if security_service_eskm_uri:
26 security_service_eskm_uri = _redfishobj.get(security_service_uri).obj.Links\
27 ['ESKM']['@odata.id']
28 security_service_eskm_resp = _redfishobj.get(security_service_eskm_uri)
29 security_service_eskm_clearlog_uri = security_service_eskm_resp.obj['Actions']\
30 ['#HpeESKM.ClearESKMLog']['target']
31 body["Action"] = "HpeESKM.ClearESKMLog"
32 #We pass the URI and the dictionary as a POST command (part of the redfish object)
33 resp = _redfishobj.post(security_service_eskm_clearlog_uri, body)
34 #If iLO responds with something outside of 200 or 201 then lets check the iLO extended info
35 #error message to see what went wrong
36
37 if resp.status == 400:
38 try:
39 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
40 sort_keys=True))
41 except Exception as excp:
42 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
43 "Message Info...")
44 elif resp.status != 200:
45 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
46 else:
47 print("Success!\n")
48 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
An example Redfish response error message following a successful reset of ESKM log.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Reset iLO
Reset iLO BMC.
1def reset_ilo(_redfishobj):
2
3 managers_members_response = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 else:
14 #Use Resource directory to find the relevant URI
15 for instance in resource_instances:
16 if '#Manager.' in instance['@odata.type']:
17 managers_members_uri = instance['@odata.id']
18 managers_members_response = _redfishobj.get(managers_members_uri)
19
20 if managers_members_response:
21 reset_ilo_uri = managers_members_response.obj['Actions']['#Manager.Reset']['target']
22 body = {'Action': 'Manager.Reset'}
23 resp = _redfishobj.post(reset_ilo_uri, body)
24
25 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
26 #error message to see what went wrong
27 if resp.status == 400:
28 try:
29 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
30 except Exception as excp:
31 sys.stderr.write("A response error occurred, unable to access iLO Extended Message "\
32 "Info...")
33 elif resp.status != 200:
34 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
35 else:
36 print("Success!\n")
37 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
An example Redfish response error message following a successful reset of iLO.
1{
2"error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "iLO.2.14.ResetInProgress"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Sessions
Example of session management.
1def sessions(_redfishobj, login_account, login_password):
2
3 new_session = {"UserName": login_account, "Password": login_password}
4 response = _redfishobj.post('/redfish/v1/Sessions', new_session)
5
6 if response.status == 201:
7 print("Success!\n")
8 session_uri = response.getheader("location")
9 session_uri = urllib.parse.urlparse(session_uri)
10 sys.stdout.write("\tSession " + session_uri.path + " created.\n")
11 x_auth_token = response.getheader("x-auth-token")
12 sys.stdout.write("\tThis is the session X-Auth Token key " + x_auth_token + ".\n")
13 print(json.dumps(response.dict, indent=4, sort_keys=True))
14
15 # Delete the created session
16 sys.stdout.write("\tTerminating this session.\n")
17 sessresp = _redfishobj.delete(session_uri.path)
18 print(json.dumps(sessresp.dict, indent=4, sort_keys=True))
19 else:
20 sys.stderr.write("ERROR: failed to create a session.\n")
21 try:
22 print(json.dumps(sessresp.obj['error']['@Message.ExtendedInfo'], indent=4, \
23 sort_keys=True))
24 except Exception as excp:
25 sys.stderr.write("A response error occurred, unable to access iLO Extended"
26 " Message Info...")
Session Creation
Session token and URI. Session tokens can be cached and used for authentication for all subsequent calls as long as the session has not been terminated by the client or timed out by the server.
Note
This is only true in production mode. Some higher security modes may require additional authentication techniques to be performed.
Session X-Auth Token: 61ac3d750eeda276749cdd2138117a8f
Session URI: /redfish/v1/SessionService/Sessions/admin000000005f3d4cbfdbde43a8
An example Redfish response error message following a successful creation.
1{
2 "@odata.context": "/redfish/v1/$metadata#Session.Session",
3 "@odata.etag": "W/\"F1F51DF3\"",
4 "@odata.id": "/redfish/v1/SessionService/Sessions/admin000000005f3d4cbfdbde43a8",
5 "@odata.type": "#Session.v1_0_0.Session",
6 "Description": "Manager User Session",
7 "Id": "admin000000005f3d4cbfdbde43a8",
8 "Name": "User Session",
9 "Oem": {
10 "Hpe": {
11 "@odata.context": "/redfish/v1/$metadata#HpeiLOSession.HpeiLOSession",
12 "@odata.type": "#HpeiLOSession.v2_1_0.HpeiLOSession",
13 "AccessTime": "2020-08-19T16:01:03Z",
14 "LoginTime": "2020-08-19T16:01:03Z",
15 "MySession": false,
16 "UserExpires": "2020-08-19T16:31:03Z",
17 "UserIP": "16.214.34.25",
18 "UserTag": "REST",
19 "UserType": "Local"
20 }
21 },
22 "UserName": "admin"
23}
Session Creation
Terminating a session from the client side simply requires deletion of the session URI. Attempting to re-access the session results in the following response message.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.NoValidSession"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
iLO Management NIC Data
Example of ethernet management NIC enablement/disablement. On iLO systems: * Ethernet Management Interface 1 is typically the physical NIC port * Ethernet Management Interface 2 is typically the shared NIC interface. ** Shared physical System/iLO NIC. ** iLO USB port (requires the use of a USB to NIC adapter) * Ethernet Management Interface 3 is typically the virtual NIC interface. This is generally PnP with a supported Kernel/kernel virtual usb drivers.
1def set_active_ilo_nic(_redfishobj):
2
3 ethernet_data = {}
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
14 ['@odata.id']
15 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
16 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
17 obj['Members']
18 for _member in manager_ethernet_interfaces_members:
19 _tmp = _redfishobj.get(_member['@odata.id']).obj
20 ethernet_data[_member['@odata.id']] = _tmp
21 else:
22 #Use Resource directory to find the relevant URI
23 for instance in resource_instances:
24 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
25 instance['@odata.id']:
26 ethernet_uri = instance['@odata.id']
27 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
28 for _ethernet_interface in ethernet_interfaces:
29 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
30 get(_ethernet_interface['@odata.id']).dict
31 break
32
33 if ethernet_data:
34 print("\n\nShowing all available ethernet management interfaces before changes:\n\n")
35 for interface in ethernet_data:
36 sys.stdout.write("Ethernet Management Inteface \'%s\'\n" % ethernet_data\
37 [interface].get('Id'))
38 sys.stdout.write("\t\'Interface Enabled\': %s\n" % ethernet_data[interface].\
39 get('InterfaceEnabled'))
40
41 for ethernet in ethernet_data:
42 sys.stdout.write("Ethernet Interface: %s\n" % ethernet)
43 ans = input("Would you like to enable/disable this interface? (enable/disable)\n")
44 if "en" in ans:
45 body = {"InterfaceEnabled": True}
46 else:
47 body = {"InterfaceEnabled": False}
48 resp = _redfishobj.patch(ethernet, body)
49 if resp.status == 400:
50 try:
51 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
52 sort_keys=True))
53 except Exception as excp:
54 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
55 "Message Info...")
56 elif resp.status != 200:
57 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
58 else:
59 print("Success! You will need to reset iLO for this change to take effect.\n")
60 print(json.dumps(resp.dict, indent=4, sort_keys=True))
BIOS iSCSI
Configure iSCSI (Internet Small Computer Systems Interface) for ip based network attached storage.
1def set_bios_iscsi(_redfishobj, iscsi_properties):
2
3 iscsi_uri = None
4 iscsi_data = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
11 systems_response = _redfishobj.get(systems_uri)
12 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
13 systems_members_response = _redfishobj.get(systems_members_uri)
14 bios_uri = systems_members_response.obj['Bios']['@odata.id']
15 bios_response = _redfishobj.get(bios_uri)
16 iscsi_uri = bios_response.obj.Oem.Hpe.Links['iScsi']['@odata.id']
17 iscsi_data = _redfishobj.get(iscsi_uri)
18 else:
19 #Use Resource directory to find the relevant URI
20 for instance in resource_instances:
21 if '#HpeiSCSISoftwareInitiator.' in instance['@odata.type']:
22 iscsi_uri = instance['@odata.id']
23 iscsi_data = _redfishobj.get(iscsi_uri)
24
25 if iscsi_data:
26 for indx, inst in enumerate(iscsi_data.obj['iSCSISources']):
27 if iscsi_properties['iSCSIBootInstance'] == indx:
28 iscsi_data.dict['iSCSISources'][indx].update(iscsi_properties)
29 resp = _redfishobj.patch(iscsi_uri, {'iSCSISources' : iscsi_data.dict['iSCSISources']})
30 #If iLO responds with soemthing outside of 200 or 201 then lets check the
31 #iLO extended info error message to see what went wrong
32 if resp.status == 400:
33 try:
34 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], \
35 indent=4, sort_keys=True))
36 except Exception as excp:
37 print(json.dumps(resp.ori, indent=4, sort_keys=True))
38 sys.stderr.write("A response error occurred, unable to access iLO " \
39 "Extended Message Info...")
40 elif resp.status != 200:
41 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
42 else:
43 print("Success! A system reboot will be required to complete the change.\n")
44 print(json.dumps(resp.dict, indent=4, sort_keys=True))
45 break
Response Example
Successful modification of iSCSI data.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "iLO.2.14.SystemResetRequired"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Set BIOS Password
Set BIOS Password.
1def set_bios_password(_redfishobj, new_password, bios_password):
2
3 bios_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
10 systems_response = _redfishobj.get(systems_uri)
11 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
12 systems_members_response = _redfishobj.get(systems_members_uri)
13 bios_uri = systems_members_response.obj['Bios']['@odata.id']
14 else:
15 #Use Resource directory to find the relevant URI
16 for instance in resource_instances:
17 if '#Bios.' in instance['@odata.type']:
18 bios_uri = instance['@odata.id']
19 break
20
21 if bios_uri:
22 bios_data = _redfishobj.get(bios_uri)
23 bios_change_pass_uri = bios_data.obj['Actions']['#Bios.ChangePassword']['target']
24 body = dict()
25 body["PasswordName"] = "Administrator"
26 body["OldPassword"] = bios_password
27 body["NewPassword"] = new_password
28 resp = _redfishobj.post(bios_change_pass_uri, body)
29 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
30 #error message to see what went wrong
31 if resp.status == 400:
32 try:
33 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
34 sort_keys=True))
35 except Exception as excp:
36 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
37 "Message Info...")
38 elif resp.status != 200:
39 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
40 else:
41 print("Success!\n")
42 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example
Successful modification of BIOS password.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Set ESKM Primary Key
Set HPE Enterprise Secure Key Manager Key Manager Config.
Note
A valid ESKM key manager config is required and is tested upon patch submission. An error initializing ESKM may occur if the ESKM key manager or associated required properties are invalid. See ‘@Message.ExtendedInfo’ in the http response message.
{
"error": {
"code": "iLO.0.10.ExtendedInfo",
"message": "See @Message.ExtendedInfo for more information.",
"@Message.ExtendedInfo": [{
"MessageId": "iLO.2.14.ErrorIntializingESKM"
}]
}
}
1def set_ESKM_PrimaryKeyServer(_redfishobj, primary_key_server_address, primary_key_server_port):
2
3 eskm_uri = None
4 body = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links['SecurityService']\
15 ['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 eskm_uri = security_service_response.obj.Links['ESKM']['@odata.id']
18 else:
19 #Use Resource directory to find the relevant URI
20 for instance in resource_instances:
21 if '#HpeESKM.' in instance['@odata.type']:
22 eskm_uri = instance['@odata.id']
23 break
24
25 if eskm_uri:
26
27 body["PrimaryKeyServerAddress"] = primary_key_server_address
28 body["PrimaryKeyServerPort"] = int(primary_key_server_port)
29
30 resp = _redfishobj.post(eskm_uri, body)
31 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
32 #error message to see what went wrong
33 if resp.status == 400:
34 try:
35 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
36 sort_keys=True))
37 except Exception as excp:
38 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
39 "Message Info...")
40 elif resp.status != 200:
41 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
42 else:
43 print("Success!\n")
44 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Configure Ethernet Management NIC(s)
Configure Ethernet Management NIC(s) for DHCP/Static Network Addressing.
1def set_ilo_static_ipv4(_redfishobj, ipv4_dict, dns_dict):
2
3 ethernet_data = {}
4 body = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 manager_ethernet_interfaces = managers_members_response.obj['EthernetInterfaces']\
15 ['@odata.id']
16 manager_ethernet_interfaces_response = _redfishobj.get(manager_ethernet_interfaces)
17 manager_ethernet_interfaces_members = manager_ethernet_interfaces_response.\
18 obj['Members']
19 for _member in manager_ethernet_interfaces_members:
20 _tmp = _redfishobj.get(_member['@odata.id']).obj
21 ethernet_data[_member['@odata.id']] = _tmp
22 else:
23 #Use Resource directory to find the relevant URI
24 for instance in resource_instances:
25 if '#EthernetInterfaceCollection.' in instance['@odata.type'] and 'Managers' in \
26 instance['@odata.id']:
27 ethernet_uri = instance['@odata.id']
28 ethernet_interfaces = _redfishobj.get(ethernet_uri).obj['Members']
29 for _ethernet_interface in ethernet_interfaces:
30 ethernet_data[_ethernet_interface['@odata.id']] = _redfishobj.\
31 get(_ethernet_interface['@odata.id']).dict
32 break
33
34 if ethernet_data:
35 print("\n\nShowing all available ethernet management interfaces before changes:\n\n")
36 for interface in ethernet_data:
37 sys.stdout.write("Ethernet Management Inteface \'%s\'\n" % ethernet_data\
38 [interface].get('Id'))
39
40 sys.stdout.write("\'DHCPv4\':\n")
41 if ethernet_data[interface].get('DHCPv4'):
42 print(json.dumps(ethernet_data[interface].get('DHCPv4'), indent=4, sort_keys=True))
43 else:
44 print(json.dumps(ethernet_data[interface]['Oem']['Hpe'].get('DHCPv4'), indent=4, \
45 sort_keys=True))
46 sys.stdout.write("\'IPv4\':\n")
47 if ethernet_data[interface].get('IPv4StaticAddresses'):
48 print(json.dumps(ethernet_data[interface].get('IPv4Addresses'), indent=4, \
49 sort_keys=True))
50 sys.stdout.write("\'StaticNameServers\':\n")
51 if ethernet_data[interface].get('StaticNameServers'):
52 print(json.dumps(ethernet_data[interface].get('StaticNameServers'), indent=4, \
53 sort_keys=True))
54
55 for ethernet in ethernet_data:
56 sys.stdout.write("Ethernet Interface: %s\n" % ethernet)
57 ans = input("Would you like to modify this interface? (y/n)\n")
58 if "n" in ans:
59 continue
60 if 'DHCPv4' in ethernet_data[ethernet]:
61 if ethernet_data[ethernet]['DHCPv4'].get('UseDNSServers'):
62 resp = _redfishobj.patch(ethernet, {"DHCPv4": {"UseDNSServers": False}})
63 ilo_response(_redfishobj, resp)
64 if ethernet_data[ethernet]['DHCPv4'].get('UseGateway'):
65 resp = _redfishobj.pathc(ethernet, {"DHCPv4": {"UseGateway": False}})
66 ilo_response(_redfishobj, resp)
67 if 'IPv4StaticAddresses' in ethernet_data[ethernet]:
68 body.update({"IPv4Addresses": [ipv4_dict]})
69 if 'StaticNameServers' in ethernet_data[ethernet]:
70 body.update({"StaticNameServers" : [dns_dict.get('PrimaryDNS'), \
71 dns_dict.get('SecondaryDNS')]})
72 else:
73 body.update({"Oem": {"Hpe": {"IPv4": {"DNSServers": [dns_dict.get('PrimaryDNS'), \
74 dns_dict.get('SecondaryDNS')]}}}})
75 resp = _redfishobj.patch(ethernet, body)
76 ilo_response(_redfishobj, resp)
77 break
Set iLO NTP Server Settings
Configure NTP Server Settings.
Note
The physical or shared ethernet networking adapter must be configured with ‘StaticNTPServers’:’True’, if static network time protocol servers are to be used. DHCP must also be disabled. The following is an error message which will occur in the event DHCP is enabled while attempting to configure static NTP server entries.
{
"MessageArgs": [
"StaticNTPServers"
],
"MessageId": "iLO.2.14.SNTPConfigurationManagedByDHCPAndIsReadOnly"
}
1def set_ilo_ntp_servers(_redfishobj, ntp_server_list):
2
3 date_time_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 date_time_uri = managers_members_response.obj.Oem.Hpe.Links['DateTimeService']['@odata.id']
14 else:
15 #Use Resource directory to find the relevant URI
16 for instance in resource_instances:
17 if '#HpeiLODateTime.' in instance['@odata.type']:
18 date_time_uri = instance['@odata.id']
19
20 if date_time_uri:
21 data = _redfishobj.get(date_time_uri)
22 if data.dict.get('StaticNTPServers'):
23 resp = _redfishobj.patch(date_time_uri, {'StaticNTPServers': ntp_server_list})
24 else:
25 raise Exception("\'StaticNTPServers\' property is not available/modifyable.\n")
26 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
27 #error message to see what went wrong
28 if resp.status == 400:
29 try:
30 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
31 sort_keys=True))
32 except Exception as excp:
33 sys.stderr.write("A response error occurred, unable to access iLO Extended " \
34 "Message Info...")
35 elif resp.status != 200:
36 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
37 else:
38 print("Success!\n")
39 print(json.dumps(resp.dict, indent=4, sort_keys=True))
40 ntp_data = _redfishobj.get(date_time_uri).dict.get('StaticNTPServers')
41 print("Printing updated NTP Servers:\n")
42 print(json.dumps(ntp_data, indent=4, sort_keys=True))
Response Example
Successful modification of StaticNTPServers. (Only displaying response from iLODateTime)
1{ 2 "error": { 3 "@Message.ExtendedInfo": [ 4 { 5 "MessageId": "iLO.2.14.SystemResetRequired" 6 } 7 ], 8 "code": "iLO.0.10.ExtendedInfo", 9 "message": "See @Message.ExtendedInfo for more information." 10 } 11}
Set Timezone
Configure Network Time Protocol Time zone.
Note
DHCP must be disabled. The following is an error message which will occur in the event DHCP is enabled while attempting to modify the NTP timezone.
{
"MessageArgs": [
"StaticNTPServers"
],
"MessageId": "iLO.2.14.SNTPConfigurationManagedByDHCPAndIsReadOnly"
}
1def set_timezone(_redfishobj, timezone):
2
3 date_time_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 date_time_uri = managers_members_response.obj.Oem.Hpe.Links['DateTimeService']['@odata.id']
14 else:
15 #Use Resource directory to find the relevant URI
16 for instance in resource_instances:
17 if '#HpeiLODateTime.' in instance['@odata.type']:
18 date_time_uri = instance['@odata.id']
19
20 if date_time_uri:
21 data = _redfishobj.get(date_time_uri)
22 if data.dict.get('TimeZone'):
23 _data = {'TimeZone': {"Name": timezone}}
24 resp = _redfishobj.patch(date_time_uri, _data)
25 else:
26 raise Exception("\'TimeZone\' property is not available/modifyable.\n")
27 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
28 #error message to see what went wrong
29 if resp.status == 400:
30 try:
31 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
32 sort_keys=True))
33 print(json.dumps(data.obj.get('TimeZoneList'), indent=4, sort_keys=True))
34 sys.stderr.write("Check the TimeZone value...\n")
35 except Exception as excp:
36 sys.stderr.write("A response error occurred, unable to access iLO Extended " \
37 "Message Info...")
38 elif resp.status != 200:
39 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
40 else:
41 print("Success!\n")
42 print(json.dumps(resp.dict, indent=4, sort_keys=True))
43 ntp_data = _redfishobj.get(date_time_uri).dict.get('TimeZone')
44 print("Printing updated NTP Servers:\n")
45 print(json.dumps(ntp_data, indent=4, sort_keys=True))
Response Example
Successful modification of iLO timezone.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Configure iLO License Key
Configure iLO License Key.
1def set_license_key(_redfishobj, ilo_key):
2
3 ilo_lic_uri = None
4
5 resource_instances = get_resource_directory(_redfishobj)
6 if DISABLE_RESOURCE_DIR or not resource_instances:
7 #if we do not have a resource directory or want to force it's non use to find the
8 #relevant URI
9 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
10 managers_response = _redfishobj.get(managers_uri)
11 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
12 managers_members_response = _redfishobj.get(managers_members_uri)
13 ilo_lic_uri = managers_members_response.obj.Oem.Hpe.Links['LicenseService']['@odata.id']
14 else:
15 #Use Resource directory to find the relevant URI
16 for instance in resource_instances:
17 if '#HpeiLOLicense.' in instance['@odata.type']:
18 ilo_lic_uri = instance['@odata.id']
19
20 if ilo_lic_uri:
21 ilo_license_collection = _redfishobj.get(ilo_lic_uri)
22 ilo_license_member_uri = next(iter(ilo_license_collection.obj['Members']))['@odata.id']
23 try:
24 ilo_license_data = _redfishobj.get(ilo_license_member_uri).obj['ConfirmationRequest']\
25 ['EON']
26 except KeyError:
27 sys.stdout.write("This machine will not show the full License Key.\n")
28 ilo_license_data = _redfishobj.get(ilo_license_member_uri).obj['LicenseKey']
29
30 sys.stdout.write("Current iLO License Data:\n")
31 print(json.dumps(ilo_license_data, indent=4, sort_keys=True))
32 resp = _redfishobj.post(ilo_lic_uri, {'LicenseKey' : ilo_key})
33 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
34 #error message to see what went wrong
35 if resp.status == 400:
36 try:
37 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
38 sort_keys=True))
39 sys.stderr.write("Check the validity of your license key...\n")
40 except Exception as excp:
41 sys.stderr.write("A response error occurred, unable to access iLO " \
42 "Extended Message Info...")
43 elif resp.status != 200:
44 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
45 else:
46 print("Success!\n")
47 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example Valid
Successful addition/modification of iLO license key.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Response Example Invalid
An invalid iLO license key.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "iLO.2.14.InvalidLicenseKey"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Server Asset Tag
Configure Redfish asset tag.
1def set_server_asset_tag(_redfishobj, tag):
2
3 systems_members_uri = None
4 systems_members_response = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
11 systems_response = _redfishobj.get(systems_uri)
12 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
13 systems_members_response = _redfishobj.get(systems_members_uri)
14 else:
15 #Use Resource directory to find the relevant URI
16 for instance in resource_instances:
17 if '#ComputerSystem.' in instance['@odata.type']:
18 systems_members_uri = instance['@odata.id']
19 systems_members_response = _redfishobj.get(systems_members_uri)
20
21 if systems_members_response and systems_members_uri and tag:
22 print("Current Asset Tag: \'%s\'\n" % systems_members_response.dict.get("AssetTag"))
23
24 resp = _redfishobj.patch(systems_members_uri, {"AssetTag" : tag})
25 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
26 #error message to see what went wrong
27 if resp.status == 400:
28 try:
29 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
30 sort_keys=True))
31 except Exception as excp:
32 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
33 "Message Info...")
34 elif resp.status != 200:
35 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
36 else:
37 print("Success!\n")
38 print(json.dumps(resp.dict, indent=4, sort_keys=True))
39 time.sleep(10) #going to wait 10 seconds before obtaining the LED indicator state
40 sys.stdout.write("\nUpdated Asset Tag: \'%s\'\n" % _redfishobj.\
41 get(systems_members_uri).dict.get("AssetTag"))
Response Example
Successful addition/modification of Redfish asset tag.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Server UID Light
Configure System Unit Identification Light as either ‘Lit’ or ‘Off’.
1def set_uid_light(_redfishobj):
2
3 body = dict()
4 systems_members_uri = None
5 systems_members_response = None
6
7 resource_instances = get_resource_directory(_redfishobj)
8 if DISABLE_RESOURCE_DIR or not resource_instances:
9 #if we do not have a resource directory or want to force it's non use to find the
10 #relevant URI
11 systems_uri = _redfishobj.root.obj['Systems']['@odata.id']
12 systems_response = _redfishobj.get(systems_uri)
13 systems_members_uri = next(iter(systems_response.obj['Members']))['@odata.id']
14 systems_members_response = _redfishobj.get(systems_members_uri)
15 else:
16 #Use Resource directory to find the relevant URI
17 for instance in resource_instances:
18 if '#ComputerSystem.' in instance['@odata.type']:
19 systems_members_uri = instance['@odata.id']
20 systems_members_response = _redfishobj.get(systems_members_uri)
21
22 if systems_members_response and systems_members_uri:
23 print("Current Indicator LED Status: \'%s\'\n" % systems_members_response.dict.\
24 get("IndicatorLED"))
25 if "Off" in systems_members_response.dict.get("IndicatorLED"):
26 print("Will illuminate indicator LED.\n")
27 body["IndicatorLED"] = "Lit"
28 else:
29 print("Will extinguish indicator LED.\n")
30 body["IndicatorLED"] = "Off"
31
32 resp = _redfishobj.patch(systems_members_uri, body)
33 #If iLO responds with soemthing outside of 200 or 201 then lets check the iLO extended info
34 #error message to see what went wrong
35 if resp.status == 400:
36 try:
37 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
38 sort_keys=True))
39 except Exception as excp:
40 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
41 "Message Info...")
42 elif resp.status != 200:
43 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
44 else:
45 print("Success!\n")
46 print(json.dumps(resp.dict, indent=4, sort_keys=True))
47 time.sleep(10) #going to wait 10 seconds before obtaining the LED indicator state
48 sys.stdout.write("\nUpdated Indicator LED Status: \'%s\'\n" % _redfishobj.\
49 get(systems_members_uri).dict['IndicatorLED'])
Response Example
Successful addition/modification of UID light.
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "Base.1.4.Success"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Server Firmware Inventory
List all iLO onboard device firmware.
1def get_inventory_uri(_redfishobj, select):
2
3 update_service_uri = None
4 inventory_uri = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 update_service_uri = _redfishobj.root.obj['UpdateService']['@odata.id']
11 else:
12 #Use Resource directory to find the relevant URI
13 for instance in resource_instances:
14 if '#UpdateService.' in instance['@odata.type']:
15 update_service_uri = instance['@odata.id']
16
17 if update_service_uri:
18 update_service_resp = _redfishobj.get(update_service_uri)
19 if "software" in select.lower():
20 inventory_uri = update_service_resp.obj['SoftwareInventory']['@odata.id']
21 elif "firmware" in select.lower():
22 inventory_uri = update_service_resp.obj['FirmwareInventory']['@odata.id']
23 else:
24 raise Exception("Invalid selection provided: Please select 'software' or 'firmware' " \
25 "to obtain the relevant invetory data.")
26 sys.stdout.write("Printing data in invetory: %s\n" % inventory_uri)
27 get_inventory(_redfishobj, inventory_uri)
Response Example
Snippet of Firmware Inventory Response.
1[
2 {
3 "@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
4 "@odata.etag": "W/\"0539D502\"",
5 "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/15/",
6 "@odata.type": "#SoftwareInventory.v1_0_0.SoftwareInventory",
7 "Description": "102b0538159000e4",
8 "Id": "15",
9 "Name": "Embedded Video Controller",
10 "Oem": {
11 "Hpe": {
12 "@odata.context": "/redfish/v1/$metadata#HpeiLOSoftwareInventory.HpeiLOSoftwareInventory",
13 "@odata.type": "#HpeiLOSoftwareInventory.v2_0_0.HpeiLOSoftwareInventory",
14 "DeviceClass": null,
15 "DeviceContext": "Embedded Device",
16 "DeviceInstance": "PciRoot(0x0)/Pci(0x1C,0x4)/Pci(0x0,0x1)",
17 "Targets": [
18 "a6b1a447-382a-5a4f-102b-0538159000e4"
19 ]
20 }
21 },
22 "Version": "2.5"
23 },
24 {
25 "@odata.context": "/redfish/v1/$metadata#SoftwareInventory.SoftwareInventory",
26 "@odata.etag": "W/\"0539D502\"",
27 "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/13/",
28 "@odata.type": "#SoftwareInventory.v1_0_0.SoftwareInventory",
29 "Description": "14e41657103c22be",
30 "Id": "13",
31 "Name": "HPE Ethernet 1Gb 4-port 331i Adapter - NIC",
32 "Oem": {
33 "Hpe": {
34 "@odata.context": "/redfish/v1/$metadata#HpeiLOSoftwareInventory.HpeiLOSoftwareInventory",
35 "@odata.type": "#HpeiLOSoftwareInventory.v2_0_0.HpeiLOSoftwareInventory",
36 "DeviceClass": null,
37 "DeviceContext": "Embedded LOM",
38 "DeviceInstance": "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)",
39 "Targets": [
40 "a6b1a447-382a-5a4f-14e4-1657103c22be"
41 ]
42 }
43 },
44 "Version": "20.6.61"
45 }
46]
Test ESKM Connectivity
Test HPE Enterprise Secure Key Manager connectivity.
1def test_ESKM_connection(_redfishobj):
2
3 eskm_uri = None
4 body = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links['SecurityService']\
15 ['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 eskm_uri = security_service_response.obj.Links['ESKM']['@odata.id']
18
19 else:
20 #Use Resource directory to find the relevant URI
21 for instance in resource_instances:
22 if '#HpeESKM.' in instance['@odata.type']:
23 eskm_uri = instance['@odata.id']
24 break
25
26 if eskm_uri:
27 eskm_test_conn_uri = _redfishobj.get(eskm_uri).obj['Actions']\
28 ['#HpeESKM.TestESKMConnections']['target']
29 body["Action"] = "HpeESKM.TestESKMConnections"
30 resp = _redfishobj.post(eskm_test_conn_uri, body)
31 #If iLO responds with something outside of 200 or 201 then lets check the iLO extended info
32 #error message to see what went wrong
33 if resp.status == 400:
34 try:
35 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
36 sort_keys=True))
37 except Exception as excp:
38 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
39 "Message Info...")
40 elif resp.status != 200:
41 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
42 else:
43 print("Success!\n")
44 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example Not Configured
Response of a failed test ESKM connection action. (ESKM not properly configured)
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "iLO.2.14.ESKMServersNotConfigured"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Test ESKM Connectivity
Test HPE Enterprise Secure Key Manager connectivity.
1def test_ESKM_connection(_redfishobj):
2
3 eskm_uri = None
4 body = dict()
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 managers_uri = _redfishobj.root.obj['Managers']['@odata.id']
11 managers_response = _redfishobj.get(managers_uri)
12 managers_members_uri = next(iter(managers_response.obj['Members']))['@odata.id']
13 managers_members_response = _redfishobj.get(managers_members_uri)
14 security_service_uri = managers_members_response.obj.Oem.Hpe.Links['SecurityService']\
15 ['@odata.id']
16 security_service_response = _redfishobj.get(security_service_uri)
17 eskm_uri = security_service_response.obj.Links['ESKM']['@odata.id']
18
19 else:
20 #Use Resource directory to find the relevant URI
21 for instance in resource_instances:
22 if '#HpeESKM.' in instance['@odata.type']:
23 eskm_uri = instance['@odata.id']
24 break
25
26 if eskm_uri:
27 eskm_test_conn_uri = _redfishobj.get(eskm_uri).obj['Actions']\
28 ['#HpeESKM.TestESKMConnections']['target']
29 body["Action"] = "HpeESKM.TestESKMConnections"
30 resp = _redfishobj.post(eskm_test_conn_uri, body)
31 #If iLO responds with something outside of 200 or 201 then lets check the iLO extended info
32 #error message to see what went wrong
33 if resp.status == 400:
34 try:
35 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, \
36 sort_keys=True))
37 except Exception as excp:
38 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
39 "Message Info...")
40 elif resp.status != 200:
41 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
42 else:
43 print("Success!\n")
44 print(json.dumps(resp.dict, indent=4, sort_keys=True))
Response Example Not Configured
Response of a failed test ESKM connection action. (ESKM not properly configured)
1{
2 "error": {
3 "@Message.ExtendedInfo": [
4 {
5 "MessageId": "iLO.2.14.ESKMServersNotConfigured"
6 }
7 ],
8 "code": "iLO.0.10.ExtendedInfo",
9 "message": "See @Message.ExtendedInfo for more information."
10 }
11}
Update iLO Firmware
Process for a client to invoke a simple update of iLO firmware. Firmware is intended to be hosted and gathered by iLO by pointing to a URL for iLO to consume. A valid URL will result in an http 202 response code; however, this only indicates iLO will separately handle both downloading and processing the firmware update. The client will need to separately poll for status information regarding the update progress.
1def update_ilo_firmware(_redfishobj, fw_url, tpm_flag):
2
3 body = dict()
4 update_service_uri = None
5
6 resource_instances = get_resource_directory(_redfishobj)
7 if DISABLE_RESOURCE_DIR or not resource_instances:
8 #if we do not have a resource directory or want to force it's non use to find the
9 #relevant URI
10 update_service_uri = _redfishobj.root.obj['UpdateService']['@odata.id']
11 else:
12 #Use Resource directory to find the relevant URI
13 for instance in resource_instances:
14 if '#UpdateService.' in instance['@odata.type']:
15 update_service_uri = instance['@odata.id']
16 break
17
18 if update_service_uri and fw_url:
19 update_uri = _redfishobj.get(update_service_uri).obj['Actions']\
20 ['#UpdateService.SimpleUpdate']['target']
21 body["ImageURI"] = fw_url
22 if tpm_flag:
23 body["TPMOverrideFlag"] = tpm_flag
24 resp = _redfishobj.post(update_uri, body)
25 if resp.status == 400:
26 try:
27 print(json.dumps(resp.obj['error']\
28 ['@Message.ExtendedInfo'], indent=4, sort_keys=True))
29 except Exception as excp:
30 sys.stderr.write("A response error occurred, unable to access iLO Extended "\
31 "Message Info...")
32 elif resp.status != 200:
33 sys.stderr.write("An http response of \'%s\' was returned.\n" % resp.status)
34 else:
35 print("Success!\n")
36 print(json.dumps(resp.obj['error']['@Message.ExtendedInfo'], indent=4, sort_keys=True))
Upload firmware to iLO Repository
Upload firmware to iLO’s Absaroka flash based repository. Firmware can be stored and catalogued, to be used at a later date or in the need to recover the platform from a failure condition. An http response code of 200 will be supplied upon completion of a successful upload; no other extended message information is provided.
1def upload_firmware(_redfishobj, firmware_loc, update_repo=True, update_target=False):
2 resource_instances = get_resource_directory(_redfishobj)
3
4 if DISABLE_RESOURCE_DIR or not resource_instances:
5 #resource directory is not available so we will navigate through paths manually
6 update_service_uri = _redfishobj.root.obj['UpdateService']['@odata.id']
7 else:
8 #obtain all account instances from resource directory
9 for instance in resource_instances:
10 if '#UpdateService.' in instance['@odata.type']:
11 update_service_uri = instance['@odata.id']
12
13 update_service_response = _redfishobj.get(update_service_uri)
14
15 path = update_service_response.obj.HttpPushUri
16
17 body = []
18 json_data = {'UpdateRepository': update_repo, 'UpdateTarget': update_target, 'ETag': 'atag', 'Section': 0}
19 session_key = _redfishobj.session_key
20
21 filename = os.path.basename(firmware_loc)
22 with open(firmware_loc, 'rb') as fle:
23 output = fle.read()
24
25 session_tuple = ('sessionKey', session_key)
26 parameters_tuple = ('parameters', json.dumps(json_data))
27 file_tuple = ('file', (filename, output, 'application/octet-stream'))
28
29 #Build the payload from each multipart-form data tuple
30 body.append(session_tuple)
31 body.append(parameters_tuple)
32 body.append(file_tuple)
33
34 #Create our header dictionary
35 header = {'Cookie': 'sessionKey=' + session_key}
36
37 #We pass the whole list payload to post
38 resp = _redfishobj.post(path, body, headers=header)
39
40 if resp.status == 400:
41 sys.stderr.write("Failed to upload firmware...")
42 elif not resp.status in [200, 201]:
43 sys.stderr.write("An http response of '%s' was returned.\n" % resp.status)
44 else:
45 print("Upload complete!\n")