diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-08-26 10:42:15 +0200 |
---|---|---|
committer | Iury Gregory Melo Ferreira <iurygregory@gmail.com> | 2022-08-26 12:45:33 +0000 |
commit | e0745d4f65806b5c48f948ef40c4b37362143483 (patch) | |
tree | 5eddedb2ee423b85b091e3b17f96da23b1f44514 /ironic | |
parent | 9a81eb268d27d7a74cac9ae15e40033dcd3a4f33 (diff) | |
download | ironic-e0745d4f65806b5c48f948ef40c4b37362143483.tar.gz |
redfish: fixes usage of ValueDisplayName
It's spelled this way, not DisplayValueName.
Change-Id: I170d78bdb7ed0f6c36a80a9f2ceb9629f44394ed
(cherry picked from commit 9f1f58c6af3aabcb3ae56e5f7b292f07e81e2864)
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/drivers/modules/redfish/bios.py | 18 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/redfish/test_bios.py | 3 |
2 files changed, 13 insertions, 8 deletions
diff --git a/ironic/drivers/modules/redfish/bios.py b/ironic/drivers/modules/redfish/bios.py index bee868e38..44742795e 100644 --- a/ironic/drivers/modules/redfish/bios.py +++ b/ironic/drivers/modules/redfish/bios.py @@ -54,20 +54,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 @@ -129,7 +132,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 f9146f3b6..2ff3235fd 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_bios.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_bios.py @@ -597,7 +597,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 |