Reference Guide
31 RESTful Server Configuration with iDRAC RESTful API
file = sys.argv[4]
except:
print "\n- FAIL, you must pass in script name along with iDRAC IP/iDRAC username/iDRAC paasswo
rd/file name"
sys.exit()
url = 'https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemCon
figuration' % idrac_ip
# For payload dictionary supported parameters, refer to schema
# "https://'iDRAC IP'/redfish/v1/Managers/iDRAC.Embedded.1/"
payload = {"ShutdownType":"Forced","ShareParameters":{"Target":"ALL","IPAddress":"192.168.0.130","
ShareName":"WebServerFolder","ShareType":"HTTP","FileName":file}}
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False, auth=(idrac
_username,idrac_password))
d=str(response.__dict__)
try:
z=re.search("JID_.+?,",d).group()
except:
print "\n- FAIL: detailed error message: {0}".format(response.__dict__['_content'])
sys.exit()
job_id=re.sub("[,']","",z)
if response.status_code != 202:
print "\n- FAIL, status code not 202\n, code is: %s" % response.status_code
sys.exit()
else:
print "\n- %s successfully created for ImportSystemConfiguration method\n" % (job_id)
response_output=response.__dict__
job_id=response_output["headers"]["Location"]
job_id=re.search("JID_.+",job_id).group()
start_time=datetime.now()
while True:
req = requests.get('https://%s/redfish/v1/TaskService/Tasks/%s' % (idrac_ip, job_id), auth=(id
rac_username, idrac_password), verify=False)
statusCode = req.status_code
data = req.json()
message_string=data[u"Messages"]
final_message_string=str(message_string)
current_time=(datetime.now()-start_time)
if statusCode == 202 or statusCode == 200:
print "\n- Query job ID command passed"
time.sleep(10)
else:
print "Query job ID command failed, error code is: %s" % statusCode
sys.exit()
if "failed" in final_message_string or "completed with errors" in final_message_string or "Not
one" in final_message_string or "Unable" in final_message_string:
print "\n- FAIL, detailed job message is: %s" % data[u"Messages"]
sys.exit()
elif "Successfully imported" in final_message_string or "completed with errors" in final_messa
ge_string or "Successfully imported" in final_message_string: