Browse Source

Merge "Correct Redfish boot once fallback conditional" into stable/train

tags/13.0.6
Zuul 2 months ago
committed by Gerrit Code Review
parent
commit
f0e06709a8
2 changed files with 32 additions and 1 deletions
  1. +1
    -1
      ironic/drivers/modules/redfish/management.py
  2. +31
    -0
      ironic/tests/unit/drivers/modules/redfish/test_management.py

+ 1
- 1
ironic/drivers/modules/redfish/management.py View File

@@ -85,7 +85,7 @@ def _set_boot_device(task, system, device, persistent=False):
use_new_set_system_boot = False
system.set_system_boot_source(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,


+ 31
- 0
ironic/tests/unit/drivers/modules/redfish/test_management.py View File

@@ -195,6 +195,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,


Loading…
Cancel
Save