mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 23:23:23 -06:00
installer: Remove ContainerInstaller and ImportInstaller
Fold their non-logic into the base Installer class
This commit is contained in:
parent
0293fa492c
commit
068c8aedd2
13
virt-install
13
virt-install
@ -512,20 +512,19 @@ def build_installer(options, guest):
|
|||||||
cdrom = False
|
cdrom = False
|
||||||
location = None
|
location = None
|
||||||
|
|
||||||
if guest.os.is_container():
|
if (options.cdrom or
|
||||||
instclass = virtinst.ContainerInstaller
|
options.location or
|
||||||
elif (options.cdrom or
|
options.livecd):
|
||||||
options.location or
|
|
||||||
options.livecd):
|
|
||||||
location = options.location or options.cdrom
|
location = options.location or options.cdrom
|
||||||
cdrom = bool(options.cdrom)
|
cdrom = bool(options.cdrom)
|
||||||
instclass = virtinst.DistroInstaller
|
instclass = virtinst.DistroInstaller
|
||||||
elif options.pxe:
|
elif options.pxe:
|
||||||
instclass = virtinst.PXEInstaller
|
instclass = virtinst.PXEInstaller
|
||||||
elif (options.import_install or
|
elif (guest.os.is_container() or
|
||||||
|
options.import_install or
|
||||||
options.xmlonly or
|
options.xmlonly or
|
||||||
options.boot):
|
options.boot):
|
||||||
instclass = virtinst.ImportInstaller
|
instclass = virtinst.Installer
|
||||||
elif implied_cdrom_install(guest):
|
elif implied_cdrom_install(guest):
|
||||||
# Explicit install options always take precedent over this case
|
# Explicit install options always take precedent over this case
|
||||||
cdrom = True
|
cdrom = True
|
||||||
|
@ -1685,7 +1685,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
instclass = virtinst.PXEInstaller
|
instclass = virtinst.PXEInstaller
|
||||||
|
|
||||||
elif instmethod == INSTALL_PAGE_IMPORT:
|
elif instmethod == INSTALL_PAGE_IMPORT:
|
||||||
instclass = virtinst.ImportInstaller
|
instclass = virtinst.Installer
|
||||||
is_import = True
|
is_import = True
|
||||||
|
|
||||||
import_path = self._get_config_import_path()
|
import_path = self._get_config_import_path()
|
||||||
@ -1700,14 +1700,14 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
"an existing storage."))
|
"an existing storage."))
|
||||||
|
|
||||||
elif instmethod == INSTALL_PAGE_CONTAINER_APP:
|
elif instmethod == INSTALL_PAGE_CONTAINER_APP:
|
||||||
instclass = virtinst.ContainerInstaller
|
instclass = virtinst.Installer
|
||||||
|
|
||||||
init = self.widget("install-app-entry").get_text()
|
init = self.widget("install-app-entry").get_text()
|
||||||
if not init:
|
if not init:
|
||||||
return self.err.val_err(_("An application path is required."))
|
return self.err.val_err(_("An application path is required."))
|
||||||
|
|
||||||
elif instmethod == INSTALL_PAGE_CONTAINER_OS:
|
elif instmethod == INSTALL_PAGE_CONTAINER_OS:
|
||||||
instclass = virtinst.ContainerInstaller
|
instclass = virtinst.Installer
|
||||||
|
|
||||||
fs = self.widget("install-oscontainer-fs").get_text()
|
fs = self.widget("install-oscontainer-fs").get_text()
|
||||||
if not fs:
|
if not fs:
|
||||||
@ -1748,7 +1748,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
|
|
||||||
|
|
||||||
elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
|
elif instmethod == INSTALL_PAGE_VZ_TEMPLATE:
|
||||||
instclass = virtinst.ContainerInstaller
|
instclass = virtinst.Installer
|
||||||
template = self.widget("install-container-template").get_text()
|
template = self.widget("install-container-template").get_text()
|
||||||
if not template:
|
if not template:
|
||||||
return self.err.val_err(_("A template name is required."))
|
return self.err.val_err(_("A template name is required."))
|
||||||
|
@ -234,7 +234,7 @@ def _import_file(conn, input_file):
|
|||||||
|
|
||||||
# Generate the Guest
|
# Generate the Guest
|
||||||
guest = conn.caps.lookup_virtinst_guest()
|
guest = conn.caps.lookup_virtinst_guest()
|
||||||
guest.installer = virtinst.ImportInstaller(conn)
|
guest.installer = virtinst.Installer(conn)
|
||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
name = os.path.basename(input_file)
|
name = os.path.basename(input_file)
|
||||||
|
@ -285,7 +285,7 @@ class vmx_parser(parser_class):
|
|||||||
disk.path = None
|
disk.path = None
|
||||||
|
|
||||||
guest = conn.caps.lookup_virtinst_guest()
|
guest = conn.caps.lookup_virtinst_guest()
|
||||||
guest.installer = virtinst.ImportInstaller(conn)
|
guest.installer = virtinst.Installer(conn)
|
||||||
|
|
||||||
guest.name = name.replace(" ", "_")
|
guest.name = name.replace(" ", "_")
|
||||||
guest.description = desc or None
|
guest.description = desc or None
|
||||||
|
@ -39,8 +39,7 @@ from virtinst.storage import StoragePool, StorageVolume
|
|||||||
|
|
||||||
from virtinst.devices import * # pylint: disable=wildcard-import
|
from virtinst.devices import * # pylint: disable=wildcard-import
|
||||||
|
|
||||||
from virtinst.installer import (ContainerInstaller, ImportInstaller,
|
from virtinst.installer import PXEInstaller, Installer
|
||||||
PXEInstaller, Installer)
|
|
||||||
|
|
||||||
from virtinst.distroinstaller import DistroInstaller
|
from virtinst.distroinstaller import DistroInstaller
|
||||||
|
|
||||||
|
@ -39,8 +39,6 @@ class Installer(object):
|
|||||||
- Hypervisor name (parameter 'type') ('qemu', 'kvm', 'xen', etc.)
|
- Hypervisor name (parameter 'type') ('qemu', 'kvm', 'xen', etc.)
|
||||||
- Guest architecture ('i686', 'x86_64')
|
- Guest architecture ('i686', 'x86_64')
|
||||||
"""
|
"""
|
||||||
_has_install_phase = True
|
|
||||||
|
|
||||||
def __init__(self, conn):
|
def __init__(self, conn):
|
||||||
self.conn = conn
|
self.conn = conn
|
||||||
self._location = None
|
self._location = None
|
||||||
@ -122,7 +120,15 @@ class Installer(object):
|
|||||||
##########################
|
##########################
|
||||||
|
|
||||||
def _get_bootdev(self, isinstall, guest):
|
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):
|
def _validate_location(self, val):
|
||||||
return val
|
return val
|
||||||
@ -150,7 +156,7 @@ class Installer(object):
|
|||||||
into the guest. Things like LiveCDs, Import, or a manually specified
|
into the guest. Things like LiveCDs, Import, or a manually specified
|
||||||
bootorder do not have an install phase.
|
bootorder do not have an install phase.
|
||||||
"""
|
"""
|
||||||
return self._has_install_phase
|
return False
|
||||||
|
|
||||||
def needs_cdrom(self):
|
def needs_cdrom(self):
|
||||||
"""
|
"""
|
||||||
@ -209,14 +215,6 @@ class Installer(object):
|
|||||||
return None
|
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):
|
class PXEInstaller(Installer):
|
||||||
def _get_bootdev(self, isinstall, guest):
|
def _get_bootdev(self, isinstall, guest):
|
||||||
bootdev = DomainOs.BOOT_DEVICE_NETWORK
|
bootdev = DomainOs.BOOT_DEVICE_NETWORK
|
||||||
@ -229,23 +227,5 @@ class PXEInstaller(Installer):
|
|||||||
|
|
||||||
return bootdev
|
return bootdev
|
||||||
|
|
||||||
|
def has_install_phase(self):
|
||||||
class ImportInstaller(Installer):
|
return True
|
||||||
_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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user