Improve redfish
set-boot-device behaviour
Makes management interface of `redfish` hardware type not changing current boot frequency if currently set one is the same as the desired one. The goal is to avoid touching potentially faulty BMC option whenever possible. This should hopefully improve interoperability with Redfish BMCs. Depends-On: https://review.opendev.org/710751 Change-Id: I380cd3aae410e05a4519c3764140ced121bf7fe7 Story: 2007355 Task: 38937
This commit is contained in:
parent
5be4c4f5c5
commit
aad54c245b
@ -126,10 +126,17 @@ class RedfishManagement(base.ManagementInterface):
|
||||
"""
|
||||
system = redfish_utils.get_system(task.node)
|
||||
|
||||
desired_persistence = BOOT_DEVICE_PERSISTENT_MAP_REV[persistent]
|
||||
current_persistence = system.boot.get('enabled')
|
||||
|
||||
# NOTE(etingof): this can be racy, esp if BMC is not RESTful
|
||||
enabled = (desired_persistence
|
||||
if desired_persistence != current_persistence else None)
|
||||
|
||||
try:
|
||||
system.set_system_boot_options(
|
||||
BOOT_DEVICE_MAP_REV[device],
|
||||
enabled=BOOT_DEVICE_PERSISTENT_MAP_REV[persistent])
|
||||
BOOT_DEVICE_MAP_REV[device], enabled=enabled)
|
||||
|
||||
except sushy.exceptions.SushyError as e:
|
||||
error_msg = (_('Redfish set boot device failed for node '
|
||||
'%(node)s. Error: %(error)s') %
|
||||
|
@ -127,6 +127,31 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||
fake_system.set_system_boot_options.reset_mock()
|
||||
mock_get_system.reset_mock()
|
||||
|
||||
@mock.patch.object(redfish_utils, 'get_system', autospec=True)
|
||||
def test_set_boot_device_persistency_no_change(self, mock_get_system):
|
||||
fake_system = mock.Mock()
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
# 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_fail(self, mock_get_system, mock_sushy):
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Makes management interface of ``redfish`` hardware type not changing
|
||||
current boot frequency if currently set is the same as the desired one.
|
||||
The goal is to avoid touching potentially faulty BMC option whenever
|
||||
possible.
|
Loading…
x
Reference in New Issue
Block a user