From 07215853b3206ec82905e1793a8f74170b12efa2 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 16 Jul 2013 20:05:24 -0400 Subject: [PATCH] Installer: Drop hard to manage install_bootconfig --- tests/utils.py | 5 ++--- tests/xmlconfig.py | 7 +++---- virtinst/DistroInstaller.py | 8 ++++---- virtinst/Installer.py | 41 ++++++++++++++++++++++--------------- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 93a048b6..82dcf07c 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -184,9 +184,8 @@ def get_basic_paravirt_guest(installer=None): if installer: g.installer = installer else: - instboot = getattr(g.installer, "_install_bootconfig") - instboot.kernel = "/boot/vmlinuz" - instboot.initrd = "/boot/initrd" + g.installer._install_kernel = "/boot/vmlinuz" + g.installer._install_initrd = "/boot/initrd" g.installer._scratchdir = scratch g.add_default_input_device() diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py index 20f38304..f760c962 100644 --- a/tests/xmlconfig.py +++ b/tests/xmlconfig.py @@ -99,10 +99,9 @@ class TestXMLConfig(unittest.TestCase): dom.destroy() # Replace kernel/initrd with known info - if (guest.installer._install_bootconfig and - guest.installer._install_bootconfig.kernel): - guest.installer._install_bootconfig.kernel = "kernel" - guest.installer._install_bootconfig.initrd = "initrd" + if guest.installer._install_kernel: + guest.installer._install_kernel = "kernel" + guest.installer._install_initrd = "initrd" xmlinst = guest.get_xml_config(True, False) xmlboot = guest.get_xml_config(False, False) diff --git a/virtinst/DistroInstaller.py b/virtinst/DistroInstaller.py index 85efa73b..546fd019 100644 --- a/virtinst/DistroInstaller.py +++ b/virtinst/DistroInstaller.py @@ -282,7 +282,7 @@ class DistroInstaller(Installer.Installer): disk.transient = True # Make sure we always fetch kernel here if required - if self._install_bootconfig.kernel and not self.scratchdir_required(): + if self._install_kernel and not self.scratchdir_required(): return disk # Need to fetch the kernel & initrd from a remote site, or @@ -315,9 +315,9 @@ class DistroInstaller(Installer.Installer): meter, kernelfn, initrdfn) self._tmpvols += tmpvols - self._install_bootconfig.kernel = kernelfn - self._install_bootconfig.initrd = initrdfn - self._install_bootconfig.kernel_args = args + self._install_kernel = kernelfn + self._install_initrd = initrdfn + self._install_args = args return disk diff --git a/virtinst/Installer.py b/virtinst/Installer.py index b3037fef..49d73f20 100644 --- a/virtinst/Installer.py +++ b/virtinst/Installer.py @@ -74,8 +74,11 @@ class Installer(XMLBuilder): self._machine = None self._loader = None self._init = None - self._install_bootconfig = Boot(self.conn) - self._bootconfig = Boot(self.conn, parsexml, parsexmlnode) + self.bootconfig = Boot(self.conn, parsexml, parsexmlnode) + + self._install_kernel = None + self._install_initrd = None + self._install_args = None # Devices created/added during the prepare() stage self.install_devices = [] @@ -95,10 +98,6 @@ class Installer(XMLBuilder): # XML related props # ##################### - def _get_bootconfig(self): - return self._bootconfig - bootconfig = property(_get_bootconfig) - # Hypervisor name (qemu, kvm, xen, lxc, etc.) def get_type(self): return self._type @@ -187,9 +186,9 @@ class Installer(XMLBuilder): initrd_injections = property(get_initrd_injections, set_initrd_injections) def get_extra_args(self): - return self._install_bootconfig.kernel_args + return self._install_args def set_extra_args(self, val): - self._install_bootconfig.kernel_args = val + self._install_args = val extraargs = property(get_extra_args, set_extra_args) @@ -223,7 +222,12 @@ class Installer(XMLBuilder): return scratch def _build_boot_order(self, isinstall, guest): - bootorder = [self._get_bootdev(isinstall, guest)] + bootdev = self._get_bootdev(isinstall, guest) + if bootdev is None: + # None here means 'kernel boot' + return [] + + bootorder = [bootdev] # If guest has an attached disk, always have 'hd' in the boot # list, so disks are marked as bootable/installable (needed for @@ -316,20 +320,24 @@ class Installer(XMLBuilder): """ # pylint: disable=W0221 # Argument number differs from overridden method - - if isinstall: - bootconfig = self._install_bootconfig - else: - bootconfig = self.bootconfig - if isinstall and not self.has_install_phase(): return + bootconfig = self.bootconfig.copy() bootorder = self._build_boot_order(isinstall, guest) - bootconfig = copy.copy(bootconfig) + if not bootconfig.bootorder: bootconfig.bootorder = bootorder + if isinstall: + bootconfig = bootconfig.copy() + if self._install_kernel: + bootconfig.kernel = self._install_kernel + if self._install_initrd: + bootconfig.initrd = self._install_initrd + if self._install_args: + bootconfig.kernel_args = self._install_args + return self._get_osblob_helper(guest, isinstall, bootconfig) @@ -442,7 +450,6 @@ class Installer(XMLBuilder): class ContainerInstaller(Installer): _has_install_phase = False - def _get_bootdev(self, isinstall, guest): ignore = isinstall ignore = guest