mirror of
https://opendev.org/x/pyghmi
synced 2025-01-12 18:58:34 +00:00
Add RDOC support for XCC3
Change-Id: Iae47c220a595b2636986cf8dc00b31052d1b0b23
This commit is contained in:
parent
e09da05a45
commit
3278c762f9
@ -1,6 +1,8 @@
|
||||
import copy
|
||||
import json
|
||||
import pyghmi.redfish.oem.generic as generic
|
||||
import pyghmi.exceptions as pygexc
|
||||
import pyghmi.util.webclient as webclient
|
||||
|
||||
|
||||
class OEMHandler(generic.OEMHandler):
|
||||
@ -97,6 +99,32 @@ class OEMHandler(generic.OEMHandler):
|
||||
currsettings[setting] = val
|
||||
return currsettings, reginfo
|
||||
|
||||
def upload_media(self, filename, progress=None, data=None):
|
||||
wc = self.webclient
|
||||
uploadthread = webclient.FileUploader(
|
||||
wc, '/rdoc_upload', filename, data,
|
||||
formname='file',
|
||||
formwrap=True)
|
||||
uploadthread.start()
|
||||
while uploadthread.isAlive():
|
||||
uploadthread.join(3)
|
||||
if progress:
|
||||
progress({'phase': 'upload',
|
||||
'progress': 100 * wc.get_upload_progress()})
|
||||
rsp = json.loads(uploadthread.rsp)
|
||||
if rsp['return'] != 0:
|
||||
raise Exception('Issue uploading file')
|
||||
remfilename = rsp['upload_filename']
|
||||
if progress:
|
||||
progress({'phase': 'upload',
|
||||
'progress': 100.0})
|
||||
self._do_web_request(
|
||||
'/redfish/v1/Systems/1/VirtualMedia/RDOC1',
|
||||
{'Image':'file:///gpx/rdocupload/' + remfilename,
|
||||
'WriteProtected': False}, method='PATCH')
|
||||
if progress:
|
||||
progress({'phase': 'complete'})
|
||||
|
||||
def get_firmware_inventory(self, components, fishclient):
|
||||
fwlist = fishclient._do_web_request(fishclient._fwinventory + '?$expand=.')
|
||||
fwlist = copy.deepcopy(fwlist.get('Members', []))
|
||||
|
@ -97,8 +97,9 @@ class FileDownloader(threading.Thread):
|
||||
|
||||
|
||||
def get_upload_form(filename, data, formname, otherfields):
|
||||
ffilename = filename.split('/')[-1]
|
||||
if not formname:
|
||||
formname = filename
|
||||
formname = ffilename
|
||||
try:
|
||||
return uploadforms[filename]
|
||||
except KeyError:
|
||||
@ -109,7 +110,7 @@ def get_upload_form(filename, data, formname, otherfields):
|
||||
form = (b'--' + BND
|
||||
+ '\r\nContent-Disposition: form-data; '
|
||||
'name="{0}"; filename="{1}"\r\n'.format(
|
||||
formname, filename).encode('utf-8'))
|
||||
formname, ffilename).encode('utf-8'))
|
||||
form += b'Content-Type: application/octet-stream\r\n\r\n' + data
|
||||
for ofield in otherfields:
|
||||
form += (b'\r\n--' + BND
|
||||
|
Loading…
x
Reference in New Issue
Block a user