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
This commit is contained in:
Jarrod Johnson 2023-02-08 09:47:34 -05:00
parent e4a48e9072
commit 44733d19b0
1 changed files with 14 additions and 3 deletions

View File

@ -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')