summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,