Merge "Sync boot mode when changing the boot device via Redfish" into stable/victoria
This commit is contained in:
commit
b7f0d1230f
|
@ -33,6 +33,7 @@ from ironic.conductor import task_manager
|
||||||
from ironic.conductor import utils as manager_utils
|
from ironic.conductor import utils as manager_utils
|
||||||
from ironic.conf import CONF
|
from ironic.conf import CONF
|
||||||
from ironic.drivers import base
|
from ironic.drivers import base
|
||||||
|
from ironic.drivers.modules import boot_mode_utils
|
||||||
from ironic.drivers.modules import deploy_utils
|
from ironic.drivers.modules import deploy_utils
|
||||||
from ironic.drivers.modules.redfish import utils as redfish_utils
|
from ironic.drivers.modules.redfish import utils as redfish_utils
|
||||||
|
|
||||||
|
@ -222,6 +223,10 @@ class RedfishManagement(base.ManagementInterface):
|
||||||
LOG.error(error_msg)
|
LOG.error(error_msg)
|
||||||
raise exception.RedfishError(error=error_msg)
|
raise exception.RedfishError(error=error_msg)
|
||||||
|
|
||||||
|
# Ensure that boot mode is synced with what is set.
|
||||||
|
# Some BMCs reset it to default (BIOS) when changing the boot device.
|
||||||
|
boot_mode_utils.sync_boot_mode(task)
|
||||||
|
|
||||||
def get_boot_device(self, task):
|
def get_boot_device(self, task):
|
||||||
"""Get the current boot device for a node.
|
"""Get the current boot device for a node.
|
||||||
|
|
||||||
|
|
|
@ -101,9 +101,11 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||||
task.driver.management.set_boot_device(task, target)
|
task.driver.management.set_boot_device(task, target)
|
||||||
|
|
||||||
# Asserts
|
# Asserts
|
||||||
fake_system.set_system_boot_options.assert_called_once_with(
|
fake_system.set_system_boot_options.assert_has_calls(
|
||||||
expected, enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
|
[mock.call(expected,
|
||||||
mock_get_system.assert_called_once_with(task.node)
|
enabled=sushy.BOOT_SOURCE_ENABLED_ONCE),
|
||||||
|
mock.call(mode=sushy.BOOT_SOURCE_MODE_BIOS)])
|
||||||
|
mock_get_system.assert_called_with(task.node)
|
||||||
self.assertNotIn('redfish_boot_device',
|
self.assertNotIn('redfish_boot_device',
|
||||||
task.node.driver_internal_info)
|
task.node.driver_internal_info)
|
||||||
|
|
||||||
|
@ -126,9 +128,11 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||||
task.driver.management.set_boot_device(
|
task.driver.management.set_boot_device(
|
||||||
task, boot_devices.PXE, persistent=target)
|
task, boot_devices.PXE, persistent=target)
|
||||||
|
|
||||||
fake_system.set_system_boot_options.assert_called_once_with(
|
fake_system.set_system_boot_options.assert_has_calls(
|
||||||
sushy.BOOT_SOURCE_TARGET_PXE, enabled=expected)
|
[mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
|
||||||
mock_get_system.assert_called_once_with(task.node)
|
enabled=expected),
|
||||||
|
mock.call(mode=sushy.BOOT_SOURCE_MODE_BIOS)])
|
||||||
|
mock_get_system.assert_called_with(task.node)
|
||||||
self.assertNotIn('redfish_boot_device',
|
self.assertNotIn('redfish_boot_device',
|
||||||
task.node.driver_internal_info)
|
task.node.driver_internal_info)
|
||||||
|
|
||||||
|
@ -153,9 +157,10 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||||
task.driver.management.set_boot_device(
|
task.driver.management.set_boot_device(
|
||||||
task, boot_devices.PXE, persistent=target)
|
task, boot_devices.PXE, persistent=target)
|
||||||
|
|
||||||
fake_system.set_system_boot_options.assert_called_once_with(
|
fake_system.set_system_boot_options.assert_has_calls(
|
||||||
sushy.BOOT_SOURCE_TARGET_PXE, enabled=None)
|
[mock.call(sushy.BOOT_SOURCE_TARGET_PXE, enabled=None),
|
||||||
mock_get_system.assert_called_once_with(task.node)
|
mock.call(mode=sushy.BOOT_SOURCE_MODE_BIOS)])
|
||||||
|
mock_get_system.assert_called_with(task.node)
|
||||||
|
|
||||||
# Reset mocks
|
# Reset mocks
|
||||||
fake_system.set_system_boot_options.reset_mock()
|
fake_system.set_system_boot_options.reset_mock()
|
||||||
|
@ -220,6 +225,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||||
fake_system.set_system_boot_options.side_effect = [
|
fake_system.set_system_boot_options.side_effect = [
|
||||||
sushy.exceptions.SushyError(),
|
sushy.exceptions.SushyError(),
|
||||||
None,
|
None,
|
||||||
|
None
|
||||||
]
|
]
|
||||||
mock_get_system.return_value = fake_system
|
mock_get_system.return_value = fake_system
|
||||||
with task_manager.acquire(self.context, self.node.uuid,
|
with task_manager.acquire(self.context, self.node.uuid,
|
||||||
|
@ -230,9 +236,9 @@ class RedfishManagementTestCase(db_base.DbTestCase):
|
||||||
mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
|
mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
|
||||||
enabled=sushy.BOOT_SOURCE_ENABLED_CONTINUOUS),
|
enabled=sushy.BOOT_SOURCE_ENABLED_CONTINUOUS),
|
||||||
mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
|
mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
|
||||||
enabled=sushy.BOOT_SOURCE_ENABLED_ONCE),
|
enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
|
||||||
])
|
])
|
||||||
mock_get_system.assert_called_once_with(task.node)
|
mock_get_system.assert_called_with(task.node)
|
||||||
|
|
||||||
task.node.refresh()
|
task.node.refresh()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
After changing the boot device via Redfish, check that the boot mode being
|
||||||
|
reported matches what is configured and, if not, set it to the configured
|
||||||
|
value. Some BMCs change the boot mode when the device is
|
||||||
|
set via Redfish, see `story 2008252
|
||||||
|
<https://storyboard.openstack.org/#!/story/2008252>`__ for details.
|
Loading…
Reference in New Issue