White Papers
29 Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers,
verify=False, auth=('root','calvin'))
statusCode = response.status_code
if statusCode == 204:
print "\n- PASS, Command passed to power ON server, code return is %s\n"
% statusCode
else:
print "\n- FAIL, Command failed to power ON server, status code is:
%s\n" % statusCode
print "Extended Info Message: {0}".format(response.json())
sys.exit()
### Function to loop checking the job status until marked completed or failed
def loop_job_status():
start_time=datetime.now()
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)
current_time=(datetime.now()-start_time)
statusCode = req.status_code
if statusCode == 200:
print "\n- PASS, Command passed to check job status, code 200
returned\n"
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 str(current_time)[0:7] >= "0:30:00":
print "\n- FAIL: Timeout of 30 minutes has been hit, script
stopped\n"
sys.exit()
elif "Fail" in data[u'Message'] or "fail" in data[u'Message']:
print "- FAIL: %s failed" % job_id
sys.exit()
elif data[u'Message'] == "Job completed successfully.":
print "\n JobID = "+data[u'Id']
print " Name = "+data[u'Name']
print " Message = "+data[u'Message']
print " PercentComplete = "+str(data[u'PercentComplete'])+"\n"
break
else: