mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
virtinst: Move PXE, Import, and LiveCD installer to Installer.py
They are all trivial classes, no need to track in separate files.
This commit is contained in:
parent
20a0083635
commit
77c044932c
@ -1,54 +0,0 @@
|
||||
#
|
||||
# Copyright 2009 Red Hat, Inc.
|
||||
# Cole Robinson <crobinso@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
|
||||
from virtinst import Installer
|
||||
from virtinst.VirtualDisk import VirtualDisk
|
||||
|
||||
|
||||
class ImportInstaller(Installer.Installer):
|
||||
"""
|
||||
Create a Guest around an existing disk device, and perform no 'install'
|
||||
stage.
|
||||
|
||||
ImportInstaller sets the Guest's boot device to that of the first disk
|
||||
attached to the Guest (so, one of 'hd', 'cdrom', or 'fd'). All the
|
||||
user has to do is fill in the Guest object with the desired parameters.
|
||||
"""
|
||||
_has_install_phase = False
|
||||
|
||||
# General Installer methods
|
||||
def prepare(self, guest, meter):
|
||||
pass
|
||||
|
||||
# Private methods
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
disks = guest.get_devices("disk")
|
||||
if not disks:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
return self._disk_to_bootdev(disks[0])
|
||||
|
||||
def _disk_to_bootdev(self, disk):
|
||||
if disk.device == VirtualDisk.DEVICE_DISK:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
elif disk.device == VirtualDisk.DEVICE_CDROM:
|
||||
return self.bootconfig.BOOT_DEVICE_CDROM
|
||||
elif disk.device == VirtualDisk.DEVICE_FLOPPY:
|
||||
return self.bootconfig.BOOT_DEVICE_FLOPPY
|
||||
else:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
@ -391,7 +391,7 @@ class Installer(XMLBuilder):
|
||||
@param meter: progress meter
|
||||
@type meter: Urlgrabber ProgressMeter
|
||||
"""
|
||||
raise NotImplementedError("Must be implemented in subclass")
|
||||
pass
|
||||
|
||||
def detect_distro(self):
|
||||
"""
|
||||
@ -433,11 +433,74 @@ class Installer(XMLBuilder):
|
||||
class ContainerInstaller(Installer):
|
||||
_has_install_phase = False
|
||||
|
||||
def prepare(self, guest, meter):
|
||||
ignore = guest
|
||||
ignore = meter
|
||||
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
ignore = isinstall
|
||||
ignore = guest
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
|
||||
|
||||
class PXEInstaller(Installer):
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
bootdev = self.bootconfig.BOOT_DEVICE_NETWORK
|
||||
|
||||
if (not isinstall and
|
||||
[d for d in guest.get_devices("disk") if
|
||||
d.device == d.DEVICE_DISK]):
|
||||
# If doing post-install boot and guest has an HD attached
|
||||
bootdev = self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
|
||||
return bootdev
|
||||
|
||||
|
||||
class LiveCDInstaller(Installer):
|
||||
_has_install_phase = False
|
||||
|
||||
def _validate_location(self, val):
|
||||
if not val:
|
||||
return None
|
||||
return self._make_cdrom_dev(val)
|
||||
def _get_location(self):
|
||||
return self._location
|
||||
def _set_location(self, val):
|
||||
self._validate_location(val)
|
||||
self._location = val
|
||||
self.cdrom = True
|
||||
location = property(_get_location, _set_location)
|
||||
|
||||
|
||||
# General Installer methods
|
||||
def prepare(self, guest, meter):
|
||||
self.cleanup()
|
||||
|
||||
disk = self._validate_location(self.location)
|
||||
|
||||
if not disk:
|
||||
raise ValueError(_("CDROM media must be specified for the live "
|
||||
"CD installer."))
|
||||
|
||||
self.install_devices.append(disk)
|
||||
|
||||
# Internal methods
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
return self.bootconfig.BOOT_DEVICE_CDROM
|
||||
|
||||
|
||||
class ImportInstaller(Installer):
|
||||
_has_install_phase = False
|
||||
|
||||
# Private methods
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
disks = guest.get_devices("disk")
|
||||
if not disks:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
return self._disk_to_bootdev(disks[0])
|
||||
|
||||
def _disk_to_bootdev(self, disk):
|
||||
if disk.device == virtinst.VirtualDisk.DEVICE_DISK:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
elif disk.device == virtinst.VirtualDisk.DEVICE_CDROM:
|
||||
return self.bootconfig.BOOT_DEVICE_CDROM
|
||||
elif disk.device == virtinst.VirtualDisk.DEVICE_FLOPPY:
|
||||
return self.bootconfig.BOOT_DEVICE_FLOPPY
|
||||
else:
|
||||
return self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
|
@ -1,57 +0,0 @@
|
||||
#
|
||||
# An installer class for LiveCD images
|
||||
#
|
||||
# Copyright 2007 Red Hat, Inc.
|
||||
# Mark McLoughlin <markmc@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
|
||||
from virtinst import Installer
|
||||
|
||||
|
||||
class LiveCDInstaller(Installer.Installer):
|
||||
_has_install_phase = False
|
||||
|
||||
|
||||
# LiveCD specific methods/overwrites
|
||||
def _validate_location(self, val):
|
||||
if not val:
|
||||
return None
|
||||
return self._make_cdrom_dev(val)
|
||||
def _get_location(self):
|
||||
return self._location
|
||||
def _set_location(self, val):
|
||||
self._validate_location(val)
|
||||
self._location = val
|
||||
self.cdrom = True
|
||||
location = property(_get_location, _set_location)
|
||||
|
||||
|
||||
# General Installer methods
|
||||
def prepare(self, guest, meter):
|
||||
self.cleanup()
|
||||
|
||||
disk = self._validate_location(self.location)
|
||||
|
||||
if not disk:
|
||||
raise ValueError(_("CDROM media must be specified for the live "
|
||||
"CD installer."))
|
||||
|
||||
self.install_devices.append(disk)
|
||||
|
||||
# Internal methods
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
return self.bootconfig.BOOT_DEVICE_CDROM
|
@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright 2006-2009 Red Hat, Inc.
|
||||
# Daniel P. Berrange <berrange@redhat.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA.
|
||||
|
||||
from virtinst import Installer
|
||||
|
||||
|
||||
class PXEInstaller(Installer.Installer):
|
||||
|
||||
# General Installer methods
|
||||
def prepare(self, guest, meter):
|
||||
pass
|
||||
|
||||
# Internal methods
|
||||
def _get_bootdev(self, isinstall, guest):
|
||||
bootdev = self.bootconfig.BOOT_DEVICE_NETWORK
|
||||
|
||||
if (not isinstall and
|
||||
[d for d in guest.get_devices("disk") if
|
||||
d.device == d.DEVICE_DISK]):
|
||||
# If doing post-install boot and guest has an HD attached
|
||||
bootdev = self.bootconfig.BOOT_DEVICE_HARDDISK
|
||||
|
||||
return bootdev
|
@ -41,11 +41,9 @@ from virtinst.VirtualRedirDevice import VirtualRedirDevice
|
||||
from virtinst.VirtualMemballoon import VirtualMemballoon
|
||||
from virtinst.VirtualTPMDevice import VirtualTPMDevice
|
||||
from virtinst.DistroInstaller import DistroInstaller
|
||||
from virtinst.PXEInstaller import PXEInstaller
|
||||
from virtinst.LiveCDInstaller import LiveCDInstaller
|
||||
from virtinst.ImportInstaller import ImportInstaller
|
||||
from virtinst.ImageInstaller import ImageInstaller
|
||||
from virtinst.Installer import ContainerInstaller
|
||||
from virtinst.Installer import (ContainerInstaller, ImportInstaller,
|
||||
LiveCDInstaller, PXEInstaller)
|
||||
from virtinst.CloneManager import Cloner
|
||||
from virtinst.Clock import Clock
|
||||
from virtinst.CPU import CPU, CPUFeature
|
||||
|
Loading…
Reference in New Issue
Block a user