diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index 3b9d93b3005..2a2767edc4d 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -244,7 +244,7 @@ def _replace_boot_line(path, boot_mode, is_whole_disk_image, else: boot_disk_type = 'boot_partition' - if boot_mode == 'uefi': + if boot_mode == 'uefi' and not CONF.pxe.ipxe_enabled: pattern = '^((set )?default)=.*$' boot_line = '\\1=%s' % boot_disk_type else: diff --git a/ironic/drivers/modules/ipxe_config.template b/ironic/drivers/modules/ipxe_config.template index 1254310bdb3..f3aa6cf74ef 100644 --- a/ironic/drivers/modules/ipxe_config.template +++ b/ironic/drivers/modules/ipxe_config.template @@ -11,7 +11,7 @@ initrd {{ pxe_options.deployment_ari_path }} boot :boot_partition -kernel {{ pxe_options.aki_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }} +kernel {{ pxe_options.aki_path }} root={{ ROOT }} ro text {{ pxe_options.pxe_append_params|default("", true) }} initrd=ramdisk initrd {{ pxe_options.ari_path }} boot diff --git a/ironic/tests/unit/drivers/ipxe_config.template b/ironic/tests/unit/drivers/ipxe_config.template index 5dbf2747dc4..1cf92bec529 100644 --- a/ironic/tests/unit/drivers/ipxe_config.template +++ b/ironic/tests/unit/drivers/ipxe_config.template @@ -11,7 +11,7 @@ initrd http://1.2.3.4:1234/deploy_ramdisk boot :boot_partition -kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param +kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk initrd http://1.2.3.4:1234/ramdisk boot diff --git a/ironic/tests/unit/drivers/ipxe_uefi_config.template b/ironic/tests/unit/drivers/ipxe_uefi_config.template index b4471c1ed63..6ad55a76b29 100644 --- a/ironic/tests/unit/drivers/ipxe_uefi_config.template +++ b/ironic/tests/unit/drivers/ipxe_uefi_config.template @@ -11,7 +11,7 @@ initrd http://1.2.3.4:1234/deploy_ramdisk boot :boot_partition -kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param +kernel http://1.2.3.4:1234/kernel root={{ ROOT }} ro text test_param initrd=ramdisk initrd http://1.2.3.4:1234/ramdisk boot diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index 5c4fc56ada9..67fa37bab0f 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -1049,7 +1049,7 @@ class SwitchPxeConfigTestCase(tests_base.TestCase): def _create_config(self, ipxe=False, boot_mode=None, boot_loader='elilo'): (fd, fname) = tempfile.mkstemp() - if boot_mode == 'uefi': + if boot_mode == 'uefi' and not ipxe: if boot_loader == 'grub': pxe_cfg = _UEFI_PXECONF_DEPLOY_GRUB else: @@ -1162,6 +1162,30 @@ class SwitchPxeConfigTestCase(tests_base.TestCase): pxeconf = f.read() self.assertEqual(_UEFI_PXECONF_BOOT_WHOLE_DISK_GRUB, pxeconf) + def test_switch_uefi_ipxe_config_partition_image(self): + boot_mode = 'uefi' + cfg.CONF.set_override('ipxe_enabled', True, 'pxe') + fname = self._create_config(boot_mode=boot_mode, ipxe=True) + utils.switch_pxe_config(fname, + '12345678-1234-1234-1234-1234567890abcdef', + boot_mode, + False) + with open(fname, 'r') as f: + pxeconf = f.read() + self.assertEqual(_IPXECONF_BOOT_PARTITION, pxeconf) + + def test_switch_uefi_ipxe_config_whole_disk_image(self): + boot_mode = 'uefi' + cfg.CONF.set_override('ipxe_enabled', True, 'pxe') + fname = self._create_config(boot_mode=boot_mode, ipxe=True) + utils.switch_pxe_config(fname, + '0x12345678', + boot_mode, + True) + with open(fname, 'r') as f: + pxeconf = f.read() + self.assertEqual(_IPXECONF_BOOT_WHOLE_DISK, pxeconf) + @mock.patch('time.sleep', lambda sec: None) class OtherFunctionTestCase(db_base.DbTestCase): diff --git a/releasenotes/notes/ipxe-uefi-f5be11c7b0606a84.yaml b/releasenotes/notes/ipxe-uefi-f5be11c7b0606a84.yaml new file mode 100644 index 00000000000..53d2196f655 --- /dev/null +++ b/releasenotes/notes/ipxe-uefi-f5be11c7b0606a84.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - Fixes bug where ironic reboots the node + with deploy image instead of the user image + during second reboot in uefi boot mode when + ipxe is enabled.