Correct Redfish boot once fallback conditional

This corrects the variable examined to determine if falling back from
Redfish boot source override enabled continuous to once should be
performed. The value of the variable 'enabled', instead of
'desired_enabled', should be used.

Story: 2007733
Task: 40273
Change-Id: I26bf32c7f824e8e5ca7018d491e0bc9dc96a8671
This commit is contained in:
Richard Pioso 2020-06-21 18:05:31 -04:00
parent 5026854e31
commit 91b0f73834
2 changed files with 32 additions and 1 deletions

View File

@ -90,7 +90,7 @@ def _set_boot_device(task, system, device, persistent=False):
try:
system.set_system_boot_options(device, enabled=enabled)
except sushy.exceptions.SushyError as e:
if desired_enabled == sushy.BOOT_SOURCE_ENABLED_CONTINUOUS:
if enabled == sushy.BOOT_SOURCE_ENABLED_CONTINUOUS:
# NOTE(dtantsur): continuous boot device settings have been
# removed from Redfish, and some vendors stopped supporting
# it before an alternative was provided. As a work around,

View File

@ -177,6 +177,37 @@ class RedfishManagementTestCase(db_base.DbTestCase):
self.assertNotIn('redfish_boot_device',
task.node.driver_internal_info)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_set_boot_device_fail_no_change(self, mock_get_system):
fake_system = mock.Mock()
fake_system.set_system_boot_options.side_effect = (
sushy.exceptions.SushyError()
)
mock_get_system.return_value = fake_system
with task_manager.acquire(self.context, self.node.uuid,
shared=False) as task:
expected_values = [
(True, sushy.BOOT_SOURCE_ENABLED_CONTINUOUS),
(False, sushy.BOOT_SOURCE_ENABLED_ONCE)
]
for target, expected in expected_values:
fake_system.boot.get.return_value = expected
self.assertRaisesRegex(
exception.RedfishError, 'Redfish set boot device',
task.driver.management.set_boot_device, task,
boot_devices.PXE, persistent=target)
fake_system.set_system_boot_options.assert_called_once_with(
sushy.BOOT_SOURCE_TARGET_PXE, enabled=None)
mock_get_system.assert_called_once_with(task.node)
self.assertNotIn('redfish_boot_device',
task.node.driver_internal_info)
# Reset mocks
fake_system.set_system_boot_options.reset_mock()
mock_get_system.reset_mock()
@mock.patch.object(sushy, 'Sushy', autospec=True)
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
def test_set_boot_device_persistence_fallback(self, mock_get_system,