diff --git a/ironic/drivers/modules/redfish/bios.py b/ironic/drivers/modules/redfish/bios.py index 44742795e1..b0cc76b57b 100644 --- a/ironic/drivers/modules/redfish/bios.py +++ b/ironic/drivers/modules/redfish/bios.py @@ -230,12 +230,16 @@ class RedfishBIOS(base.BIOSInterface): LOG.debug('Apply BIOS configuration for node %(node_uuid)s: ' '%(settings)r', {'node_uuid': task.node.uuid, 'settings': settings}) - - if bios.supported_apply_times and ( - sushy.APPLY_TIME_ON_RESET in bios.supported_apply_times): - apply_time = sushy.APPLY_TIME_ON_RESET - else: - apply_time = None + apply_time = None + try: + if bios.supported_apply_times and ( + sushy.APPLY_TIME_ON_RESET in + bios.supported_apply_times): + apply_time = sushy.APPLY_TIME_ON_RESET + except AttributeError: + LOG.warning('SupportedApplyTimes attribute missing for BIOS' + ' configuration on node %(node_uuid)s: ', + {'node_uuid': task.node.uuid}) try: bios.set_attributes(attributes, apply_time=apply_time) diff --git a/ironic/tests/unit/drivers/modules/redfish/test_bios.py b/ironic/tests/unit/drivers/modules/redfish/test_bios.py index 2ff3235fd9..1d307300f4 100644 --- a/ironic/tests/unit/drivers/modules/redfish/test_bios.py +++ b/ironic/tests/unit/drivers/modules/redfish/test_bios.py @@ -537,6 +537,27 @@ class RedfishBiosTestCase(db_base.DbTestCase): {s['name']: s['value'] for s in settings}, apply_time=None) + @mock.patch.object(redfish_boot.RedfishVirtualMediaBoot, 'prepare_ramdisk', + spec_set=True, autospec=True) + @mock.patch.object(deploy_utils, 'build_agent_options', autospec=True) + @mock.patch.object(redfish_utils, 'get_system', autospec=True) + @mock.patch.object(manager_utils, 'node_power_action', autospec=True) + def test_apply_configuration_no_apply_time_attr( + self, mock_power_action, mock_get_system, mock_build_agent_options, + mock_prepare): + settings = [{'name': 'ProcTurboMode', 'value': 'Disabled'}, + {'name': 'NicBoot1', 'value': 'NetworkBoot'}] + with task_manager.acquire(self.context, self.node.uuid, + shared=False) as task: + bios = mock_get_system(task.node).bios + del bios.supported_apply_times + + task.driver.bios.apply_configuration(task, settings) + + bios.set_attributes.assert_called_once_with( + {s['name']: s['value'] for s in settings}, + apply_time=None) + @mock.patch('oslo_utils.eventletutils.EventletEvent.wait', lambda *args, **kwargs: None) diff --git a/releasenotes/notes/handle-missing-bios-supportedapplytimes-attr-fbacc7ca3c399e83.yaml b/releasenotes/notes/handle-missing-bios-supportedapplytimes-attr-fbacc7ca3c399e83.yaml new file mode 100644 index 0000000000..153430deee --- /dev/null +++ b/releasenotes/notes/handle-missing-bios-supportedapplytimes-attr-fbacc7ca3c399e83.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes the bug where provisioning a Redfish managed node fails if changing + BIOS settings is attempted on a BMC that doesn't provide + supportedApplyTime information. This is done by adding handling of + AttributeError exception in apply_configuration() method.