From 44733d19b06e9b85f1e48c9a1ad1843f9904b783 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 8 Feb 2023 09:47:34 -0500 Subject: [PATCH] Add retry logic to web fetch While UEFI configuration is always handy, reads to the IMM section may require wait and retry. Change-Id: I7fe97124897fca6e928c3699171bfbe676d699e1 --- pyghmi/ipmi/oem/lenovo/config.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/oem/lenovo/config.py b/pyghmi/ipmi/oem/lenovo/config.py index 30ed06d9..5a3758f4 100644 --- a/pyghmi/ipmi/oem/lenovo/config.py +++ b/pyghmi/ipmi/oem/lenovo/config.py @@ -23,6 +23,7 @@ import random import struct import six +import time import pyghmi.exceptions as pygexc @@ -285,9 +286,19 @@ class LenovoFirmwareConfig(object): else: rsp = (None, 500) if rsp[1] == 200: - data = rsp[0]['Content'] - data = base64.b64decode(data) - data = EfiCompressor.FrameworkDecompress(data, len(data)) + for _ in range(0, 30): + data = rsp[0]['Content'] + data = base64.b64decode(data) + data = EfiCompressor.FrameworkDecompress(data, len(data)) + if len(data) != 0: + break + if self.connection: + self.connection.ipmi_session.pause(2) + else: + time.sleep(2) + rsp = self.xc.grab_redfish_response_with_status( + '/redfish/v1/Systems/1/Actions/Oem/LenovoComputerSystem.DSReadFile', + {'Action': 'DSReadFile', 'FileName': cfgfilename}) else: if self.connection is None: raise Unsupported('Not Supported')