White Papers

28 Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers
def get_job_status():
while True:
req =
requests.get('https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/%s' %
(idrac_ip, job_id), auth=(idrac_username, idrac_password), verify=False)
statusCode = req.status_code
if statusCode == 200:
print "\n- PASS, Command passed to check job status, code 200
returned\n"
time.sleep(20)
else:
print "\n- FAIL, Command failed to check job status, return code is
%s" % statusCode
print "Extended Info Message: {0}".format(req.json())
sys.exit()
data = req.json()
if data[u'Message'] == "Task successfully scheduled.":
print " JobID = "+data[u'Id']
print " Name = "+data[u'Name']
print " Message = "+data[u'Message']
print " PercentComplete = "+str(data[u'PercentComplete'])+"\n"
break
else:
print "\n- WARNING: JobStatus not scheduled, current status is:
%s\n" % data[u'Message']
### Function to reboot the server
def reboot_server():
url =
'https://%s/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset' %
idrac_ip
payload = {'ResetType': 'ForceOff'}
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers,
verify=False, auth=(idrac_username,idrac_password))
statusCode = response.status_code
if statusCode == 204:
print "\n- PASS, Command passed to power OFF server, code return is
%s\n" % statusCode
else:
print "\n- FAIL, Command failed to power OFF server, status code is:
%s\n" % statusCode
print "Extended Info Message: {0}".format(response.json())
sys.exit()
time.sleep(10)
payload = {'ResetType': 'On'}