Merge "Prevent MissingAttribute error when supportedApplyTime missing"

This commit is contained in:
Zuul 2023-08-08 07:59:03 +00:00 committed by Gerrit Code Review
commit e2011518f1
3 changed files with 38 additions and 6 deletions

View File

@ -230,12 +230,16 @@ class RedfishBIOS(base.BIOSInterface):
LOG.debug('Apply BIOS configuration for node %(node_uuid)s: ' LOG.debug('Apply BIOS configuration for node %(node_uuid)s: '
'%(settings)r', {'node_uuid': task.node.uuid, '%(settings)r', {'node_uuid': task.node.uuid,
'settings': settings}) '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: try:
bios.set_attributes(attributes, apply_time=apply_time) bios.set_attributes(attributes, apply_time=apply_time)

View File

@ -537,6 +537,27 @@ class RedfishBiosTestCase(db_base.DbTestCase):
{s['name']: s['value'] for s in settings}, {s['name']: s['value'] for s in settings},
apply_time=None) 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', @mock.patch('oslo_utils.eventletutils.EventletEvent.wait',
lambda *args, **kwargs: None) lambda *args, **kwargs: None)

View File

@ -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.