Fix issues with uefi-ipxe booting

When booting from ipxe in uefi boot mode, once the node boots with deploy
image, ironic is not changing the default menu entry to boot_partition
to boot the instance image during next boot. The current changes fix
the issue. The kernel parameter "initrd=ramdisk" is also added to the ipxe
template which is required for ipxe booting.

Closes-Bug: #1532679
Change-Id: Idf78195d228b4861f85fbcae9a269edd95523ad7
This commit is contained in:
vmud213 2016-01-11 09:47:30 +00:00 committed by Haomeng,Wang
parent 53e5171db1
commit 91906c5928
6 changed files with 35 additions and 5 deletions

View File

@ -244,7 +244,7 @@ def _replace_boot_line(path, boot_mode, is_whole_disk_image,
else: else:
boot_disk_type = 'boot_partition' boot_disk_type = 'boot_partition'
if boot_mode == 'uefi': if boot_mode == 'uefi' and not CONF.pxe.ipxe_enabled:
pattern = '^((set )?default)=.*$' pattern = '^((set )?default)=.*$'
boot_line = '\\1=%s' % boot_disk_type boot_line = '\\1=%s' % boot_disk_type
else: else:

View File

@ -11,7 +11,7 @@ initrd {{ pxe_options.deployment_ari_path }}
boot boot
:boot_partition :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 }} initrd {{ pxe_options.ari_path }}
boot boot

View File

@ -11,7 +11,7 @@ initrd http://1.2.3.4:1234/deploy_ramdisk
boot boot
:boot_partition :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 initrd http://1.2.3.4:1234/ramdisk
boot boot

View File

@ -11,7 +11,7 @@ initrd http://1.2.3.4:1234/deploy_ramdisk
boot boot
:boot_partition :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 initrd http://1.2.3.4:1234/ramdisk
boot boot

View File

@ -1049,7 +1049,7 @@ class SwitchPxeConfigTestCase(tests_base.TestCase):
def _create_config(self, ipxe=False, boot_mode=None, boot_loader='elilo'): def _create_config(self, ipxe=False, boot_mode=None, boot_loader='elilo'):
(fd, fname) = tempfile.mkstemp() (fd, fname) = tempfile.mkstemp()
if boot_mode == 'uefi': if boot_mode == 'uefi' and not ipxe:
if boot_loader == 'grub': if boot_loader == 'grub':
pxe_cfg = _UEFI_PXECONF_DEPLOY_GRUB pxe_cfg = _UEFI_PXECONF_DEPLOY_GRUB
else: else:
@ -1162,6 +1162,30 @@ class SwitchPxeConfigTestCase(tests_base.TestCase):
pxeconf = f.read() pxeconf = f.read()
self.assertEqual(_UEFI_PXECONF_BOOT_WHOLE_DISK_GRUB, pxeconf) 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) @mock.patch('time.sleep', lambda sec: None)
class OtherFunctionTestCase(db_base.DbTestCase): class OtherFunctionTestCase(db_base.DbTestCase):

View File

@ -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.