White Papers

35 Implementation of the DMTF Redfish API on Dell EMC PowerEdge Servers
from datetime import datetime
# Validate all correct parameters are passed in
try:
idrac_ip = sys.argv[1]
idrac_username = sys.argv[2]
idrac_password = sys.argv[3]
firmware_image_location = sys.argv[4]
file_image_name= sys.argv[5]
Install_Option = sys.argv[6]
except:
print "\n- FAIL, you must pass in script name along with iDRAC IP / iDRAC
username / iDRAC password / Image Path / Filename / Install Option. Example: \"
script_name.py 192.168.0.120 root calvin c:\Python26 bios.exe NowAndReboot\""
sys.exit()
# Convert install option to correct string due to case sensitivity in iDRAC.
if Install_Option == "now":
install_option = "Now"
elif Install_Option == "nowandreboot":
install_option = "NowAndReboot"
elif Install_Option == "nextreboot":
install_option = "NextReboot"
else:
install_option = Install_Option
# Download the image payload to the iDRAC
def download_image_payload():
print "\n- WARNING, downloading DUP payload to iDRAC\n"
global Location
global new_FW_version
global dup_version
req = requests.get('https://%s/redfish/v1/UpdateService/FirmwareInventory/'
% (idrac_ip), auth=(idrac_username, idrac_password), verify=False)
statusCode = req.status_code
data = req.json()
filename = file_image_name.lower()
ImageLocation = firmware_image_location
ImagePath = ImageLocation + "\\" + filename
ETag = req.headers['ETag']
url = 'https://%s/redfish/v1/UpdateService/FirmwareInventory' % (idrac_ip)
files = {'file': (filename, open(ImagePath, 'rb'), 'multipart/form-data')}
headers = {"if-match": ETag}