Blame SOURCES/koan-rhel7-virtinst.patch

1330ca
diff -rupN cobbler-2.0.7-old/koan/app.py cobbler-2.0.7-new/koan/app.py
1330ca
--- cobbler-2.0.7-old/koan/app.py	2013-11-21 14:02:54.303559201 -0500
1330ca
+++ cobbler-2.0.7-new/koan/app.py	2013-11-22 17:54:23.691918000 -0500
1330ca
@@ -28,6 +28,7 @@ import random
1330ca
 import os
1330ca
 import traceback
1330ca
 import tempfile
1330ca
+import shlex
1330ca
 
1330ca
 ANCIENT_PYTHON = 0
1330ca
 try:
1330ca
@@ -536,10 +537,13 @@ class Koan:
1330ca
                 if not os.path.exists("/usr/bin/qemu-img"):
1330ca
                     raise InfoException("qemu package needs to be installed")
1330ca
                 # is libvirt new enough?
1330ca
-                cmd = sub_process.Popen("rpm -q python-virtinst", stdout=sub_process.PIPE, shell=True)
1330ca
-                version_str = cmd.communicate()[0]
1330ca
-                if version_str.find("virtinst-0.1") != -1 or version_str.find("virtinst-0.0") != -1:
1330ca
-                    raise InfoException("need python-virtinst >= 0.2 to do installs for qemu/kvm")
1330ca
+                # Note: in some newer distros (like Fedora 19) the python-virtinst package has been
1330ca
+                # subsumed into virt-install. If we don't have one check to see if we have the other.
1330ca
+                rc, version_str = utils.subprocess_get_response(shlex.split('rpm -q virt-install'), True)
1330ca
+                if rc != 0:
1330ca
+                    rc, version_str = utils.subprocess_get_response(shlex.split('rpm -q python-virtinst'), True)
1330ca
+                    if rc != 0 or version_str.find("virtinst-0.1") != -1 or version_str.find("virtinst-0.0") != -1:
1330ca
+                        raise InfoException("need python-virtinst >= 0.2 or virt-install package to do installs for qemu/kvm (depending on your OS)")
1330ca
 
1330ca
             # for vmware
1330ca
             if self.virt_type == "vmware" or self.virt_type == "vmwarew":
1330ca
@@ -1106,7 +1110,10 @@ class Koan:
1330ca
         Invoke virt guest-install (or tweaked copy thereof)
1330ca
         """
1330ca
         pd = profile_data
1330ca
-        self.load_virt_modules()
1330ca
+        # importing can't throw exceptions any more, don't put it in a sub-method
1330ca
+        import xencreate
1330ca
+        import qcreate
1330ca
+        import imagecreate
1330ca
 
1330ca
         arch                          = self.safe_load(pd,'arch','x86')
1330ca
         kextra                        = self.calc_kernel_args(pd)
1330ca
@@ -1180,17 +1187,6 @@ class Koan:
1330ca
 
1330ca
     #---------------------------------------------------
1330ca
 
1330ca
-    def load_virt_modules(self):
1330ca
-        try:
1330ca
-            import xencreate
1330ca
-            import qcreate
1330ca
-            import imagecreate
1330ca
-        except:
1330ca
-            traceback.print_exc()
1330ca
-            raise InfoException("no virtualization support available, install python-virtinst?")
1330ca
-
1330ca
-    #---------------------------------------------------
1330ca
-
1330ca
     def virt_choose(self, pd):
1330ca
         fullvirt = False
1330ca
         can_poll = None
1330ca
@@ -1438,6 +1434,10 @@ class Koan:
1330ca
                 return "%s/%s-disk%s" % (location, name, offset)
1330ca
             elif not os.path.exists(location) and os.path.isdir(os.path.dirname(location)):
1330ca
                 return location
1330ca
+            elif not os.path.exists(os.path.dirname(location)):
1330ca
+                print "- creating: %s" % os.path.dirname(location)
1330ca
+                os.makedirs(os.path.dirname(location))
1330ca
+                return location
1330ca
             else:
1330ca
                 raise InfoException, "invalid location: %s" % location                
1330ca
         elif location.startswith("/dev/"):
1330ca
diff -rupN cobbler-2.0.7-old/koan/imagecreate.py cobbler-2.0.7-new/koan/imagecreate.py
1330ca
--- cobbler-2.0.7-old/koan/imagecreate.py	2013-11-21 14:02:54.303559201 -0500
1330ca
+++ cobbler-2.0.7-new/koan/imagecreate.py	2013-11-21 14:08:24.214897902 -0500
1330ca
@@ -1,7 +1,7 @@
1330ca
 """
1330ca
 Virtualization installation functions for image based deployment
1330ca
 
1330ca
-Copyright 2008 Red Hat, Inc.
1330ca
+Copyright 2008 Red Hat, Inc and Others.
1330ca
 Bryan Kearney <bkearney@redhat.com>
1330ca
 
1330ca
 Original version based on virt-image
1330ca
@@ -23,169 +23,9 @@ Foundation, Inc., 51 Franklin Street, Fi
1330ca
 02110-1301  USA
1330ca
 """
1330ca
 
1330ca
-import os, sys, time, stat
1330ca
-import shutil
1330ca
-import random
1330ca
-import exceptions
1330ca
-import errno
1330ca
-import virtinst
1330ca
-try:
1330ca
-   from virtinst import ImageParser, Guest, CapabilitiesParser, VirtualNetworkInterface
1330ca
-except:
1330ca
-   # if this fails, this is ok, the user just won't be able to use image objects...
1330ca
-   # keeping this dynamic allows this to work on older EL.
1330ca
-   pass
1330ca
-import libvirt
1330ca
-
1330ca
-import app as koan
1330ca
-
1330ca
-#FIXME this was copied
1330ca
-def random_mac():
1330ca
-    """
1330ca
-    from xend/server/netif.py
1330ca
-    Generate a random MAC address.
1330ca
-    Uses OUI 00-16-3E, allocated to
1330ca
-    Xensource, Inc.  Last 3 fields are random.
1330ca
-    return: MAC address string
1330ca
-    """
1330ca
-    mac = [ 0x00, 0x16, 0x3e,
1330ca
-        random.randint(0x00, 0x7f),
1330ca
-        random.randint(0x00, 0xff),
1330ca
-        random.randint(0x00, 0xff) ]
1330ca
-    return ':'.join(map(lambda x: "%02x" % x, mac))
1330ca
-
1330ca
-
1330ca
-def transform_arch(arch):
1330ca
-    if arch == "i386":
1330ca
-        return "i686"
1330ca
-    else:
1330ca
-        return arch
1330ca
-        
1330ca
-def copy_image(original_file, new_location):
1330ca
-    shutil.copyfile(original_file, new_location)
1330ca
-    return new_location
1330ca
-    
1330ca
-    
1330ca
-def process_disk(image, boot, file, location, target):
1330ca
-    image_location = copy_image(file, location)
1330ca
-    # Create the disk
1330ca
-    disk = ImageParser.Disk()
1330ca
-    disk.format = "raw"
1330ca
-    disk.file = image_location
1330ca
-    disk.use = "user"
1330ca
-    disk.id = image_location
1330ca
-    image.storage[disk.id] = disk
1330ca
-    
1330ca
-    #Create the drive
1330ca
-    drive = ImageParser.Drive()
1330ca
-    drive.id = image_location
1330ca
-    drive.target = target 
1330ca
-    drive.disk = disk
1330ca
-    boot.disks.append(drive)
1330ca
-    #dev api
1330ca
-    #boot.drives.append(drive)  
1330ca
-    
1330ca
-    
1330ca
-def process_networks(domain, guest, profile_data, bridge):
1330ca
-    # Create a bridge or default network for every requested nic. If there are more
1330ca
-    # bridges then nics discard the last one.
1330ca
-    domain.interface = int(profile_data["network_count"])
1330ca
-    bridges = []
1330ca
-    #use the provided bridge first
1330ca
-    guest_bridge = bridge
1330ca
-    if guest_bridge is None:
1330ca
-        guest_bridge = profile_data["virt_bridge"]
1330ca
-        
1330ca
-    # Look for commas
1330ca
-    if (guest_bridge is not None) and (len(guest_bridge.strip()) > 0):
1330ca
-        if guest_bridge.find(",") == -1:
1330ca
-            bridges.append(guest_bridge)
1330ca
-        else:
1330ca
-            bridges == guest_bridge.split(",")
1330ca
-    
1330ca
-    for cnt in range(0,domain.interface):
1330ca
-        if cnt < len(bridges):
1330ca
-            nic = VirtualNetworkInterface(random_mac(), type="bridge", bridge = bridges[cnt])
1330ca
-            #dev api
1330ca
-            #nic = VirtualNetworkInterface(random_mac(), type="bridge", bridge = bridge, conn=guest.conn)                
1330ca
-        else: 
1330ca
-            default_network = virtinst.util.default_network()
1330ca
-            #dev api
1330ca
-            #default_network = virtinst.util.default_network(guest.conn)
1330ca
-            nic = VirtualNetworkInterface(random_mac(), type=default_network[0], network=default_network[1])
1330ca
-        guest.nics.append(nic)
1330ca
-
1330ca
-def start_install(name=None, 
1330ca
-                  ram=None, 
1330ca
-                  disks=None,
1330ca
-                  uuid=None,  
1330ca
-                  extra=None, 
1330ca
-                  vcpus=None,  
1330ca
-                  profile_data=None, 
1330ca
-                  arch=None, 
1330ca
-                  no_gfx=False, 
1330ca
-                  fullvirt=False, 
1330ca
-                  bridge=None, 
1330ca
-                  virt_type=None,
1330ca
-                  virt_auto_boot=None):                 
1330ca
-                           
1330ca
-    #FIXME how to do a non-default connection
1330ca
-    #Can we drive off of virt-type?
1330ca
-    connection = None
1330ca
-    
1330ca
-    if (virt_type is None ) or (virt_type == "auto"):
1330ca
-        connection = virtinst.util.default_connection()
1330ca
-    elif virt_type.lower()[0:3] == "xen":
1330ca
-        connection = "xen"
1330ca
-    else:
1330ca
-        connection = "qemu:///system"
1330ca
-        
1330ca
-    connection = libvirt.open(connection)
1330ca
-    capabilities = virtinst.CapabilitiesParser.parse(connection.getCapabilities())   
1330ca
-    image_arch = transform_arch(arch)       
1330ca
-
1330ca
-    image = ImageParser.Image() 
1330ca
-    #dev api
1330ca
-    #image = ImageParser.Image(filename="") #FIXME, ImageParser should take in None
1330ca
-    image.name = name
1330ca
-
1330ca
-    domain = ImageParser.Domain()
1330ca
-    domain.vcpu = vcpus
1330ca
-    domain.memory = ram
1330ca
-    image.domain = domain
1330ca
-    
1330ca
-    boot = ImageParser.Boot()
1330ca
-    boot.type = "hvm" #FIXME HARDCODED
1330ca
-    boot.loader = "hd" #FIXME HARDCODED
1330ca
-    boot.arch = image_arch
1330ca
-    domain.boots.append(boot)
1330ca
-    
1330ca
-    #FIXME Several issues. Single Disk, type is hardcoded
1330ca
-    #And there is no way to provision with access to "file"
1330ca
-    process_disk(image, boot, profile_data["file"], disks[0][0], "hda")
1330ca
-    
1330ca
-    #FIXME boot_index??
1330ca
-    installer = virtinst.ImageInstaller(boot_index = 0, image=image, capabilities=capabilities)                               
1330ca
-    guest = virtinst.FullVirtGuest(connection = connection, installer=installer, arch=image_arch)
1330ca
-
1330ca
-    extra = extra.replace("&","&")
1330ca
-
1330ca
-    guest.extraargs = extra
1330ca
-    guest.set_name(name)
1330ca
-    guest.set_memory(ram)
1330ca
-    guest.set_vcpus(vcpus)
1330ca
-
1330ca
-    if not no_gfx:
1330ca
-        guest.set_graphics("vnc")
1330ca
-    else:
1330ca
-        guest.set_graphics(False)
1330ca
-
1330ca
-    if uuid is not None:
1330ca
-        guest.set_uuid(uuid)
1330ca
-                   
1330ca
-    process_networks(domain, guest, profile_data, bridge)                   
1330ca
-    
1330ca
-    guest.start_install()
1330ca
-    
1330ca
-    return "use virt-manager or reconnect with virsh console %s" % name 
1330ca
-     
1330ca
+import utils
1330ca
+import virtinstall
1330ca
+
1330ca
+def start_install(*args, **kwargs):
1330ca
+    cmd = virtinstall.build_commandline("import", *args, **kwargs)
1330ca
+    utils.subprocess_call(cmd)
1330ca
diff -rupN cobbler-2.0.7-old/koan/qcreate.py cobbler-2.0.7-new/koan/qcreate.py
1330ca
--- cobbler-2.0.7-old/koan/qcreate.py	2013-11-21 14:02:54.304559209 -0500
1330ca
+++ cobbler-2.0.7-new/koan/qcreate.py	2013-12-05 18:49:06.355883703 -0500
1330ca
@@ -1,8 +1,8 @@
1330ca
 """
1330ca
-Virtualization installation functions.  
1330ca
+Virtualization installation functions.
1330ca
 
1330ca
-Copyright 2007-2008 Red Hat, Inc.
1330ca
-Michael DeHaan <mdehaan@redhat.com>
1330ca
+Copyright 2007-2008 Red Hat, Inc and Others.
1330ca
+Michael DeHaan <michael.dehaan AT gmail>
1330ca
 
1330ca
 This program is free software; you can redistribute it and/or modify
1330ca
 it under the terms of the GNU General Public License as published by
1330ca
@@ -20,192 +20,32 @@ Foundation, Inc., 51 Franklin Street, Fi
1330ca
 02110-1301  USA
1330ca
 
1330ca
 module for creating fullvirt guests via KVM/kqemu/qemu
1330ca
-requires python-virtinst-0.200.
1330ca
+requires python-virtinst-0.200 (or virt-install in later distros).
1330ca
 """
1330ca
 
1330ca
-import os, sys, time, stat
1330ca
-import tempfile
1330ca
-import random
1330ca
-from optparse import OptionParser
1330ca
-import exceptions
1330ca
-import errno
1330ca
-import re
1330ca
-import tempfile
1330ca
-import shutil
1330ca
-import virtinst
1330ca
-import app as koan
1330ca
-try:
1330ca
-    import subprocess
1330ca
-except:
1330ca
-    import sub_process as subprocess
1330ca
 import utils
1330ca
+import virtinstall
1330ca
+from xml.dom.minidom import parseString
1330ca
 
1330ca
-def random_mac():
1330ca
-    """
1330ca
-    from xend/server/netif.py
1330ca
-    Generate a random MAC address.
1330ca
-    Uses OUI 00-16-3E, allocated to
1330ca
-    Xensource, Inc.  Last 3 fields are random.
1330ca
-    return: MAC address string
1330ca
-    """
1330ca
-    mac = [ 0x00, 0x16, 0x3e,
1330ca
-        random.randint(0x00, 0x7f),
1330ca
-        random.randint(0x00, 0xff),
1330ca
-        random.randint(0x00, 0xff) ]
1330ca
-    return ':'.join(map(lambda x: "%02x" % x, mac))
1330ca
-
1330ca
-
1330ca
-def start_install(name=None, 
1330ca
-                  ram=None, 
1330ca
-                  disks=None, 
1330ca
-                  mac=None,
1330ca
-                  uuid=None,  
1330ca
-                  extra=None,
1330ca
-                  vcpus=None, 
1330ca
-                  profile_data=None, 
1330ca
-                  arch=None, 
1330ca
-                  no_gfx=False, 
1330ca
-                  fullvirt=True, 
1330ca
-                  bridge=None, 
1330ca
-                  virt_type=None,
1330ca
-                  virt_auto_boot=False):
1330ca
-
1330ca
-    vtype = "qemu"
1330ca
-    if virtinst.util.is_kvm_capable():
1330ca
-       vtype = "kvm"
1330ca
-       arch = None # let virtinst.FullVirtGuest() default to the host arch
1330ca
-    elif virtinst.util.is_kqemu_capable():
1330ca
-       vtype = "kqemu"
1330ca
-    print "- using qemu hypervisor, type=%s" % vtype
1330ca
-
1330ca
-    if arch is not None and arch.lower() in ["x86","i386"]:
1330ca
-        arch = "i686"
1330ca
-
1330ca
-    guest = virtinst.FullVirtGuest(hypervisorURI="qemu:///system",type=vtype, arch=arch)
1330ca
-
1330ca
-    if not profile_data.has_key("file"):
1330ca
-        # images don't need to source this 
1330ca
-        if not profile_data.has_key("install_tree"):
1330ca
-            raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
1330ca
-   
1330ca
- 
1330ca
-        if not profile_data["install_tree"].endswith("/"):
1330ca
-            profile_data["install_tree"] = profile_data["install_tree"] + "/"
1330ca
-
1330ca
-        # virt manager doesn't like nfs:// and just wants nfs:
1330ca
-        # (which cobbler should fix anyway)
1330ca
-        profile_data["install_tree"] = profile_data["install_tree"].replace("nfs://","nfs:")
1330ca
-
1330ca
-    if profile_data.has_key("file"):
1330ca
-        # this is an image based installation
1330ca
-        input_path = profile_data["file"]
1330ca
-        print "- using image location %s" % input_path
1330ca
-        if input_path.find(":") == -1:
1330ca
-            # this is not an NFS path
1330ca
-            guest.cdrom = input_path
1330ca
-        else:
1330ca
-            (tempdir, filename) = utils.nfsmount(input_path)
1330ca
-            guest.cdrom = os.path.join(tempdir, filename)     
1330ca
-
1330ca
-        kickstart = profile_data.get("kickstart","")
1330ca
-        if kickstart != "":
1330ca
-            # we have a (windows?) answer file we have to provide
1330ca
-            # to the ISO.
1330ca
-            print "I want to make a floppy for %s" % kickstart
1330ca
-            floppy_path = utils.make_floppy(kickstart)
1330ca
-            guest.disks.append(virtinst.VirtualDisk(device=virtinst.VirtualDisk.DEVICE_FLOPPY, path=floppy_path))
1330ca
-        
1330ca
-
1330ca
-    else:
1330ca
-        guest.location = profile_data["install_tree"]
1330ca
-   
1330ca
-    extra = extra.replace("&","&") 
1330ca
-    guest.extraargs = extra
1330ca
-
1330ca
-    if profile_data.has_key("breed"):
1330ca
-        breed = profile_data["breed"]
1330ca
-        if breed != "other" and breed != "":
1330ca
-            if breed in [ "debian", "suse", "redhat" ]:
1330ca
-                guest.set_os_type("linux")
1330ca
-            elif breed in [ "windows" ]:
1330ca
-                guest.set_os_type("windows")
1330ca
-            else:
1330ca
-                guest.set_os_type("unix")
1330ca
-            if profile_data.has_key("os_version"):
1330ca
-                # FIXME: when os_version is not defined and it's linux, do we use generic24/generic26 ?
1330ca
-                version = profile_data["os_version"]
1330ca
-                if version != "other" and version != "":
1330ca
-                    try:
1330ca
-                        guest.set_os_variant(version)
1330ca
-                    except:
1330ca
-                        print "- virtinst library does not understand variant %s, treating as generic" % version
1330ca
-                        pass
1330ca
-
1330ca
-    guest.set_name(name)
1330ca
-    guest.set_memory(ram)
1330ca
-    guest.set_vcpus(vcpus)
1330ca
-    # for KVM, we actually can't disable this, since it's the only
1330ca
-    # console it has other than SDL
1330ca
-    guest.set_graphics("vnc")
1330ca
-
1330ca
-    if uuid is not None:
1330ca
-        guest.set_uuid(uuid)
1330ca
-
1330ca
-    for d in disks:
1330ca
-        print "- adding disk: %s of size %s" % (d[0], d[1])
1330ca
-        if d[1] != 0 or d[0].startswith("/dev"):
1330ca
-            guest.disks.append(virtinst.VirtualDisk(d[0], size=d[1]))
1330ca
-        else:
1330ca
-            raise koan.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
1330ca
-
1330ca
-    if profile_data.has_key("interfaces"):
1330ca
-
1330ca
-        counter = 0
1330ca
-        interfaces = profile_data["interfaces"].keys()
1330ca
-        interfaces.sort()
1330ca
-        vlanpattern = re.compile("[a-zA-Z0-9]+\.[0-9]+")
1330ca
-        for iname in interfaces:
1330ca
-            intf = profile_data["interfaces"][iname]
1330ca
-
1330ca
-            if intf["bonding"] == "master" or vlanpattern.match(iname) or iname.find(":") != -1:
1330ca
-                continue
1330ca
-
1330ca
-            mac = intf["mac_address"]
1330ca
-            if mac == "":
1330ca
-                mac = random_mac()
1330ca
-
1330ca
-            if bridge is None:
1330ca
-                profile_bridge = profile_data["virt_bridge"]
1330ca
-
1330ca
-                intf_bridge = intf["virt_bridge"]
1330ca
-                if intf_bridge == "":
1330ca
-                    if profile_bridge == "":
1330ca
-                        raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
-                    intf_bridge = profile_bridge
1330ca
-            else:
1330ca
-                if bridge.find(",") == -1:
1330ca
-                    intf_bridge = bridge
1330ca
-                else:
1330ca
-                    bridges = bridge.split(",")  
1330ca
-                    intf_bridge = bridges[counter]
1330ca
-            nic_obj = virtinst.VirtualNetworkInterface(macaddr=mac, bridge=intf_bridge)
1330ca
-            guest.nics.append(nic_obj)
1330ca
-            counter = counter + 1
1330ca
-
1330ca
-    else:
1330ca
-
1330ca
-            if bridge is not None:
1330ca
-                profile_bridge = bridge
1330ca
-            else:
1330ca
-                profile_bridge = profile_data["virt_bridge"]
1330ca
-
1330ca
-            if profile_bridge == "":
1330ca
-                raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
-
1330ca
-            nic_obj = virtinst.VirtualNetworkInterface(macaddr=random_mac(), bridge=profile_bridge)
1330ca
-            guest.nics.append(nic_obj)
1330ca
-
1330ca
-    guest.start_install()
1330ca
-
1330ca
-    return "use virt-manager and connect to qemu to manage guest: %s" % name
1330ca
-
1330ca
+def start_install(*args, **kwargs):
1330ca
+    # See http://post-office.corp.redhat.com/archives/satellite-dept-list/2013-December/msg00039.html for discussion on this hack.
1330ca
+    if 'arch' in kwargs.keys():
1330ca
+        kwargs['arch'] = None # use host arch for kvm acceleration
1330ca
+
1330ca
+    # Use kvm acceleration if available
1330ca
+    try:
1330ca
+        import libvirt
1330ca
+    except:
1330ca
+        raise koan.InfoException("package libvirt is required for installing virtual guests")
1330ca
+    conn = libvirt.openReadOnly(None)
1330ca
+    # See http://libvirt.org/formatcaps.html
1330ca
+    capabilities = parseString(conn.getCapabilities())
1330ca
+    for domain in capabilities.getElementsByTagName("domain"):
1330ca
+        attributes = dict(domain.attributes.items())
1330ca
+        if 'type' in attributes.keys() and attributes['type'] == 'kvm':
1330ca
+            kwargs['virt_type'] = 'kvm'
1330ca
+            break
1330ca
+
1330ca
+    virtinstall.create_image_file(*args, **kwargs)
1330ca
+    cmd = virtinstall.build_commandline("qemu:///system", *args, **kwargs)
1330ca
+    utils.subprocess_call(cmd)
1330ca
diff -rupN cobbler-2.0.7-old/koan/utils.py cobbler-2.0.7-new/koan/utils.py
1330ca
--- cobbler-2.0.7-old/koan/utils.py	2013-11-21 14:02:54.303559201 -0500
1330ca
+++ cobbler-2.0.7-new/koan/utils.py	2013-12-03 16:14:43.732007939 -0500
1330ca
@@ -178,6 +178,27 @@ def subprocess_call(cmd,ignore_rc=0):
1330ca
         raise InfoException, "command failed (%s)" % rc
1330ca
     return rc
1330ca
 
1330ca
+def subprocess_get_response(cmd, ignore_rc=False):
1330ca
+    """
1330ca
+    Wrapper around subprocess.check_output(...)
1330ca
+    """
1330ca
+    print "- %s" % cmd
1330ca
+    rc = 0
1330ca
+    result = ""
1330ca
+    if not ANCIENT_PYTHON:
1330ca
+        try:
1330ca
+            result = sub_process.check_output(cmd).strip()
1330ca
+        except sub_process.CalledProcessError, e:
1330ca
+            rc = e.returncode
1330ca
+            result = e.output
1330ca
+    else:
1330ca
+        cmd = string.join(cmd, " ")
1330ca
+        print "cmdstr=(%s)" % cmd
1330ca
+        rc = os.system(cmd)
1330ca
+    if not ignore_rc and rc != 0:
1330ca
+        raise InfoException, "command failed (%s)" % rc
1330ca
+    return rc, result
1330ca
+
1330ca
 def input_string_or_hash(options,delim=None,allow_multiples=True):
1330ca
     """
1330ca
     Older cobbler files stored configurations in a flat way, such that all values for strings.
1330ca
@@ -267,7 +288,7 @@ def nfsmount(input_path):
1330ca
         shutil.rmtree(tempdir, ignore_errors=True)
1330ca
         raise koan.InfoException("nfs mount failed: %s" % dirpath)
1330ca
     # NOTE: option for a blocking install might be nice, so we could do this
1330ca
-    # automatically, if supported by python-virtinst
1330ca
+    # automatically, if supported by virt-install
1330ca
     print "after install completes, you may unmount and delete %s" % tempdir
1330ca
     return (tempdir, filename)
1330ca
 
1330ca
@@ -516,7 +537,7 @@ def make_floppy(kickstart):
1330ca
     if not rc == 0:
1330ca
         raise InfoException("umount failed")
1330ca
 
1330ca
-    # return the path to the completed disk image to pass to virtinst
1330ca
+    # return the path to the completed disk image to pass to virt-install
1330ca
     return floppy_path
1330ca
 
1330ca
 
1330ca
diff -rupN cobbler-2.0.7-old/koan/virtinstall.py cobbler-2.0.7-new/koan/virtinstall.py
1330ca
--- cobbler-2.0.7-old/koan/virtinstall.py	1969-12-31 19:00:00.000000000 -0500
1330ca
+++ cobbler-2.0.7-new/koan/virtinstall.py	2013-12-05 17:06:04.469953236 -0500
1330ca
@@ -0,0 +1,413 @@
1330ca
+"""
1330ca
+Virtualization installation functions.
1330ca
+Currently somewhat Xen/paravirt specific, will evolve later.
1330ca
+
1330ca
+Copyright 2006-2008 Red Hat, Inc.
1330ca
+Michael DeHaan <mdehaan@redhat.com>
1330ca
+
1330ca
+Original version based on virtguest-install
1330ca
+Jeremy Katz <katzj@redhat.com>
1330ca
+Option handling added by Andrew Puch <apuch@redhat.com>
1330ca
+Simplified for use as library by koan, Michael DeHaan <mdehaan@redhat.com>
1330ca
+
1330ca
+This program is free software; you can redistribute it and/or modify
1330ca
+it under the terms of the GNU General Public License as published by
1330ca
+the Free Software Foundation; either version 2 of the License, or
1330ca
+(at your option) any later version.
1330ca
+
1330ca
+This program is distributed in the hope that it will be useful,
1330ca
+but WITHOUT ANY WARRANTY; without even the implied warranty of
1330ca
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1330ca
+GNU General Public License for more details.
1330ca
+
1330ca
+You should have received a copy of the GNU General Public License
1330ca
+along with this program; if not, write to the Free Software
1330ca
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
1330ca
+02110-1301  USA
1330ca
+"""
1330ca
+
1330ca
+import os
1330ca
+import re
1330ca
+import shlex
1330ca
+
1330ca
+import app as koan
1330ca
+import utils
1330ca
+
1330ca
+# The virtinst module will no longer be availabe to import in some
1330ca
+# distros. We need to get all the info we need from the virt-install
1330ca
+# command line tool. This should work on both old and new variants,
1330ca
+# as the virt-install command line tool has always been provided by
1330ca
+# python-virtinst (and now the new virt-install rpm).
1330ca
+rc, response = utils.subprocess_get_response(
1330ca
+        shlex.split('virt-install --version'), True)
1330ca
+if rc == 0:
1330ca
+    virtinst_version = response
1330ca
+else:
1330ca
+    virtinst_version = None
1330ca
+
1330ca
+# This one's trickier. We need a list of supported os varients, but
1330ca
+# the man page explicitly says not to parse the result of this command.
1330ca
+# But we need it, and there's no other way to get it. I spoke with the
1330ca
+# virt-install maintainers and they said the point of that message
1330ca
+# is that you can't absolutely depend on the output not changing, but
1330ca
+# at the moment it's the only option for us. Long term plans are for
1330ca
+# virt-install to switch to libosinfo for OS metadata tracking, which
1330ca
+# provides a library and tools for querying valid OS values. Until
1330ca
+# that's available and pervasive the best we can do is to use the
1330ca
+# module if it's availabe and if not parse the command output.
1330ca
+supported_variants = set()
1330ca
+try:
1330ca
+    from virtinst import osdict
1330ca
+    for ostype in osdict.OS_TYPES.keys():
1330ca
+        for variant in osdict.OS_TYPES[ostype]["variants"].keys():
1330ca
+            supported_variants.add(variant)
1330ca
+except:
1330ca
+    try:
1330ca
+        rc, response = utils.subprocess_get_response(
1330ca
+                shlex.split('virt-install --os-variant list'))
1330ca
+        variants = response.split('\n')
1330ca
+        for variant in variants:
1330ca
+            supported_variants.add(variant.split()[0])
1330ca
+    except:
1330ca
+        pass # No problem, we'll just use generic
1330ca
+
1330ca
+def _sanitize_disks(disks):
1330ca
+    ret = []
1330ca
+    for d in disks:
1330ca
+        driver_type = None
1330ca
+        if len(d) > 2:
1330ca
+            driver_type = d[2]
1330ca
+
1330ca
+        if d[1] != 0 or d[0].startswith("/dev"):
1330ca
+            ret.append((d[0], d[1], driver_type))
1330ca
+        else:
1330ca
+            raise koan.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
1330ca
+
1330ca
+    return ret
1330ca
+
1330ca
+def _sanitize_nics(nics, bridge, profile_bridge, network_count):
1330ca
+    ret = []
1330ca
+
1330ca
+    if network_count is not None and not nics:
1330ca
+        # Fill in some stub nics so we can take advantage of the loop logic
1330ca
+        nics = {}
1330ca
+        for i in range(int(network_count)):
1330ca
+            nics["foo%s" % i] = {
1330ca
+                "interface_type" : "na",
1330ca
+                "mac_address": None,
1330ca
+                "virt_bridge": None,
1330ca
+            }
1330ca
+
1330ca
+    if not nics:
1330ca
+        return ret
1330ca
+
1330ca
+    interfaces = nics.keys()
1330ca
+    interfaces.sort()
1330ca
+    counter = -1
1330ca
+    vlanpattern = re.compile("[a-zA-Z0-9]+\.[0-9]+")
1330ca
+
1330ca
+    for iname in interfaces:
1330ca
+        counter = counter + 1
1330ca
+        intf = nics[iname]
1330ca
+
1330ca
+        if (intf["bonding"] == "master" or vlanpattern.match(iname) or iname.find(":") != -1):
1330ca
+            continue
1330ca
+
1330ca
+        mac = intf["mac_address"]
1330ca
+
1330ca
+        if not bridge:
1330ca
+            intf_bridge = intf["virt_bridge"]
1330ca
+            if intf_bridge == "":
1330ca
+                if profile_bridge == "":
1330ca
+                    raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
+                intf_bridge = profile_bridge
1330ca
+
1330ca
+        else:
1330ca
+            if bridge.find(",") == -1:
1330ca
+                intf_bridge = bridge
1330ca
+            else:
1330ca
+                bridges = bridge.split(",")
1330ca
+                intf_bridge = bridges[counter]
1330ca
+
1330ca
+        ret.append((intf_bridge, mac))
1330ca
+
1330ca
+    return ret
1330ca
+
1330ca
+def create_image_file(disks=None, **kwargs):
1330ca
+    disks = _sanitize_disks(disks)
1330ca
+    for path, size, driver_type in disks:
1330ca
+        if driver_type is None:
1330ca
+            continue
1330ca
+        if os.path.isdir(path) or os.path.exists(path):
1330ca
+            continue
1330ca
+        if str(size) == "0":
1330ca
+            continue
1330ca
+        utils.create_qemu_image_file(path, size, driver_type)
1330ca
+
1330ca
+def build_commandline(uri,
1330ca
+                      name=None,
1330ca
+                      ram=None,
1330ca
+                      disks=None,
1330ca
+                      uuid=None,
1330ca
+                      extra=None,
1330ca
+                      vcpus=None,
1330ca
+                      profile_data=None,
1330ca
+                      arch=None,
1330ca
+                      no_gfx=False,
1330ca
+                      fullvirt=False,
1330ca
+                      bridge=None,
1330ca
+                      virt_type=None,
1330ca
+                      virt_auto_boot=False,
1330ca
+                      virt_pxe_boot=False,
1330ca
+                      qemu_driver_type=None,
1330ca
+                      qemu_net_type=None,
1330ca
+                      qemu_machine_type=None,
1330ca
+                      wait=0,
1330ca
+                      noreboot=False,
1330ca
+                      osimport=False):
1330ca
+
1330ca
+    # Set flags for CLI arguments based on the virtinst_version
1330ca
+    # tuple above. Older versions of python-virtinst don't have
1330ca
+    # a version easily accessible, so it will be None and we can
1330ca
+    # easily disable features based on that (RHEL5 and older usually)
1330ca
+
1330ca
+    disable_autostart = False
1330ca
+    disable_virt_type = False
1330ca
+    disable_boot_opt = False
1330ca
+    disable_driver_type = False
1330ca
+    disable_net_model = False
1330ca
+    disable_machine_type = False
1330ca
+    oldstyle_macs = False
1330ca
+    oldstyle_accelerate = False
1330ca
+
1330ca
+    if not virtinst_version:
1330ca
+        print ("- warning: old virt-install detected, a lot of features will be disabled")
1330ca
+        disable_autostart = True
1330ca
+        disable_boot_opt = True
1330ca
+        disable_virt_type = True
1330ca
+        disable_driver_type = True
1330ca
+        disable_net_model = True
1330ca
+        disable_machine_type = True
1330ca
+        oldstyle_macs = True
1330ca
+        oldstyle_accelerate = True
1330ca
+
1330ca
+    import_exists = False # avoid duplicating --import parameter
1330ca
+    disable_extra = False # disable --extra-args on --import
1330ca
+    if osimport:
1330ca
+        disable_extra = True
1330ca
+
1330ca
+    is_import = uri.startswith("import")
1330ca
+    if is_import:
1330ca
+        # We use the special value 'import' for imagecreate.py. Since
1330ca
+        # it is connection agnostic, just let virt-install choose the
1330ca
+        # best hypervisor.
1330ca
+        uri = ""
1330ca
+        fullvirt = None
1330ca
+
1330ca
+    is_xen = uri.startswith("xen")
1330ca
+    is_qemu = uri.startswith("qemu")
1330ca
+    if is_qemu:
1330ca
+        if virt_type != "kvm":
1330ca
+            fullvirt = True
1330ca
+        else:
1330ca
+            fullvirt = None
1330ca
+
1330ca
+    floppy = None
1330ca
+    cdrom = None
1330ca
+    location = None
1330ca
+    importpath = None
1330ca
+
1330ca
+    if is_import:
1330ca
+        importpath = profile_data.get("file")
1330ca
+        if not importpath:
1330ca
+            raise koan.InfoException("Profile 'file' required for image "
1330ca
+                                     "install")
1330ca
+
1330ca
+    elif profile_data.has_key("file"):
1330ca
+        if is_xen:
1330ca
+            raise koan.InfoException("Xen does not work with --image yet")
1330ca
+
1330ca
+        # this is an image based installation
1330ca
+        input_path = profile_data["file"]
1330ca
+        print "- using image location %s" % input_path
1330ca
+        if input_path.find(":") == -1:
1330ca
+            # this is not an NFS path
1330ca
+            cdrom = input_path
1330ca
+        else:
1330ca
+            (tempdir, filename) = utils.nfsmount(input_path)
1330ca
+            cdrom = os.path.join(tempdir, filename)
1330ca
+
1330ca
+        kickstart = profile_data.get("kickstart","")
1330ca
+        if kickstart != "":
1330ca
+            # we have a (windows?) answer file we have to provide
1330ca
+            # to the ISO.
1330ca
+            print "I want to make a floppy for %s" % kickstart
1330ca
+            floppy = utils.make_floppy(kickstart)
1330ca
+    elif is_qemu or is_xen:
1330ca
+        # images don't need to source this
1330ca
+        if not profile_data.has_key("install_tree"):
1330ca
+            raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
1330ca
+
1330ca
+        if not profile_data["install_tree"].endswith("/"):
1330ca
+            profile_data["install_tree"] = profile_data["install_tree"] + "/"
1330ca
+
1330ca
+        location = profile_data["install_tree"]
1330ca
+
1330ca
+
1330ca
+    disks = _sanitize_disks(disks)
1330ca
+    nics = _sanitize_nics(profile_data.get("interfaces"),
1330ca
+                          bridge,
1330ca
+                          profile_data.get("virt_bridge"),
1330ca
+                          profile_data.get("network_count"))
1330ca
+    if not nics:
1330ca
+        # for --profile you get one NIC, go define a system if you want more.
1330ca
+        # FIXME: can mac still be sent on command line in this case?
1330ca
+
1330ca
+        if bridge is None:
1330ca
+            bridge = profile_data["virt_bridge"]
1330ca
+
1330ca
+        if bridge == "":
1330ca
+            raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
+        nics = [(bridge, None)]
1330ca
+
1330ca
+
1330ca
+    kernel = profile_data.get("kernel_local")
1330ca
+    initrd = profile_data.get("initrd_local")
1330ca
+    breed = profile_data.get("breed")
1330ca
+    os_version = profile_data.get("os_version")
1330ca
+    if os_version and breed == "ubuntu":
1330ca
+        os_version = "ubuntu%s" % os_version
1330ca
+    if os_version and breed == "debian":
1330ca
+        os_version = "debian%s" % os_version
1330ca
+
1330ca
+    net_model = None
1330ca
+    disk_bus = None
1330ca
+    machine_type = None
1330ca
+
1330ca
+    if is_qemu:
1330ca
+        net_model = qemu_net_type
1330ca
+        disk_bus = qemu_driver_type
1330ca
+        machine_type = qemu_machine_type
1330ca
+
1330ca
+    if machine_type is None:
1330ca
+        machine_type = "pc"
1330ca
+
1330ca
+    cmd = "virt-install "
1330ca
+    if uri:
1330ca
+        cmd += "--connect %s " % uri
1330ca
+
1330ca
+    cmd += "--name %s " % name
1330ca
+    cmd += "--ram %s " % ram
1330ca
+    cmd += "--vcpus %s " % vcpus
1330ca
+
1330ca
+    if uuid:
1330ca
+        cmd += "--uuid %s " % uuid
1330ca
+
1330ca
+    if virt_auto_boot and not disable_autostart:
1330ca
+        cmd += "--autostart "
1330ca
+
1330ca
+    if no_gfx:
1330ca
+        cmd += "--nographics "
1330ca
+    else:
1330ca
+        cmd += "--vnc "
1330ca
+
1330ca
+    if is_qemu and virt_type:
1330ca
+        if not disable_virt_type:
1330ca
+            cmd += "--virt-type %s " % virt_type
1330ca
+
1330ca
+    if is_qemu and machine_type and not disable_machine_type:
1330ca
+        cmd += "--machine %s " % machine_type
1330ca
+
1330ca
+    if fullvirt or is_qemu or is_import:
1330ca
+        if fullvirt is not None:
1330ca
+            cmd += "--hvm "
1330ca
+        elif oldstyle_accelerate:
1330ca
+            cmd += "--accelerate "
1330ca
+
1330ca
+        if is_qemu and extra and not(virt_pxe_boot) and not(disable_extra):
1330ca
+            cmd += ("--extra-args=\"%s\" " % (extra))
1330ca
+
1330ca
+        if virt_pxe_boot or is_xen:
1330ca
+            cmd += "--pxe "
1330ca
+        elif cdrom:
1330ca
+            cmd += "--cdrom %s " % cdrom
1330ca
+        elif location:
1330ca
+            cmd += "--location %s " % location
1330ca
+        elif importpath:
1330ca
+            cmd += "--import "
1330ca
+            import_exists = True
1330ca
+
1330ca
+        if arch:
1330ca
+            cmd += "--arch %s " % arch
1330ca
+    else:
1330ca
+        cmd += "--paravirt "
1330ca
+        if not disable_boot_opt:
1330ca
+            cmd += ("--boot kernel=%s,initrd=%s,kernel_args=\"%s\" " %
1330ca
+                    (kernel, initrd, extra))
1330ca
+        else:
1330ca
+            if location:
1330ca
+                cmd += "--location %s " % location
1330ca
+            if extra:
1330ca
+                cmd += "--extra-args=\"%s\" " % extra
1330ca
+
1330ca
+    if breed and breed != "other":
1330ca
+        if os_version and os_version != "other":
1330ca
+            if breed == "suse":
1330ca
+                suse_version_re = re.compile("^(opensuse[0-9]+)\.([0-9]+)$")
1330ca
+                if suse_version_re.match(os_version):
1330ca
+                    os_version = suse_version_re.match(os_version).groups()[0]
1330ca
+            # make sure virt-install knows about our os_version,
1330ca
+            # otherwise default it to generic26
1330ca
+            found = False
1330ca
+            if os_version in supported_variants:
1330ca
+                cmd += "--os-variant %s " % os_version
1330ca
+            else:
1330ca
+                print ("- warning: virt-install doesn't know this os_version, defaulting to generic26")
1330ca
+                cmd += "--os-variant generic26 "
1330ca
+        else:
1330ca
+            distro = "unix"
1330ca
+            if breed in [ "debian", "suse", "redhat" ]:
1330ca
+                distro = "linux"
1330ca
+            elif breed in [ "windows" ]:
1330ca
+                distro = "windows"
1330ca
+
1330ca
+            cmd += "--os-type %s " % distro
1330ca
+
1330ca
+    if importpath:
1330ca
+        # This needs to be the first disk for import to work
1330ca
+        cmd += "--disk path=%s " % importpath
1330ca
+
1330ca
+    for path, size, driver_type in disks:
1330ca
+        print ("- adding disk: %s of size %s (driver type=%s)" %
1330ca
+               (path, size, driver_type))
1330ca
+        cmd += "--disk path=%s" % (path)
1330ca
+        if str(size) != "0":
1330ca
+            cmd += ",size=%s" % size
1330ca
+        if disk_bus:
1330ca
+            cmd += ",bus=%s" % disk_bus
1330ca
+        if driver_type and not disable_driver_type:
1330ca
+            cmd += ",format=%s" % driver_type
1330ca
+        cmd += " "
1330ca
+
1330ca
+    if floppy:
1330ca
+        cmd += "--disk path=%s,device=floppy " % floppy
1330ca
+
1330ca
+    for bridge, mac in nics:
1330ca
+        cmd += "--network bridge=%s" % bridge
1330ca
+        if net_model and not disable_net_model:
1330ca
+            cmd += ",model=%s" % net_model
1330ca
+        if mac:
1330ca
+            if oldstyle_macs:
1330ca
+                cmd += " --mac=%s" % mac
1330ca
+            else:
1330ca
+                cmd += ",mac=%s" % mac
1330ca
+        cmd += " "
1330ca
+
1330ca
+    cmd += "--wait %d " % int(wait)
1330ca
+    if noreboot:
1330ca
+        cmd += "--noreboot "
1330ca
+    if osimport and not(import_exists):
1330ca
+        cmd += "--import "
1330ca
+    cmd += "--noautoconsole "
1330ca
+
1330ca
+    return shlex.split(cmd.strip())
1330ca
diff -rupN cobbler-2.0.7-old/koan/xencreate.py cobbler-2.0.7-new/koan/xencreate.py
1330ca
--- cobbler-2.0.7-old/koan/xencreate.py	2013-11-21 14:02:54.304559209 -0500
1330ca
+++ cobbler-2.0.7-new/koan/xencreate.py	2013-11-21 14:05:56.006847361 -0500
1330ca
@@ -1,14 +1,14 @@
1330ca
 """
1330ca
-Virtualization installation functions.  
1330ca
+Virtualization installation functions.
1330ca
 Currently somewhat Xen/paravirt specific, will evolve later.
1330ca
 
1330ca
-Copyright 2006-2008 Red Hat, Inc.
1330ca
-Michael DeHaan <mdehaan@redhat.com>
1330ca
+Copyright 2006-2008 Red Hat, Inc and Others.
1330ca
+Michael DeHaan <michael.dehaan AT gmail>
1330ca
 
1330ca
 Original version based on virtguest-install
1330ca
 Jeremy Katz <katzj@redhat.com>
1330ca
 Option handling added by Andrew Puch <apuch@redhat.com>
1330ca
-Simplified for use as library by koan, Michael DeHaan <mdehaan@redhat.com>
1330ca
+Simplified for use as library by koan, Michael DeHaan <michael.dehaan AT gmail>
1330ca
 
1330ca
 This program is free software; you can redistribute it and/or modify
1330ca
 it under the terms of the GNU General Public License as published by
1330ca
@@ -26,180 +26,9 @@ Foundation, Inc., 51 Franklin Street, Fi
1330ca
 02110-1301  USA
1330ca
 """
1330ca
 
1330ca
-import os, sys, time, stat
1330ca
-import tempfile
1330ca
-import random
1330ca
-import exceptions
1330ca
-import errno
1330ca
-import re
1330ca
-import virtinst
1330ca
-import app as koan
1330ca
-
1330ca
-try:
1330ca
-    from virtinst.DistroManager import PXEInstaller
1330ca
-    pxe_installer = PXEInstaller()
1330ca
-except ImportError:
1330ca
-    try:
1330ca
-        from virtinst import PXEInstaller
1330ca
-        pxe_installer = PXEInstaller(os_type='hvm')
1330ca
-    except:
1330ca
-        # older virtinst, this is probably ok
1330ca
-        # but we know we can't do Xen fullvirt installs
1330ca
-        pass
1330ca
-import traceback
1330ca
-
1330ca
-def random_mac():
1330ca
-    """
1330ca
-    from xend/server/netif.py
1330ca
-    Generate a random MAC address.
1330ca
-    Uses OUI 00-16-3E, allocated to
1330ca
-    Xensource, Inc.  Last 3 fields are random.
1330ca
-    return: MAC address string
1330ca
-    """
1330ca
-    mac = [ 0x00, 0x16, 0x3e,
1330ca
-        random.randint(0x00, 0x7f),
1330ca
-        random.randint(0x00, 0xff),
1330ca
-        random.randint(0x00, 0xff) ]
1330ca
-    return ':'.join(map(lambda x: "%02x" % x, mac))
1330ca
-
1330ca
-
1330ca
-def start_install(name=None, 
1330ca
-                  ram=None, 
1330ca
-                  disks=None,
1330ca
-                  uuid=None,  
1330ca
-                  extra=None, 
1330ca
-                  vcpus=None,  
1330ca
-                  profile_data=None, 
1330ca
-                  arch=None, 
1330ca
-                  no_gfx=False, 
1330ca
-                  fullvirt=False, 
1330ca
-                  bridge=None, 
1330ca
-                  virt_type=None,
1330ca
-                  virt_auto_boot=False):
1330ca
-
1330ca
-    if profile_data.has_key("file"):
1330ca
-        raise koan.InfoException("Xen does not work with --image yet")
1330ca
-
1330ca
-    if fullvirt:
1330ca
-        # FIXME: add error handling here to explain when it's not supported
1330ca
-        guest = virtinst.FullVirtGuest(installer=pxe_installer)
1330ca
-    else:
1330ca
-        guest = virtinst.ParaVirtGuest()
1330ca
-
1330ca
-    extra = extra.replace("&","&")
1330ca
-
1330ca
-    if not fullvirt:
1330ca
-        guest.set_boot((profile_data["kernel_local"], profile_data["initrd_local"]))
1330ca
-        # fullvirt OS's will get this from the PXE config (managed by Cobbler)
1330ca
-        guest.extraargs = extra
1330ca
-    else:
1330ca
-        print "- fullvirt mode"
1330ca
-        if profile_data.has_key("breed"):
1330ca
-            breed = profile_data["breed"]
1330ca
-            if breed != "other" and breed != "":
1330ca
-                if breed in [ "debian", "suse", "redhat" ]:
1330ca
-                    guest.set_os_type("linux")
1330ca
-                elif breed in [ "windows" ]:
1330ca
-                    guest.set_os_type("windows")
1330ca
-                else:
1330ca
-                    guest.set_os_type("unix")
1330ca
-                if profile_data.has_key("os_version"):
1330ca
-                    # FIXME: when os_version is not defined and it's linux, do we use generic24/generic26 ?
1330ca
-                    version = profile_data["os_version"]
1330ca
-                    if version != "other" and version != "":
1330ca
-                        try:
1330ca
-                            guest.set_os_variant(version)
1330ca
-                        except:
1330ca
-                            print "- virtinst library does not understand variant %s, treating as generic" % version
1330ca
-                            pass
1330ca
-
1330ca
-
1330ca
-    guest.set_name(name)
1330ca
-    guest.set_memory(ram)
1330ca
-    guest.set_vcpus(vcpus)
1330ca
-
1330ca
-    if not no_gfx:
1330ca
-        guest.set_graphics("vnc")
1330ca
-    else:
1330ca
-        guest.set_graphics(False)
1330ca
-
1330ca
-    if uuid is not None:
1330ca
-        guest.set_uuid(uuid)
1330ca
-
1330ca
-    for d in disks:
1330ca
-        if d[1] != 0 or d[0].startswith("/dev"):
1330ca
-            virtdisk = virtinst.XenDisk(d[0], size=d[1])
1330ca
-
1330ca
-            # Set driver_name to tap for Xen PV guests
1330ca
-            if guest.installer and guest.installer.os_type in ('xen', 'linux'):
1330ca
-                if virtdisk.type == virtinst.XenDisk.TYPE_FILE and \
1330ca
-                   virtinst._util.is_blktap_capable():
1330ca
-                    virtdisk.driver_name = virtinst.XenDisk.DRIVER_TAP
1330ca
-
1330ca
-            guest.disks.append(virtdisk)
1330ca
-        else:
1330ca
-            raise koan.InfoException("this virtualization type does not work without a disk image, set virt-size in Cobbler to non-zero")
1330ca
-
1330ca
-    counter = 0
1330ca
-
1330ca
-    if profile_data.has_key("interfaces"):
1330ca
-
1330ca
-        interfaces = profile_data["interfaces"].keys()
1330ca
-        interfaces.sort()
1330ca
-        counter = -1
1330ca
-        vlanpattern = re.compile("[a-zA-Z0-9]+\.[0-9]+")
1330ca
-
1330ca
-        for iname in interfaces:
1330ca
-            counter = counter + 1
1330ca
-            intf = profile_data["interfaces"][iname]
1330ca
-
1330ca
-            if intf["bonding"] == "master" or vlanpattern.match(iname) or iname.find(":") != -1: 
1330ca
-                continue
1330ca
-
1330ca
-            mac = intf["mac_address"]
1330ca
-            if mac == "":
1330ca
-                mac = random_mac()
1330ca
-
1330ca
-            if not bridge:
1330ca
-                profile_bridge = profile_data["virt_bridge"]
1330ca
-
1330ca
-                intf_bridge = intf["virt_bridge"]
1330ca
-                if intf_bridge == "":
1330ca
-                    if profile_bridge == "":
1330ca
-                        raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
-                    intf_bridge = profile_bridge
1330ca
-
1330ca
-            else:
1330ca
-                if bridge.find(",") == -1:
1330ca
-                    intf_bridge = bridge
1330ca
-                else:
1330ca
-                    bridges = bridge.split(",")
1330ca
-                    intf_bridge = bridges[counter]
1330ca
-
1330ca
-
1330ca
-            nic_obj = virtinst.XenNetworkInterface(macaddr=mac, bridge=intf_bridge)
1330ca
-            guest.nics.append(nic_obj)
1330ca
-            counter = counter + 1
1330ca
-   
1330ca
-    else:
1330ca
-            # for --profile you just get one NIC, go define a system if you want more.
1330ca
-            # FIXME: can mac still be sent on command line in this case?
1330ca
-
1330ca
-            if bridge is None:
1330ca
-                profile_bridge = profile_data["virt_bridge"]
1330ca
-            else:
1330ca
-                profile_bridge = bridge
1330ca
-
1330ca
-            if profile_bridge == "":
1330ca
-                raise koan.InfoException("virt-bridge setting is not defined in cobbler")
1330ca
-
1330ca
-            nic_obj = virtinst.XenNetworkInterface(macaddr=random_mac(), bridge=profile_bridge)
1330ca
-            guest.nics.append(nic_obj)
1330ca
-            
1330ca
-        
1330ca
-
1330ca
-
1330ca
-    guest.start_install()
1330ca
-    
1330ca
-    return "use virt-manager or reconnect with virsh console %s" % name 
1330ca
-     
1330ca
+import utils
1330ca
+import virtinstall
1330ca
+
1330ca
+def start_install(*args, **kwargs):
1330ca
+    cmd = virtinstall.build_commandline("xen:///", *args, **kwargs)
1330ca
+    utils.subprocess_call(cmd)