Build UEFI-only ISO for UEFI boot

This change makes ironic building UEFI-only bootable
ISO image (when being asked to build a UEFI-bootable image)
rather than building a hybrid BIOS/UEFI-bootable ISO.

The motivation behind this change is to make node boot more
predicable in the sense that if the user asks for UEFI boot,
the node would either boot over UEFI or fail.

On top of that, the ISO image slims down a tad bit and syslinux
boot loader presence on the conductor machine is not a
requirement any more.

Change-Id: If7828f72724cc7532f97cab758a29a9e8345850e
Story: 1526753
Task: 28368
This commit is contained in:
Ilya Etingof 2018-12-10 14:35:42 +01:00 committed by Julia Kreger
parent de92b40588
commit 4008c9bfa4
3 changed files with 12 additions and 29 deletions

View File

@ -243,17 +243,12 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
:raises: ImageCreationFailed, if image creation failed while copying files :raises: ImageCreationFailed, if image creation failed while copying files
or while running command to generate iso. or while running command to generate iso.
""" """
ISOLINUX_BIN = 'isolinux/isolinux.bin'
ISOLINUX_CFG = 'isolinux/isolinux.cfg'
isolinux_options = {'kernel': '/vmlinuz', 'ramdisk': '/initrd'}
grub_options = {'linux': '/vmlinuz', 'initrd': '/initrd'} grub_options = {'linux': '/vmlinuz', 'initrd': '/initrd'}
with utils.tempdir() as tmpdir: with utils.tempdir() as tmpdir:
files_info = { files_info = {
kernel: 'vmlinuz', kernel: 'vmlinuz',
ramdisk: 'initrd', ramdisk: 'initrd',
CONF.isolinux_bin: ISOLINUX_BIN,
} }
# Open the deploy iso used to initiate deploy and copy the # Open the deploy iso used to initiate deploy and copy the
@ -274,12 +269,6 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
finally: finally:
_umount_without_raise(mountdir) _umount_without_raise(mountdir)
cfg = _generate_cfg(kernel_params,
CONF.isolinux_config_template, isolinux_options)
isolinux_cfg = os.path.join(tmpdir, ISOLINUX_CFG)
utils.write_to_file(isolinux_cfg, cfg)
# Generate and copy grub config file. # Generate and copy grub config file.
grub_cfg = os.path.join(tmpdir, grub_rel_path) grub_cfg = os.path.join(tmpdir, grub_rel_path)
grub_conf = _generate_cfg(kernel_params, grub_conf = _generate_cfg(kernel_params,
@ -288,12 +277,10 @@ def create_isolinux_image_for_uefi(output_file, deploy_iso, kernel, ramdisk,
# Create the boot_iso. # Create the boot_iso.
try: try:
utils.execute('mkisofs', '-r', '-V', "VMEDIA_BOOT_ISO", utils.execute('mkisofs', '-r', '-V', "VMEDIA_BOOT_ISO", '-l',
'-cache-inodes', '-J', '-l', '-no-emul-boot',
'-boot-load-size', '4', '-boot-info-table',
'-b', ISOLINUX_BIN, '-eltorito-alt-boot',
'-e', e_img_rel_path, '-no-emul-boot', '-e', e_img_rel_path, '-no-emul-boot',
'-o', output_file, tmpdir) '-o', output_file, tmpdir)
except processutils.ProcessExecutionError as e: except processutils.ProcessExecutionError as e:
LOG.exception("Creating ISO image failed.") LOG.exception("Creating ISO image failed.")
raise exception.ImageCreationFailed(image_type='iso', error=e) raise exception.ImageCreationFailed(image_type='iso', error=e)

View File

@ -496,19 +496,14 @@ class FsImageTestCase(base.TestCase):
files_info = { files_info = {
'path/to/kernel': 'vmlinuz', 'path/to/kernel': 'vmlinuz',
'path/to/ramdisk': 'initrd', 'path/to/ramdisk': 'initrd',
CONF.isolinux_bin: 'isolinux/isolinux.bin',
'path/to/grub': 'relpath/to/grub.cfg', 'path/to/grub': 'relpath/to/grub.cfg',
'sourceabspath/to/efiboot.img': 'path/to/efiboot.img' 'sourceabspath/to/efiboot.img': 'path/to/efiboot.img'
} }
cfg = "cfg"
cfg_file = 'tmpdir/isolinux/isolinux.cfg'
grubcfg = "grubcfg" grubcfg = "grubcfg"
grub_file = 'tmpdir/relpath/to/grub.cfg' grub_file = 'tmpdir/relpath/to/grub.cfg'
gen_cfg_mock.side_effect = cfg, grubcfg gen_cfg_mock.side_effect = (grubcfg,)
params = ['a=b', 'c'] params = ['a=b', 'c']
isolinux_options = {'kernel': '/vmlinuz',
'ramdisk': '/initrd'}
grub_options = {'linux': '/vmlinuz', grub_options = {'linux': '/vmlinuz',
'initrd': '/initrd'} 'initrd': '/initrd'}
@ -531,18 +526,12 @@ class FsImageTestCase(base.TestCase):
kernel_params=params) kernel_params=params)
mount_mock.assert_called_once_with('path/to/deploy_iso', 'mountdir') mount_mock.assert_called_once_with('path/to/deploy_iso', 'mountdir')
create_root_fs_mock.assert_called_once_with('tmpdir', files_info) create_root_fs_mock.assert_called_once_with('tmpdir', files_info)
gen_cfg_mock.assert_any_call(params, CONF.isolinux_config_template,
isolinux_options)
write_to_file_mock.assert_any_call(cfg_file, cfg)
gen_cfg_mock.assert_any_call(params, CONF.grub_config_template, gen_cfg_mock.assert_any_call(params, CONF.grub_config_template,
grub_options) grub_options)
write_to_file_mock.assert_any_call(grub_file, grubcfg) write_to_file_mock.assert_any_call(grub_file, grubcfg)
execute_mock.assert_called_once_with( execute_mock.assert_called_once_with(
'mkisofs', '-r', '-V', "VMEDIA_BOOT_ISO", '-cache-inodes', '-J', 'mkisofs', '-r', '-V', 'VMEDIA_BOOT_ISO', '-l', '-e',
'-l', '-no-emul-boot', '-boot-load-size', '4', '-boot-info-table', 'path/to/efiboot.img', '-no-emul-boot', '-o', 'tgt_file', 'tmpdir')
'-b', 'isolinux/isolinux.bin', '-eltorito-alt-boot',
'-e', 'path/to/efiboot.img', '-no-emul-boot',
'-o', 'tgt_file', 'tmpdir')
umount_mock.assert_called_once_with('mountdir') umount_mock.assert_called_once_with('mountdir')
@mock.patch.object(images, '_create_root_fs', autospec=True) @mock.patch.object(images, '_create_root_fs', autospec=True)

View File

@ -0,0 +1,7 @@
---
other:
- |
The Bare Metal service now builds UEFI-only bootable ISO image (when being asked to
build a UEFI-bootable image) rather than building a hybrid
BIOS/UEFI-bootable ISO.