[et-mgmt-tools] [patch 8/8] Add the livecd installer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a LiveCDInstaller class which has the simple
job of setting up the cdrom disk and returning the appropriate
<os> blob to boot from it.

Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx>

Index: virtinst--devel/virt-install
===================================================================
--- virtinst--devel.orig/virt-install
+++ virtinst--devel/virt-install
@@ -526,6 +526,8 @@ def main():
 
     if not options.installer or options.installer == "distro":
         installer = virtinst.DistroInstaller(type = type)
+    elif options.installer == "livecd":
+        installer = virtinst.LiveCDInstaller(type = type)
     else:
         print >> sys.stderr, "Unknown installer type '%s'" % options.installer
         sys.exit(1)
Index: virtinst--devel/virtinst/LiveCDInstaller.py
===================================================================
--- /dev/null
+++ virtinst--devel/virtinst/LiveCDInstaller.py
@@ -0,0 +1,65 @@
+#!/usr/bin/python -tt
+#
+# An installer class for LiveCD images
+#
+# Copyright 2007  Red Hat, Inc.
+# Mark McLoughlin <markmc@xxxxxxxxxx>
+#
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import os
+
+import Guest
+import CapabilitiesParser
+
+class LiveCDInstallerException(Exception):
+    def __init__(self, msg):
+        Exception.__init__(self, msg)
+
+class LiveCDInstaller(Guest.Installer):
+    def __init__(self, type = "xen", location = None):
+        Guest.Installer.__init__(self, type, location)
+
+    def prepare(self, guest, need_bootdev, meter, distro = None):
+        self.cleanup()
+
+        if not os.path.exists(self.location):
+            raise LiveCDInstallerException("LiveCD image '%s' does not exist" % self.location)
+
+        capabilities = CapabilitiesParser.parse(guest.conn.getCapabilities())
+
+        found = False
+        for guest_caps in capabilities.guests:
+            if guest_caps.os_type == "hvm":
+                found = True
+                break
+
+        if not found:
+            raise LiveCDInstallerException("HVM virtualisation not supported; cannot boot LiveCD")
+
+        disk = Guest.VirtualDisk(self.location,
+                                 device = Guest.VirtualDisk.DEVICE_CDROM,
+                                 readOnly = True)
+        guest.disks.insert(0, disk)
+
+    def _get_osblob(self, install, hvm, arch = None, loader = None):
+        if install:
+            return None
+
+        osblob  = "<os>\n"
+        osblob += "      <type>hvm</type>\n"
+        if loader:
+            osblob += "      <loader>%s</loader>\n" % loader
+        osblob += "      <boot dev='cdrom'/>\n"
+        osblob += "    </os>"
+
+        return osblob
+
+    def post_install_check(self, guest):
+        return True
+
Index: virtinst--devel/virtinst/__init__.py
===================================================================
--- virtinst--devel.orig/virtinst/__init__.py
+++ virtinst--devel/virtinst/__init__.py
@@ -3,3 +3,4 @@ from Guest import Guest, VirtualDisk, Vi
 from FullVirtGuest import FullVirtGuest
 from ParaVirtGuest import ParaVirtGuest
 from DistroManager import DistroInstaller
+from LiveCDInstaller import LiveCDInstaller

-- 


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux