White Papers
26 Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers
…
#
# redfish_set_One_bios_attribute.py
# Set a single BIOS attributes to a new value
# Synopsis:
# redfish_set_one_bios_attribute.py <iDRAC IP> <user> <password>
# <Attribute name> <New value>
#
import requests, json, sys, re, time
from datetime import datetime
try:
idrac_ip = sys.argv[1]
idrac_username = sys.argv[2]
idrac_password = sys.argv[3]
attribute_name = sys.argv[4]
pending_value = sys.argv[5]
except:
print "- FAIL: You must pass in script name along with iDRAC IP / iDRAC
username / iDRAC password / attribute name / attribute value. Example:
\"script_name.py 192.168.0.120 root calvin MemTest Enabled\""
sys.exit()
### Function to get BIOS attribute current value
def get_attribute_current_value():
global current_value
response =
requests.get('https://%s/redfish/v1/Systems/System.Embedded.1/Bios' %
idrac_ip,verify=False,auth=(idrac_username, idrac_password))
data = response.json()
current_value = data[u'Attributes'][attribute_name]
if current_value == pending_value:
answer = raw_input("\n- WARNING, %s is already set to %s, do you still
want to set the attribute? Type (y) or (n): " % (attribute_name, current_value))
if answer == "n":
sys.exit()
else:
pass
### Function to set BIOS attribute pending value
def set_bios_attribute():
print "\n- WARNING: Current value for %s is: %s, setting to: %s\n" %
(attribute_name, current_value, pending_value)