Skip to content

Commit

Permalink
redfish: fixes usage of ValueDisplayName
Browse files Browse the repository at this point in the history
It's spelled this way, not DisplayValueName.

Change-Id: I170d78bdb7ed0f6c36a80a9f2ceb9629f44394ed
(cherry picked from commit 9f1f58c)
  • Loading branch information
dtantsur authored and iurygregory committed Aug 26, 2022
1 parent 8034242 commit 4bcdd4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
18 changes: 11 additions & 7 deletions ironic/drivers/modules/redfish/bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,23 @@ def __init__(self):
driver='redfish',
reason=_("Unable to import the sushy library"))

def _parse_allowable_values(self, allowable_values):
def _parse_allowable_values(self, node, allowable_values):
"""Convert the BIOS registry allowable_value list to expected strings
:param allowable_values: list of dicts of valid values for enumeration
:returns: list containing only allowable value names
"""

# Get name from ValueName if it exists, otherwise use DisplayValueName
# Get name from ValueName if it exists, otherwise use ValueDisplayName
new_list = []
for dic in allowable_values:
for key in dic:
if key == 'ValueName' or key == 'DisplayValueName':
new_list.append(dic[key])
break
key = dic.get('ValueName') or dic.get('ValueDisplayName')
if key:
new_list.append(key)
else:
LOG.warning('Cannot detect the value name for enumeration '
'item %(item)s for node %(node)s',
{'item': dic, 'node': node.uuid})

return new_list

Expand Down Expand Up @@ -129,7 +132,8 @@ def cache_bios_settings(self, task):
setting[k] = getattr(reg, k, None)
if k == "allowable_values" and isinstance(setting[k],
list):
setting[k] = self._parse_allowable_values(setting[k])
setting[k] = self._parse_allowable_values(
task.node, setting[k])

LOG.debug('Cache BIOS settings for node %(node_uuid)s',
{'node_uuid': task.node.uuid})
Expand Down
3 changes: 2 additions & 1 deletion ironic/tests/unit/drivers/modules/redfish/test_bios.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ def __init__(self, num_entries):
self.registry.registry_entries.attributes[1].read_only = False
self.registry.registry_entries.attributes[1].allowable_values =\
[{'ValueName': 'Enabled', 'ValueDisplayName': 'Enabled'},
{'ValueName': 'Disabled', 'ValueDisplayName': 'Disabled'}]
{'ValueDisplayName': 'Disabled'},
{'Invalid': 'banana'}]
self.registry.registry_entries.attributes[2].name = "BootDelay"
self.registry.registry_entries.attributes[2].attribute_type = "Integer"
self.registry.registry_entries.attributes[2].lower_bound = 5
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/ValueDisplayName-13837c653277ff08.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixes detecting of allowable values for a BIOS settings enumeration in
the ``redfish`` BIOS interface when only ``ValueDisplayName`` is provided.

0 comments on commit 4bcdd4d

Please sign in to comment.