installer: Remove ContainerInstaller and ImportInstaller

Fold their non-logic into the base Installer class
This commit is contained in:
Cole Robinson 2018-09-03 10:58:25 -04:00
parent 0293fa492c
commit 068c8aedd2
6 changed files with 25 additions and 47 deletions

View File

@ -512,20 +512,19 @@ def build_installer(options, guest):
cdrom = False
location = None
if guest.os.is_container():
instclass = virtinst.ContainerInstaller
elif (options.cdrom or
options.location or
options.livecd):
if (options.cdrom or
options.location or
options.livecd):
location = options.location or options.cdrom
cdrom = bool(options.cdrom)
instclass = virtinst.DistroInstaller
elif options.pxe:
instclass = virtinst.PXEInstaller
elif (options.import_install or
elif (guest.os.is_container() or
options.import_install or
options.xmlonly or
options.boot):
instclass = virtinst.ImportInstaller
instclass = virtinst.Installer
elif implied_cdrom_install(guest):
# Explicit install options always take precedent over this case
cdrom = True

View File

@ -1685,7 +1685,7 @@ class vmmCreate(vmmGObjectUI):
instclass = virtinst.PXEInstaller
elif instmethod == INSTALL_PAGE_IMPORT:
instclass = virtinst.ImportInstaller
instclass = virtinst.Installer
is_import = True
import_path = self._get_config_import_path()
@ -1700,14 +1700,14 @@ class vmmCreate(vmmGObjectUI):
"an existing storage."))
elif instmethod == INSTALL_PAGE_CONTAINER_APP:
instclass = virtinst.ContainerInstaller
instclass = virtinst.Installer
init = self.widget("install-app-entry").get_text()
if not init:
return self.err.val_err(_("An application path is required."))
elif instmethod == INSTALL_PAGE_CONTAINER_OS:
instclass = virtinst.ContainerInstaller
instclass = virtinst.Installer
fs = self.widget("install-oscontainer-fs").get_text()
if not fs:
@ -1748,7 +1748,7 @@ class vmmCreate(vmmGObjectUI):
elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
instclass = virtinst.ContainerInstaller
instclass = virtinst.Installer
template = self.widget("install-container-template").get_text()
if not template:
return self.err.val_err(_("A template name is required."))

View File

@ -234,7 +234,7 @@ def _import_file(conn, input_file):
# Generate the Guest
guest = conn.caps.lookup_virtinst_guest()
guest.installer = virtinst.ImportInstaller(conn)
guest.installer = virtinst.Installer(conn)
if not name:
name = os.path.basename(input_file)

View File

@ -285,7 +285,7 @@ class vmx_parser(parser_class):
disk.path = None
guest = conn.caps.lookup_virtinst_guest()
guest.installer = virtinst.ImportInstaller(conn)
guest.installer = virtinst.Installer(conn)
guest.name = name.replace(" ", "_")
guest.description = desc or None

View File

@ -39,8 +39,7 @@ from virtinst.storage import StoragePool, StorageVolume
from virtinst.devices import * # pylint: disable=wildcard-import
from virtinst.installer import (ContainerInstaller, ImportInstaller,
PXEInstaller, Installer)
from virtinst.installer import PXEInstaller, Installer
from virtinst.distroinstaller import DistroInstaller

View File

@ -39,8 +39,6 @@ class Installer(object):
- Hypervisor name (parameter 'type') ('qemu', 'kvm', 'xen', etc.)
- Guest architecture ('i686', 'x86_64')
"""
_has_install_phase = True
def __init__(self, conn):
self.conn = conn
self._location = None
@ -122,7 +120,15 @@ class Installer(object):
##########################
def _get_bootdev(self, isinstall, guest):
raise NotImplementedError("Must be implemented in subclass")
ignore = isinstall
device = guest.devices.disk and guest.devices.disk[0].device or None
if device == DeviceDisk.DEVICE_DISK:
return DomainOs.BOOT_DEVICE_HARDDISK
elif device == DeviceDisk.DEVICE_CDROM:
return DomainOs.BOOT_DEVICE_CDROM
elif device == DeviceDisk.DEVICE_FLOPPY:
return DomainOs.BOOT_DEVICE_FLOPPY
return DomainOs.BOOT_DEVICE_HARDDISK
def _validate_location(self, val):
return val
@ -150,7 +156,7 @@ class Installer(object):
into the guest. Things like LiveCDs, Import, or a manually specified
bootorder do not have an install phase.
"""
return self._has_install_phase
return False
def needs_cdrom(self):
"""
@ -209,14 +215,6 @@ class Installer(object):
return None
class ContainerInstaller(Installer):
_has_install_phase = False
def _get_bootdev(self, isinstall, guest):
ignore = isinstall
ignore = guest
return DomainOs.BOOT_DEVICE_HARDDISK
class PXEInstaller(Installer):
def _get_bootdev(self, isinstall, guest):
bootdev = DomainOs.BOOT_DEVICE_NETWORK
@ -229,23 +227,5 @@ class PXEInstaller(Installer):
return bootdev
class ImportInstaller(Installer):
_has_install_phase = False
# Private methods
def _get_bootdev(self, isinstall, guest):
disks = guest.devices.disk
if not disks:
return DomainOs.BOOT_DEVICE_HARDDISK
return self._disk_to_bootdev(disks[0])
def _disk_to_bootdev(self, disk):
if disk.device == DeviceDisk.DEVICE_DISK:
return DomainOs.BOOT_DEVICE_HARDDISK
elif disk.device == DeviceDisk.DEVICE_CDROM:
return DomainOs.BOOT_DEVICE_CDROM
elif disk.device == DeviceDisk.DEVICE_FLOPPY:
return DomainOs.BOOT_DEVICE_FLOPPY
else:
return DomainOs.BOOT_DEVICE_HARDDISK
def has_install_phase(self):
return True