summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Fournier <bfournie@redhat.com>2020-10-19 14:28:15 -0400
committerJulia Kreger <juliaashleykreger@gmail.com>2020-11-17 15:32:44 -0800
commit64bda92296ebd4481ed81277c9988803097bdf2a (patch)
tree0d70cb84b9219be96710a723b1d034e559f1670d
parent88f1058eeec4c80b3ef2b72443bfc3df81dccc05 (diff)
downloadironic-64bda92296ebd4481ed81277c9988803097bdf2a.tar.gz
Sync boot mode when changing the boot device via Redfish
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, this will ensure the mode is set properly. Change-Id: Ib077f7f32de029833e6bd936853c382305bce36e Story: 2008252 Task: 41103 (cherry picked from commit 685131fd3658b2ff0b131d19d32fd82d74f3bb17) (cherry picked from commit 861e91c8616db39e589589629bd5305909067331) (cherry picked from commit a6f38ab05a64802aec1b17c058e62ce7244e9a81)
-rw-r--r--ironic/drivers/modules/redfish/management.py5
-rw-r--r--ironic/tests/unit/drivers/modules/redfish/test_management.py37
-rw-r--r--releasenotes/notes/sync-boot-mode-after-changing-redfish-device-f60ef90ba5675215.yaml8
3 files changed, 36 insertions, 14 deletions
diff --git a/ironic/drivers/modules/redfish/management.py b/ironic/drivers/modules/redfish/management.py
index d9c418d7a..04e3d96b0 100644
--- a/ironic/drivers/modules/redfish/management.py
+++ b/ironic/drivers/modules/redfish/management.py
@@ -25,6 +25,7 @@ from ironic.common.i18n import _
from ironic.common import utils
from ironic.conductor import task_manager
from ironic.drivers import base
+from ironic.drivers.modules import boot_mode_utils
from ironic.drivers.modules.redfish import utils as redfish_utils
LOG = log.getLogger(__name__)
@@ -215,6 +216,10 @@ class RedfishManagement(base.ManagementInterface):
LOG.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):
"""Get the current boot device for a node.
diff --git a/ironic/tests/unit/drivers/modules/redfish/test_management.py b/ironic/tests/unit/drivers/modules/redfish/test_management.py
index 61b4dc007..5bc5aaf41 100644
--- a/ironic/tests/unit/drivers/modules/redfish/test_management.py
+++ b/ironic/tests/unit/drivers/modules/redfish/test_management.py
@@ -90,9 +90,13 @@ class RedfishManagementTestCase(db_base.DbTestCase):
task.driver.management.set_boot_device(task, target)
# Asserts
- fake_system.set_system_boot_options.assert_called_once_with(
- expected, enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
- mock_get_system.assert_called_once_with(task.node)
+ fake_system.set_system_boot_options.assert_has_calls(
+ [mock.call(expected,
+ 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',
+ task.node.driver_internal_info)
# Reset mocks
fake_system.set_system_boot_options.reset_mock()
@@ -115,9 +119,10 @@ class RedfishManagementTestCase(db_base.DbTestCase):
task.driver.management.set_boot_device(task, target)
# Asserts
- fake_system.set_system_boot_source.assert_called_once_with(
- expected, enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)
- mock_get_system.assert_called_once_with(task.node)
+ fake_system.set_system_boot_source.assert_has_calls([
+ mock.call(expected,
+ enabled=sushy.BOOT_SOURCE_ENABLED_ONCE)])
+ self.assertEqual(3, mock_get_system.call_count)
self.assertNotIn('redfish_boot_device',
task.node.driver_internal_info)
@@ -140,9 +145,11 @@ class RedfishManagementTestCase(db_base.DbTestCase):
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=expected)
- mock_get_system.assert_called_once_with(task.node)
+ fake_system.set_system_boot_options.assert_has_calls(
+ [mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
+ enabled=expected),
+ mock.call(mode=sushy.BOOT_SOURCE_MODE_BIOS)])
+ mock_get_system.assert_called_with(task.node)
self.assertNotIn('redfish_boot_device',
task.node.driver_internal_info)
@@ -167,9 +174,10 @@ class RedfishManagementTestCase(db_base.DbTestCase):
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)
+ fake_system.set_system_boot_options.assert_has_calls(
+ [mock.call(sushy.BOOT_SOURCE_TARGET_PXE, enabled=None),
+ mock.call(mode=sushy.BOOT_SOURCE_MODE_BIOS)])
+ mock_get_system.assert_called_with(task.node)
# Reset mocks
fake_system.set_system_boot_options.reset_mock()
@@ -234,6 +242,7 @@ class RedfishManagementTestCase(db_base.DbTestCase):
fake_system.set_system_boot_options.side_effect = [
sushy.exceptions.SushyError(),
None,
+ None
]
mock_get_system.return_value = fake_system
with task_manager.acquire(self.context, self.node.uuid,
@@ -244,9 +253,9 @@ class RedfishManagementTestCase(db_base.DbTestCase):
mock.call(sushy.BOOT_SOURCE_TARGET_PXE,
enabled=sushy.BOOT_SOURCE_ENABLED_CONTINUOUS),
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()
self.assertEqual(
diff --git a/releasenotes/notes/sync-boot-mode-after-changing-redfish-device-f60ef90ba5675215.yaml b/releasenotes/notes/sync-boot-mode-after-changing-redfish-device-f60ef90ba5675215.yaml
new file mode 100644
index 000000000..629d9527c
--- /dev/null
+++ b/releasenotes/notes/sync-boot-mode-after-changing-redfish-device-f60ef90ba5675215.yaml
@@ -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.