Reference Guide

33 RESTful Server Configuration with iDRAC RESTful API
2.9 Importing SCP from a streamed local file
Configuration changes do not have to be located on a remote file share. It is fully possible to stream settings
from a local file, or indeed specify specific settings directly in the code, from a local client machine. This
feature requires iDRAC7/8 firmware 2.50.50.50 or later and iDRAC9 firmware 3.00.00.00 or later.
As input parameters the following script will take an iDRAC IP address, the IP admin credentials and a local
filename of an SCP file to stream to the target.
Script: redfish_SCP_import_local_file.py
# Python script using Redfish API to perform iDRAC
# Server Configuration Profile (SCP) import from local file
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]
filename=sys.argv[4]
except:
print "\n- FAIL: You must pass in script name\iDRAC ip\iDRAC username\iDRAC password"
sys.exit()
try:
f=open(filename,"r")
except:
print "\n-FAIL, \"%s\" file doesn't exist" % filename
sys.exit()
url = 'https://%s/redfish/v1/Managers/iDRAC.Embedded.1/Actions/Oem/EID_674_Manager.ImportSystemCon
figuration' % idrac_ip
# Code needed to modify the XML to one string to pass in for POST command
z=f.read()
z=re.sub(" \n ","",z)
z=re.sub(" \n","",z)
xml_string=re.sub(" ","",z)
f.close()
payload = {"ImportBuffer":"","ShareParameters":{"Target":"ALL"}}
payload["ImportBuffer"]=xml_string
headers = {'content-type': 'application/json'}
response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False, auth=('root
','calvin'))
#print '\n- Response status code is: %s' % response.status_code
d=str(response.__dict__)
try:
z=re.search("JID_.+?,",d).group()
except: