2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-27 19:37:44 +00:00

Provide for Adapter updates

Adapter updates require a different conversation.
Implement that conversation so that the user need
not be aware.

Change-Id: I865d211b8aad08797b556a077814a3068ae9ea2c
This commit is contained in:
Jarrod Johnson 2017-10-24 10:49:19 -04:00
parent 110f6c1ebd
commit 30195bd316

View File

@ -1,6 +1,6 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2016 Lenovo
# Copyright 2016-2017 Lenovo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -672,9 +672,33 @@ class XCCClient(IMMClient):
rsp = self.wc.grab_json_response('/api/dataset/imm_firmware_success')
if len(rsp['items']) != 1:
raise Exception('Unexpected result: ' + repr(rsp))
rsp = self.wc.grab_json_response('/api/dataset/imm_firmware_update')
if rsp['items'][0]['upgrades'][0]['id'] != 1:
raise Exception('Unexpected answer: ' + repr(rsp))
firmtype = rsp['items'][0]['firmware_type']
if firmtype not in ('UEFI', 'IMM'): # adapter firmware
webid = rsp['items'][0]['webfile_build_id']
locations = webid[webid.find('[')+1:webid.find(']')]
locations = locations.split(':')
if len(locations) > 1:
raise Exception("Multiple of the same adapter not supported")
validselector = locations[0].replace('#', '-')
rsp = self.wc.grab_json_response(
'/api/function/adapter_update?params=pci_GetAdapterListAndFW')
for adpitem in rsp['items']:
selector = '{0}-{1}'.format(adpitem['location'],
adpitem['slotNo'])
if selector == validselector:
break
else:
raise Exception('Could not find matching adapter for update')
rsp = self.wc.grab_json_response('/api/function', json.dumps(
{'pci_SetOOBFWSlots': selector}))
if rsp['return'] != 0:
raise Exception(
'Unexpected result from PCI select: ' + repr(rsp))
else:
rsp = self.wc.grab_json_response(
'/api/dataset/imm_firmware_update')
if rsp['items'][0]['upgrades'][0]['id'] != 1:
raise Exception('Unexpected answer: ' + repr(rsp))
self._refresh_token()
progress({'phase': 'apply',
'progress': 0.0})