summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-08-30 05:51:29 +0000
committerGerrit Code Review <review@openstack.org>2022-08-30 05:51:29 +0000
commit67946336308b285f4ed28af1ece2237676afbd73 (patch)
tree06f41e98157ad0dd9cebb25b1a506673edfa69ce
parent45aa5776877120f215344d082ab32597d45398f1 (diff)
parentc6936cc6389aa8396480aecf8d71cdf50eb42fae (diff)
downloadironic-67946336308b285f4ed28af1ece2237676afbd73.tar.gz
Merge "redfish: fixes usage of ValueDisplayName" into bugfix/19.0
-rw-r--r--ironic/drivers/modules/redfish/bios.py18
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_bios.py3
-rw-r--r--releasenotes/notes/ValueDisplayName-13837c653277ff08.yaml5
3 files changed, 18 insertions, 8 deletions
diff --git a/ironic/drivers/modules/redfish/bios.py b/ironic/drivers/modules/redfish/bios.py
index 3ac7fcd6e..9e0e1ac31 100644
--- a/ironic/drivers/modules/redfish/bios.py
+++ b/ironic/drivers/modules/redfish/bios.py
@@ -55,20 +55,23 @@ class RedfishBIOS(base.BIOSInterface):
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
@@ -130,7 +133,8 @@ class RedfishBIOS(base.BIOSInterface):
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})
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_bios.py b/ironic/tests/unit/drivers/modules/redfish/test_bios.py
index cd6f9be5f..a0ef28f5c 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_bios.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_bios.py
@@ -573,7 +573,8 @@ class RedfishBiosRegistryTestCase(db_base.DbTestCase):
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
diff --git a/releasenotes/notes/ValueDisplayName-13837c653277ff08.yaml b/releasenotes/notes/ValueDisplayName-13837c653277ff08.yaml
new file mode 100644
index 000000000..6abac74c6
--- /dev/null
+++ b/releasenotes/notes/ValueDisplayName-13837c653277ff08.yaml
@@ -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.