diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-05-21 16:05:18 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-05-21 16:05:18 +0300 |
commit | 92aa365f11f0f46e849837b87f5a2e8cb25bee99 (patch) | |
tree | 693dfe73d99fb30a14b7571df249ea1f4da8d3b8 | |
parent | 97650eacd9c40665475b0bbbec2cb6a705741b64 (diff) | |
download | vmdb2-92aa365f11f0f46e849837b87f5a2e8cb25bee99.tar.gz |
Refactor: Make UEFI and BIOS flavor use common code
-rw-r--r-- | vmdb/plugins/grub_plugin.py | 58 |
1 files changed, 16 insertions, 42 deletions
diff --git a/vmdb/plugins/grub_plugin.py b/vmdb/plugins/grub_plugin.py index e9a5928..58af4e0 100644 --- a/vmdb/plugins/grub_plugin.py +++ b/vmdb/plugins/grub_plugin.py @@ -103,57 +103,23 @@ class GrubStepRunner(vmdb.StepRunnerInterface): raise Exception('Unknown GRUB flavor {}'.format(flavor)) def install_uefi(self, step, settings, state): - grub_package = 'grub-efi-amd64' - grub_target = 'x86_64-efi' - - device = step['device'] - - rootfs = step['root-fs'] - chroot = state.mounts[rootfs] - - root_part = step['root-part'] - root_dev = state.parts[root_part] - - efi_part = step['efi-part'] - efi_dev = state.parts[efi_part] + vmdb.progress('Installing GRUB for UEFI') - image_dev = self.get_image_loop_device(root_dev) - - self.bind_mount_many(chroot, ['/dev', '/proc', '/sys'], state) - self.mount(chroot, efi_dev, '/boot/efi', state) + if not 'efi-part' in step: + raise Exception('"efi-part" is required in UEFI GRUB installtion') - self.install_package(chroot, grub_package) - - kernel_params = [ - 'biosdevname=0', - 'net.ifnames=0', - 'consoleblank=0', - 'systemd.show_status=true', - ] - self.set_grub_cmdline_config(chroot, kernel_params) - - self.chroot(chroot, ['grub-mkconfig', '-o', '/boot/grub/grub.cfg']) - self.chroot( - chroot, [ - 'grub-install', - '--target=' + grub_target, - '--no-nvram', - '--force-extra-removable', - '--no-floppy', - '--modules=part_msdos part_gpt', - '--grub-mkdevicemap=/boot/grub/device.map', - image_dev, - ] - ) - - self.unmount(state) + grub_package = 'grub-efi-amd64' + grub_target = 'x86_64-efi' + self.install_grub(step, settings, state, grub_package, grub_target) def install_bios(self, step, settings, state): vmdb.progress('Installing GRUB for BIOS') grub_package = 'grub-pc' grub_target = 'i386-pc' + self.install_grub(step, settings, state, grub_package, grub_target) + def install_grub(self, step, settings, state, grub_package, grub_target): device = step['device'] rootfs = step['root-fs'] @@ -164,7 +130,15 @@ class GrubStepRunner(vmdb.StepRunnerInterface): image_dev = self.get_image_loop_device(root_dev) + if 'efi-part' in step: + efi_part = step['efi-part'] + efi_dev = state.parts[efi_part] + else: + efi_dev = None + self.bind_mount_many(chroot, ['/dev', '/proc', '/sys'], state) + if efi_dev: + self.mount(chroot, efi_dev, '/boot/efi', state) self.install_package(chroot, grub_package) kernel_params = [ |