mirror of
https://github.com/xcat2/confluent.git
synced 2026-06-03 01:38:30 +00:00
Port megarac changes over
This commit is contained in:
@@ -1537,7 +1537,7 @@ class Command(object):
|
||||
oem = await self.oem()
|
||||
return await oem.get_update_status()
|
||||
|
||||
async def update_firmware(self, file, data=None, progress=None, bank=None):
|
||||
async def update_firmware(self, file, data=None, progress=None, bank=None, otherfields=()):
|
||||
"""Send file to BMC to perform firmware update
|
||||
|
||||
:param filename: The filename to upload to the target BMC
|
||||
@@ -1550,7 +1550,7 @@ class Command(object):
|
||||
if progress is None:
|
||||
progress = lambda x: True
|
||||
oem = await self.oem()
|
||||
return await oem.update_firmware(file, data, progress, bank)
|
||||
return await oem.update_firmware(file, data, progress, bank, otherfields)
|
||||
|
||||
async def get_diagnostic_data(self, savefile, progress=None, autosuffix=False):
|
||||
if os.path.exists(savefile) and not os.path.isdir(savefile):
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import aiohmi.redfish.oem.generic as generic
|
||||
import aiohmi.util.webclient as webclient
|
||||
from urllib.parse import urlencode
|
||||
import aiohmi.exceptions as pygexc
|
||||
|
||||
|
||||
class OEMHandler(generic.OEMHandler):
|
||||
@@ -34,7 +35,49 @@ class OEMHandler(generic.OEMHandler):
|
||||
self.bmc = webclient.thehost
|
||||
self._certverify = webclient.verifycallback
|
||||
return self
|
||||
|
||||
|
||||
async def reseat_bay(self, bay):
|
||||
if bay != -1:
|
||||
raise pygexc.UnsupportedFunctionality(
|
||||
'This is not an enclosure manager')
|
||||
|
||||
await self._do_web_request('/redfish/v1/Chassis/Chassis_0/Actions/Oem/NvidiaChassis.AuxPowerReset', {
|
||||
"ResetType": "AuxPowerCycle"
|
||||
})
|
||||
|
||||
def format_messages(self, response):
|
||||
msgs = response.get('Messages', [])
|
||||
msgents = []
|
||||
for msg in msgs:
|
||||
msgents.append(self.format_message(msg))
|
||||
for msg in response.get('Oem', {}).get('Ami', {}).get('HMCMessages', []):
|
||||
msgents.append(self.format_messages(msg))
|
||||
return ';'.join(msgents)
|
||||
|
||||
async def update_firmware(self, filename, data=None, progress=None, bank=None, otherfields=()):
|
||||
await self._do_web_request('/redfish/v1/UpdateService', {
|
||||
"Oem": {
|
||||
"AMIUpdateService": {
|
||||
"@odata.type": "#AMIUpdateService.v1_0_0.AMIUpdateService",
|
||||
"PreserveConfiguration": {
|
||||
"Syslog": True,
|
||||
"NTP": True,
|
||||
"Network": True,
|
||||
"Authentication": True,
|
||||
"EXTLOG": True,
|
||||
"FRU": True,
|
||||
"IPMI": True,
|
||||
"KVM": True,
|
||||
"REDFISH": True,
|
||||
"SDR": False,
|
||||
"SEL": True,
|
||||
"SNMP": True,
|
||||
"SSH": True,
|
||||
"WEB": True
|
||||
}
|
||||
}}}, method='PATCH', etag='*')
|
||||
return await super().update_firmware(filename, data, progress, bank, otherfields)
|
||||
|
||||
|
||||
async def get_wc(self):
|
||||
self.fwid = None
|
||||
|
||||
@@ -652,7 +652,7 @@ class OEMHandler(object):
|
||||
'Status', {})
|
||||
procsumstatus = procsumstatus.get('HealthRollup',
|
||||
procsumstatus.get('Health',
|
||||
None))
|
||||
'OK'))
|
||||
if procsumstatus != 'OK':
|
||||
procfound = False
|
||||
procurl = sysinfo.get('Processors', {}).get('@odata.id',
|
||||
@@ -764,6 +764,8 @@ class OEMHandler(object):
|
||||
return {'bootdev': reqbootdev}
|
||||
except Exception:
|
||||
del payload['Boot']['BootSourceOverrideMode']
|
||||
else:
|
||||
payload['Boot']['BootSourceOverrideMode'] = 'UEFI'
|
||||
#thetag = fishclient.sysinfo.get('@odata.etag', None)
|
||||
await fishclient._do_web_request(fishclient.sysurl, payload, method='PATCH',
|
||||
etag='*') # thetag)
|
||||
@@ -1404,13 +1406,22 @@ class OEMHandler(object):
|
||||
return 'ready'
|
||||
return 'unavailable'
|
||||
|
||||
def format_message(self, msg):
|
||||
try:
|
||||
return '{}: {}'.format(msg.get('MessageSeverity', msg['Severity']), msg['Message'])
|
||||
except Exception:
|
||||
return repr(msg)
|
||||
|
||||
def format_messages(self, response):
|
||||
msgs = response.get('Messages', [])
|
||||
return ';'.join(self.format_message(x) for x in msgs)
|
||||
|
||||
async def update_firmware(self, filename, data=None, progress=None, bank=None, otherfields=()):
|
||||
# disable cache to make sure we trigger the token renewal logic if needed
|
||||
usd, upurl, ismultipart = await self.retrieve_firmware_upload_url()
|
||||
try:
|
||||
uploadthread = await webclient.make_uploader(
|
||||
self.webclient, upurl, filename, data, formwrap=ismultipart,
|
||||
self.webclient, upurl, filename, data, formname='UpdateFile', formwrap=ismultipart,
|
||||
otherfields=otherfields)
|
||||
wc = self.webclient
|
||||
while not uploadthread.completed():
|
||||
@@ -1471,11 +1482,9 @@ class OEMHandler(object):
|
||||
if state in ('Cancelled', 'Exception', 'Interrupted',
|
||||
'Suspended'):
|
||||
raise Exception(
|
||||
json.dumps(json.dumps(pgress['Messages'])))
|
||||
self.format_messages(pgress))
|
||||
if 'PercentComplete' in pgress:
|
||||
pct = float(pgress['PercentComplete'])
|
||||
else:
|
||||
print(repr(pgress))
|
||||
complete = state == 'Completed'
|
||||
progress({'phase': phase, 'progress': pct})
|
||||
if complete:
|
||||
|
||||
Reference in New Issue
Block a user