summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Pioso <richard.pioso@dell.com>2020-06-21 18:05:31 -0400
committerRichard Pioso <richard.pioso@dell.com>2020-07-05 03:52:12 -0400
commit91b0f738347cdbcb87c320e80023657b1824b6a5 (patch)
treeb73c3efd339c48e0ea4c4d13f33aba86c255cd21
parent5026854e318fc8d324c18896e51e666b1064b1d4 (diff)
downloadironic-91b0f738347cdbcb87c320e80023657b1824b6a5.tar.gz
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
-rw-r--r--ironic/drivers/modules/redfish/management.py2
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_management.py31
2 files changed, 32 insertions, 1 deletions
diff --git a/ironic/drivers/modules/redfish/management.py b/ironic/drivers/modules/redfish/management.py
index f415b6d20..22ef03b49 100644
--- a/ironic/drivers/modules/redfish/management.py
+++ b/ironic/drivers/modules/redfish/management.py
@@ -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,
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_management.py b/ironic/tests/unit/drivers/modules/redfish/test_management.py
index 70c1d5df9..60c9fd095 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_management.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_management.py
@@ -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,