|
19 | 19 | def ex48_set_bios_password(redfishobj, new_password, bios_password=None): |
20 | 20 | sys.stdout.write("\nEXAMPLE 48: Set Bios Password\n") |
21 | 21 | instances = redfishobj.search_for_type("Bios.") |
| 22 | + |
22 | 23 | if not len(instances) and redfishobj.typepath.defs.isgen9: |
23 | 24 | sys.stderr.write("\nNOTE: This example requires the Redfish schema "\ |
24 | | - "version TBD in the managed iLO. It will fail against iLOs"\ |
25 | | - " with the 2.50 firmware or earlier. \n") |
26 | | - |
27 | | - for instance in instances: |
28 | | - body = {"AdminPassword": new_password, \ |
29 | | - "OldAdminPassword": bios_password} |
30 | | - response = redfishobj.redfish_patch(instance["@odata.id"], body, \ |
31 | | - optionalpassword=bios_password) |
32 | | - redfishobj.error_handler(response) |
| 25 | + "version TBD in the managed iLO. It will fail against iLO's"\ |
| 26 | + " with the 2.50 firmware or earlier. \n") |
| 27 | + else: |
| 28 | + for instance in instances: |
| 29 | + response = redfishobj.redfish_get(instance["@odata.id"]) |
| 30 | + body = dict() |
| 31 | + try: |
| 32 | + body["PasswordName"] = "Administrator" |
| 33 | + body["OldPassword"] = bios_password |
| 34 | + body["NewPassword"] = new_password |
| 35 | + response = redfishobj.redfish_post(response.dict["Actions"]\ |
| 36 | + ["#Bios.ChangePassword"]\ |
| 37 | + ["target"], body) |
| 38 | + except KeyError: |
| 39 | + pass |
| 40 | + |
| 41 | + redfishobj.error_handler(response) |
33 | 42 |
|
34 | 43 | if __name__ == "__main__": |
35 | 44 | # When running on the server locally use the following commented values |
|
0 commit comments