diff --git a/pyghmi/ipmi/oem/lenovo/config.py b/pyghmi/ipmi/oem/lenovo/config.py index 9cd40d17..826700d1 100644 --- a/pyghmi/ipmi/oem/lenovo/config.py +++ b/pyghmi/ipmi/oem/lenovo/config.py @@ -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 diff --git a/pyghmi/ipmi/oem/lenovo/imm.py b/pyghmi/ipmi/oem/lenovo/imm.py index 1e29bc86..b7d8a439 100644 --- a/pyghmi/ipmi/oem/lenovo/imm.py +++ b/pyghmi/ipmi/oem/lenovo/imm.py @@ -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,