Merge "Handle default_boot_mode during cleaning/inspection with PXE/iPXE"

This commit is contained in:
Zuul 2020-09-11 21:40:46 +00:00 committed by Gerrit Code Review
commit 235506b001
5 changed files with 26 additions and 5 deletions

View File

@ -284,7 +284,8 @@ def get_boot_mode(node):
return boot_mode
# TODO(hshiina): The default boot mode will be changed to UEFI.
global warn_about_default_boot_mode
if not warn_about_default_boot_mode:
if (not warn_about_default_boot_mode
and CONF.deploy.default_boot_mode == boot_modes.LEGACY_BIOS):
warn_about_default_boot_mode = True
LOG.warning('Boot mode is not configured for node %(node_uuid)s '
'explicitly. The default boot mode is "%(bios)s", but, '
@ -294,4 +295,4 @@ def get_boot_mode(node):
{'node_uuid': node.uuid,
'bios': boot_modes.LEGACY_BIOS,
'uefi': boot_modes.UEFI})
return boot_modes.LEGACY_BIOS
return CONF.deploy.default_boot_mode

View File

@ -191,7 +191,8 @@ class PXEBaseMixin(object):
pxe_info.update(
pxe_utils.get_instance_image_info(
task, ipxe_enabled=self.ipxe_enabled))
boot_mode_utils.sync_boot_mode(task)
boot_mode_utils.sync_boot_mode(task)
pxe_options = pxe_utils.build_pxe_config_options(
task, pxe_info, ipxe_enabled=self.ipxe_enabled,

View File

@ -53,3 +53,14 @@ class GetBootModeTestCase(tests_base.TestCase):
boot_mode = boot_mode_utils.get_boot_mode(self.node)
self.assertEqual(boot_modes.LEGACY_BIOS, boot_mode)
self.assertEqual(1, mock_log.warning.call_count)
@mock.patch.object(boot_mode_utils, 'LOG', autospec=True)
@mock.patch.object(boot_mode_utils, 'get_boot_mode_for_deploy',
autospec=True)
def test_get_boot_mode_default_set(self, mock_for_deploy, mock_log):
self.config(default_boot_mode='uefi', group='deploy')
boot_mode_utils.warn_about_default_boot_mode = False
mock_for_deploy.return_value = None
boot_mode = boot_mode_utils.get_boot_mode(self.node)
self.assertEqual(boot_modes.UEFI, boot_mode)
self.assertEqual(0, mock_log.warning.call_count)

View File

@ -276,8 +276,7 @@ class PXEBootTestCase(db_base.DbTestCase):
mode=mode,
ipxe_enabled=False)
provider_mock.update_dhcp.assert_called_once_with(task, dhcp_opts)
if self.node.provision_state == states.DEPLOYING:
get_boot_mode_mock.assert_called_once_with(task)
get_boot_mode_mock.assert_called_once_with(task)
set_boot_device_mock.assert_called_once_with(task,
boot_devices.PXE,
persistent=persistent)

View File

@ -0,0 +1,9 @@
---
fixes:
- |
Fixes cleaning and managed inspection not respecting the
``default_boot_mode`` configuration option.
- |
Fixes cleaning and managed inspection not following the standard boot
mode handling logic, particularly, not trying to assert the requested
boot mode if the driver allows it.