2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-31 05:17:39 +00:00

Slow down setting configuration

Problems may occur if setting configuration in
a script and multiple transactions are attempted
back to back.

Also, it can be confusing to set settings and then readback the old settings.

Address both concerns by only returning from
set when the transaction manifests in the data
returned from the peer system.

Change-Id: I93f360e0e2a3360bed460534bb924df1472d2bfb
This commit is contained in:
Jarrod Johnson 2021-02-01 15:30:01 -05:00
parent 3cfee6d2f2
commit 6542e7cc20
2 changed files with 26 additions and 9 deletions

View File

@ -51,7 +51,7 @@ def fromstring(inputdata):
def run_command_with_retry(connection, data):
tries = 15
tries = 240
while tries:
tries -= 1
try:
@ -472,7 +472,7 @@ class LenovoFirmwareConfig(object):
return options
def set_fw_options(self, options):
def set_fw_options(self, options, checkonly=False):
changes = False
random.seed()
ident = 'ASU-%x-%x-%x-0' % (random.getrandbits(48),
@ -539,7 +539,9 @@ class LenovoFirmwareConfig(object):
choice.append(instance)
if not changes:
return
return False
if checkonly:
return True
xml = etree.tostring(configurations)
data = EfiCompressor.FrameworkCompress(xml, len(xml))
@ -547,3 +549,4 @@ class LenovoFirmwareConfig(object):
size=len(data))
self.imm_write(filehandle, len(data), data)
self.imm_close(filehandle)
return True

View File

@ -253,6 +253,26 @@ class IMMClient(object):
else:
raise pygexc.InvalidParameterValue(
'{0} not a known setting'.format(key))
self.merge_changeset(changeset)
changepending = True
if changeset:
try:
changepending = self.fwc.set_fw_options(self.fwo)
except Exception:
self.fwo = None
self.fwovintage = 0
raise
giveup = util._monotonic_time() + 60
while changeset and changepending:
ipmisession.Session.pause(1)
self.fwo = self.fwc.get_fw_options(fetchimm=fetchimm)
self.fwovintage = util._monotonic_time()
if self.fwovintage > giveup:
break
self.merge_changeset(changeset)
changepending = self.fwc.set_fw_options(self.fwo, checkonly=True)
def merge_changeset(self, changeset):
for key in changeset:
if isinstance(changeset[key], six.string_types):
changeset[key] = {'value': changeset[key]}
@ -293,12 +313,6 @@ class IMMClient(object):
self.fwo[key]['new_value'] = newnewvalues[0]
else:
self.fwo[key]['new_value'] = newnewvalues
if changeset:
try:
self.fwc.set_fw_options(self.fwo)
except Exception:
self.fwo = None
raise
def clear_bmc_configuration(self):
self.ipmicmd.xraw_command(0x2e, 0xcc,