Reference Guide

16 RESTful Server Configuration with iDRAC RESTful API
Script redfish_SCP_export_http.py
# Python script using Redfish API to perform iDRAC feature
# Server Configuration Profile (SCP) for export to HTTP share only
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]
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.ExportSystemCon
figuration' % idrac_ip
# For payload dictionary supported parameters, refer to schema
# "https://'iDRAC IP'/redfish/v1/Managers/iDRAC.Embedded.1/"
payload = {"ExportFormat":"JSON","ExportUse":"Default","ShareParameters":{"Target":"All","IPAddres
s":"192.168.0.130","ShareName":"webshare","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##### Command Failed, status code not 202\n, code is: %s" % response.status_code
sys.exit()
else:
print "\n- %s successfully created for ExportSystemConfiguration 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