2
0
mirror of https://opendev.org/x/pyghmi synced 2025-03-09 21:56:48 +00:00

Block problematic operations while update in progress

The XCC does not take kindly to certain requests during update.
Mitigate through blocking those requests.  Before the update would fail
and the new operation succeed.  Change so that the running update is
allowed to continue at the expense of the new attempt.

Change-Id: I94618450206fd4a7eba37f2614e713baf3e82023
This commit is contained in:
Jarrod Johnson 2017-11-01 11:06:01 -04:00
parent 87cc663751
commit ba46ba7a25
2 changed files with 20 additions and 1 deletions

View File

@ -2,7 +2,7 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 IBM Corporation
# Copyright 2015 Lenovo
# Copyright 2015-2017 Lenovo
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -35,6 +35,12 @@ class UnrecognizedCertificate(Exception):
self.certdata = certdata
class TemporaryError(Exception):
# A temporary condition that should clear, but warrants reporting to the
# caller
pass
class InvalidParameterValue(PyghmiException):
pass

View File

@ -69,6 +69,7 @@ class IMMClient(object):
def __init__(self, ipmicmd):
self.ipmicmd = weakref.proxy(ipmicmd)
self.updating = False
self.imm = ipmicmd.bmc
self.adp_referer = 'https://{0}/designs/imm/index-console.php'.format(
self.imm)
@ -222,6 +223,9 @@ class IMMClient(object):
def fetch_agentless_firmware(self):
adapterdata = self.get_cached_data('lenovo_cached_adapters')
if not adapterdata:
if self.updating:
raise pygexc.TemporaryError(
'Cannot read extended inventory during firmware update')
if self.wc:
adapterdata = self.wc.grab_json_response(
self.ADP_URL, referer=self.adp_referer)
@ -340,6 +344,9 @@ class IMMClient(object):
hwmap['Enclosure'] = {'UUID': fixup_uuid(enclosureuuid)}
adapterdata = self.get_cached_data('lenovo_cached_adapters')
if not adapterdata:
if self.updating:
raise pygexc.TemporaryError(
'Cannot read extended inventory during firmware update')
if self.wc:
adapterdata = self.wc.grab_json_response(
self.ADP_URL, referer=self.adp_referer)
@ -594,15 +601,21 @@ class XCCClient(IMMClient):
def update_firmware(self, filename, data=None, progress=None, bank=None):
result = None
if self.updating:
raise pygexc.TemporaryError('Cannot run multiple updates to same '
'target concurrently')
self.updating = True
try:
result = self.update_firmware_backend(filename, data, progress,
bank)
except Exception:
self.updating = False
self._refresh_token()
self.wc.grab_json_response('/api/providers/fwupdate', json.dumps(
{'UPD_WebCancel': 1}))
self.weblogout()
raise
self.updating = False
self.weblogout()
return result