2
0
mirror of https://opendev.org/x/pyghmi synced 2025-09-14 22:28:08 +00:00

Merge "Block problematic operations while update in progress"

This commit is contained in:
Zuul
2017-11-01 17:18:07 +00:00
committed by Gerrit Code Review
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