[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[et-mgmt-tools] [PATCH 1/2] Add new ImportInstaller class
- From: Cole Robinson <crobinso redhat com>
- To: Fedora/Linux Management Tools <et-mgmt-tools redhat com>
- Subject: [et-mgmt-tools] [PATCH 1/2] Add new ImportInstaller class
- Date: Wed, 18 Feb 2009 21:43:39 -0500
This patch adds a new ImportInstaller class, as well as test suite
changes to exercise the new code.
Thanks,
Cole
# HG changeset patch
# User Cole Robinson <crobinso redhat com>
# Date 1235006163 18000
# Node ID 38db2ccaff913afb4c4ef823e58f2ce7d609b73f
# Parent ef6c4d5ed38687ef5d42eb2a5d1c66edd8c7077a
Add ImportInstaller class.
Used for creating guest xml around an existing disk image. Just uses the
first Guest disk device as the assumed boot device.
diff -r ef6c4d5ed386 -r 38db2ccaff91 tests/pylint-virtinst.sh
--- a/tests/pylint-virtinst.sh Wed Feb 18 19:52:11 2009 -0500
+++ b/tests/pylint-virtinst.sh Wed Feb 18 20:16:03 2009 -0500
@@ -46,7 +46,7 @@
PROT_MEM_BUGS="protected member (_lookup_osdict_key|_OS_TYPES|_prepare_install|_create_devices|_install_disks)"
# Scattered examples of legitimately unused arguments
-UNUSED_ARGS="(SuseDistro|SolarisDistro).isValidStore.*Unused argument 'progresscb'|LiveCDInstaller.prepare.*Unused argument|ImageInstaller.prepare.*Unused argument|post_install_check.*Unused argument 'guest'|Guest.__init__.*Unused argument 'type'"
+UNUSED_ARGS="(SuseDistro|SolarisDistro).isValidStore.*Unused argument 'progresscb'|.*Installer.prepare.*Unused argument|post_install_check.*Unused argument 'guest'|Guest.__init__.*Unused argument 'type'"
# Outside __init__ checks throw false positives with distutils custom commands
# tests.storage also invokes false positives using hasattr
diff -r ef6c4d5ed386 -r 38db2ccaff91 tests/xmlconfig-xml/install-fullyvirt-import.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmlconfig-xml/install-fullyvirt-import.xml Wed Feb 18 20:16:03 2009 -0500
@@ -0,0 +1,29 @@
+<domain type='xen'>
+ <name>TestGuest</name>
+ <currentMemory>204800</currentMemory>
+ <memory>409600</memory>
+ <uuid>12345678-1234-1234-1234-123456789012</uuid>
+ <os>
+ <type arch='i686'>hvm</type>
+ <loader>/usr/lib/xen/boot/hvmloader</loader>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/><apic/>
+ </features>
+ <clock offset="utc"/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <vcpu>5</vcpu>
+ <devices>
+ <emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+ <console type='pty'/>
+ <disk type='file' device='disk'>
+ <source file='/tmp/test.img'/>
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <input type='mouse' bus='ps2'/>
+ <graphics type='sdl' display=':3.4' xauth='/testdir/.Xauthority'/>
+ </devices>
+</domain>
diff -r ef6c4d5ed386 -r 38db2ccaff91 tests/xmlconfig-xml/install-paravirt-import.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/xmlconfig-xml/install-paravirt-import.xml Wed Feb 18 20:16:03 2009 -0500
@@ -0,0 +1,19 @@
+<domain type='xen'>
+ <name>TestGuest</name>
+ <currentMemory>204800</currentMemory>
+ <memory>409600</memory>
+ <uuid>12345678-1234-1234-1234-123456789012</uuid>
+ <bootloader>/usr/bin/pygrub</bootloader>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <vcpu>5</vcpu>
+ <devices>
+ <disk type='file' device='disk'>
+ <source file='/tmp/test.img'/>
+ <target dev='xvda' bus='xen'/>
+ </disk>
+ <input type='mouse' bus='xen'/>
+ <graphics type='vnc' port='-1' keymap='ja'/>
+ </devices>
+</domain>
diff -r ef6c4d5ed386 -r 38db2ccaff91 tests/xmlconfig.py
--- a/tests/xmlconfig.py Wed Feb 18 19:52:11 2009 -0500
+++ b/tests/xmlconfig.py Wed Feb 18 20:16:03 2009 -0500
@@ -70,6 +70,8 @@
# Should probably break this out into a separate function
dom = xenguest.conn.defineXML(actualXML)
dom.create()
+ dom.destroy()
+ dom.undefine()
finally:
xenguest.installer.cleanup()
@@ -230,6 +232,20 @@
location="/dev/loop0")
self._compare(g, "install-fullyvirt-livecd", False)
+ def testInstallFVImport(self):
+ g = get_basic_fullyvirt_guest()
+ g.disks.append(get_filedisk())
+ g.installer = virtinst.ImportInstaller(type="xen", os_type="hvm",
+ conn=g.conn)
+ self._compare(g, "install-fullyvirt-import", False)
+
+ def testInstallPVImport(self):
+ g = get_basic_paravirt_guest()
+ g.disks.append(get_filedisk())
+ g.installer = virtinst.ImportInstaller(type="xen", os_type="xen",
+ conn=g.conn)
+ self._compare(g, "install-paravirt-import", False)
+
def testXMLEscaping(self):
g = get_basic_fullyvirt_guest()
g.disks.append(get_filedisk("/tmp/ISO&'&s"))
diff -r ef6c4d5ed386 -r 38db2ccaff91 virtinst/ImportInstaller.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/virtinst/ImportInstaller.py Wed Feb 18 20:16:03 2009 -0500
@@ -0,0 +1,63 @@
+#
+# 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.
+
+import Installer
+from 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 'floppy'). All the
+ user has to do is fill in the Guest object with the desired parameters.
+ """
+
+ # General Installer methods
+
+ def prepare(self, guest, meter, distro = None):
+ if len(guest.disks) == 0:
+ raise ValueError(_("A disk device must be specified."))
+
+ def get_install_xml(self, guest, isinstall):
+ if isinstall:
+ # Signifies to the 'Guest' that there is no 'install' phase
+ return None
+ else:
+ bootdev = self._disk_to_bootdev(guest.disks[0])
+
+ return self._get_osblob_helper(isinstall=isinstall, guest=guest,
+ kernel=None, bootdev=bootdev)
+
+ def post_install_check(self, guest):
+ return True
+
+
+ # Private methods
+
+ def _disk_to_bootdev(self, disk):
+ if disk.device == VirtualDisk.DEVICE_DISK:
+ return "hd"
+ elif disk.device == VirtualDisk.DEVICE_CDROM:
+ return "cdrom"
+ elif disk.device == VirtualDisk.DEVICE_FLOPPY:
+ return "floppy"
+ else:
+ return "hd"
diff -r ef6c4d5ed386 -r 38db2ccaff91 virtinst/ParaVirtGuest.py
--- a/virtinst/ParaVirtGuest.py Wed Feb 18 19:52:11 2009 -0500
+++ b/virtinst/ParaVirtGuest.py Wed Feb 18 20:16:03 2009 -0500
@@ -21,7 +21,6 @@
from Guest import Guest
from DistroInstaller import DistroInstaller
-from virtinst import _virtinst as _
class ParaVirtGuest(Guest):
def __init__(self, type=None, connection=None, hypervisorURI=None,
@@ -35,11 +34,6 @@
def _get_input_device(self):
return ("mouse", "xen")
- def validate_parms(self):
- if not self.location and not self.boot:
- raise ValueError, _("A location must be specified to install from")
- Guest.validate_parms(self)
-
def _get_disk_xml(self, install = True):
"""Get the disk config in the libvirt XML format"""
ret = ""
diff -r ef6c4d5ed386 -r 38db2ccaff91 virtinst/__init__.py
--- a/virtinst/__init__.py Wed Feb 18 19:52:11 2009 -0500
+++ b/virtinst/__init__.py Wed Feb 18 20:16:03 2009 -0500
@@ -37,6 +37,7 @@
from DistroInstaller import DistroInstaller
from PXEInstaller import PXEInstaller
from LiveCDInstaller import LiveCDInstaller
+from ImportInstaller import ImportInstaller
from ImageManager import ImageInstaller
from CloneManager import CloneDesign
from User import User
@@ -47,4 +48,5 @@
"XenNetworkInterface", "VirtualGraphics", "VirtualAudio",
"VirtualDisk", "XenDisk", "FullVirtGuest", "ParaVirtGuest",
"DistroInstaller", "PXEInstaller", "LiveCDInstaller",
- "ImageInstaller", "CloneDesign", "Storage", "User", "util"]
+ "ImportInstaller", "ImageInstaller", "CloneDesign", "Storage",
+ "User", "util"]
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]