1- # Copyright 2020 Hewlett Packard Enterprise Development LP
1+ # Copyright 2019 Hewlett Packard Enterprise Development LP
22 #
33 # Licensed under the Apache License, Version 2.0 (the "License"); you may
44 # not use this file except in compliance with the License. You may obtain
1414
1515# -*- coding: utf-8 -*-
1616"""
17- An example of uploading firmware to the iLO Repository for flashing
17+ An example of uploading a component to the iLO Repository for flashing
1818"""
1919
2020import os
2525
2626from get_resource_directory import get_resource_directory
2727
28- def upload_firmware (_redfishobj , firmware_loc , update_repo = True , update_target = False ):
28+ def upload_firmware (_redfishobj , firmware_loc , compsig_loc , update_repo = True , update_target = False ):
2929 resource_instances = get_resource_directory (_redfishobj )
3030
3131 if DISABLE_RESOURCE_DIR or not resource_instances :
@@ -47,15 +47,21 @@ def upload_firmware(_redfishobj, firmware_loc, update_repo=True, update_target=F
4747
4848 filename = os .path .basename (firmware_loc )
4949 with open (firmware_loc , 'rb' ) as fle :
50- output = fle .read ()
50+ filenameOutput = fle .read ()
51+
52+ filename = os .path .basename (compsig_loc )
53+ with open (compsig_loc , 'rb' ) as fle :
54+ compsigOutput = fle .read ()
5155
5256 session_tuple = ('sessionKey' , session_key )
5357 parameters_tuple = ('parameters' , json .dumps (json_data ))
54- file_tuple = ('file' , (filename , output , 'application/octet-stream' ))
58+ file_tuple = ('file' , (filename , filenameOutput , 'application/octet-stream' ))
59+ comp_tuple = ('compsig' , (filename , compsigOutput , 'application/octet-stream' ))
5560
5661 #Build the payload from each multipart-form data tuple
5762 body .append (session_tuple )
5863 body .append (parameters_tuple )
64+ body .append (comp_tuple )
5965 body .append (file_tuple )
6066
6167 #Create our header dictionary
@@ -82,12 +88,13 @@ def upload_firmware(_redfishobj, firmware_loc, update_repo=True, update_target=F
8288 # SYSTEM_URL acceptable examples:
8389 # "https://10.0.0.0"
8490 # "https://ilo.hostname"
85- SYSTEM_URL = "https://16.83.61.104 "
86- LOGIN_ACCOUNT = "admin"
87- LOGIN_PASSWORD = "password"
91+ SYSTEM_URL = "https://10.0.0.0 "
92+ LOGIN_ACCOUNT = "admin
93+ LOGIN_PASSWORD = "password
8894
8995 # The path to the firmware file to upload
90- FIRMWARE_PATH = "C:\\ Users\\ oconnogr\\ git\\ python-restful-interface-tool\\ src\\ ilo5_230_p31.fwpkg"
96+ FIRMWARE_PATH = "/path/to/component.exe"
97+ COMPSIG_PATH = "/path/to/component.compsiq"
9198 # Upload the firmware file to the iLO Repository
9299 UPDATE_REPO = True
93100 # Update the system with the firmware file
@@ -107,6 +114,6 @@ def upload_firmware(_redfishobj, firmware_loc, update_repo=True, update_target=F
107114 sys .stderr .write ("ERROR: server not reachable or does not support RedFish.\n " )
108115 sys .exit ()
109116
110- upload_firmware (REDFISHOBJ , FIRMWARE_PATH , UPDATE_REPO , UPDATE_TARGET )
117+ upload_firmware (REDFISHOBJ , FIRMWARE_PATH , COMPSIG_PATH , UPDATE_REPO , UPDATE_TARGET )
111118
112119 REDFISHOBJ .logout ()
0 commit comments