2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-28 11:57:34 +00:00

Support ordered default setting

An ordered setting (e.g. bootorder) requires
different handling.  Support it by the appropriate modifications.

Change-Id: I5b8931f3b034ee8f48285797bec4a4016a5fecc5
This commit is contained in:
Jarrod Johnson 2019-02-12 10:07:25 -05:00
parent bc8deb4b68
commit 97be31ca95

View File

@ -311,6 +311,7 @@ class LenovoFirmwareConfig(object):
ldata = setting.find("list_data")
extraorder = False
currentdict = {}
currentdef = {}
if ldata is not None:
is_list = True
current = []
@ -334,13 +335,24 @@ class LenovoFirmwareConfig(object):
choice.find('value').text)
except ValueError:
lenovo_value = choice.find('value').text
if choice.get("default") == "true":
hasdefault = choice.get('default')
if hasdefault == "true":
default = label
elif hasdefault is not None:
try:
a = int(hasdefault)
currentdef[a] = label
except ValueError:
pass
if choice.get("reset-required") == "true":
reset = True
if len(currentdict) > 0:
for order in sorted(currentdict):
current.append(currentdict[order])
if len(currentdef) > 0:
default = []
for order in sorted(currentdef):
default.append(currentdef[order])
optionname = "%s.%s" % (lenovo_id, name)
options[optionname] = dict(current=current,
default=default,