From 3794384d1117b97a8628872cc98035f4d27e9f3d Mon Sep 17 00:00:00 2001
From: Christian Berendt <berendt@b1-systems.de>
Date: Mon, 24 Oct 2011 16:33:58 +0200
Subject: [PATCH] removed a lot of useless spaces in koan

---
 koan/app.py          |  120 +++++++++++++++++++++++++-------------------------
 koan/configurator.py |   90 +++++++++++++++++++-------------------
 koan/imagecreate.py  |   76 ++++++++++++++++----------------
 koan/qcreate.py      |   18 ++++----
 koan/register.py     |   20 ++++----
 koan/utils.py        |   18 ++++----
 koan/vmwcreate.py    |   24 +++++-----
 koan/xencreate.py    |   34 +++++++-------
 8 files changed, 200 insertions(+), 200 deletions(-)

diff --git a/koan/app.py b/koan/app.py
index d6133c3..f5cbe11 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -2,7 +2,7 @@
 koan = kickstart over a network
 
 a tool for network provisioning of virtualization (xen,kvm/qemu,vmware)
-and network re-provisioning of existing Linux systems.  
+and network re-provisioning of existing Linux systems.
 used with 'cobbler'. see manpage for usage.
 
 Copyright 2006-2008 Red Hat, Inc.
@@ -12,12 +12,12 @@ 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
@@ -159,7 +159,7 @@ def main():
                  help="for xen/qemu/KVM, poll & restart the VM after the install is done")
     p.add_option("-P", "--virt-path",
                  dest="virt_path",
-                 help="override virt install location")  
+                 help="override virt install location")
     p.add_option("", "--force-path",
                  dest="force_path",
                  action="store_true",
@@ -171,11 +171,11 @@ def main():
                  dest="virt_bridge",
                  help="override virt bridge")
     p.add_option("-n", "--nogfx",
-                 action="store_true", 
+                 action="store_true",
                  dest="no_gfx",
                  help="disable Xen graphics (xenpv,xenfv)")
     p.add_option("", "--virt-auto-boot",
-                 action="store_true", 
+                 action="store_true",
                  dest="virt_auto_boot",
                  help="set VM for autoboot")
     p.add_option("", "--add-reinstall-entry",
@@ -304,7 +304,7 @@ class Koan:
         """
         koan's main function...
         """
-        
+
         # we can get the info we need from either the cobbler server
         #  or a kickstart file
         if self.server is None:
@@ -317,7 +317,7 @@ class Koan:
                found = found+1
         if found != 1:
             raise InfoException, "choose: --virt, --replace-self, --update-files, --list=what, or --display"
- 
+
 
         # This set of options are only valid with --server
         if not self.server or self.server == "":
@@ -329,14 +329,14 @@ class Koan:
         if self.list_items:
             self.list(self.list_items)
             return
-    
+
         if not os.getuid() == 0:
             if self.is_virt:
                 print "warning: running as non root"
             else:
                 print "this operation requires root access"
                 return 3
-        
+
         # if both --profile and --system were ommitted, autodiscover
         if self.is_virt:
             if (self.profile is None and self.system is None and self.image is None):
@@ -390,12 +390,12 @@ class Koan:
         else:
             self.display()
 
-    # --------------------------------------------------   
+    # --------------------------------------------------
 
     def ask_profile(self):
         """
         Used by the live CD mode, if the system can not be auto-discovered, show a list of available
-        profiles and ask the user what they want to install.  
+        profiles and ask the user what they want to install.
         """
         # FIXME: use a TUI library to make this more presentable.
         try:
@@ -405,14 +405,14 @@ class Koan:
             self.connect_fail()
 
         print "\n- which profile to install?\n"
-      
+
         for x in available_profiles:
             print "%s" % x["name"]
 
         sys.stdout.write("\n?>")
 
         data = sys.stdin.readline().strip()
- 
+
         for x in available_profiles:
             print "comp (%s,%s)" % (x["name"],data)
             if x["name"] == data:
@@ -424,7 +424,7 @@ class Koan:
     def autodetect_system(self, allow_interactive=False):
         """
         Determine the name of the cobbler system record that
-        matches this MAC address. 
+        matches this MAC address.
         """
         systems = self.get_data("systems")
         my_netinfo = utils.get_network_info()
@@ -467,7 +467,7 @@ class Koan:
     #---------------------------------------------------
 
     def safe_load(self,hashv,primary_key,alternate_key=None,default=None):
-        if hashv.has_key(primary_key): 
+        if hashv.has_key(primary_key):
             return hashv[primary_key]
         elif alternate_key is not None and hashv.has_key(alternate_key):
             return hashv[alternate_key]
@@ -500,7 +500,7 @@ class Koan:
                    profile_data["kickstart"] = "http://%s/cblr/svc/op/ks/profile/%s" % (profile_data['http_server'], profile_data['name'])
                else:
                    profile_data["kickstart"] = "http://%s/cblr/svc/op/ks/system/%s" % (profile_data['http_server'], profile_data['name'])
-                
+
             # If breed is ubuntu/debian we need to source the install tree differently
             # as preseeds are used instead of kickstarts.
             if profile_data["breed"] in [ "ubuntu", "debian" ]:
@@ -519,7 +519,7 @@ class Koan:
                     profile_data["initrd"] = profile_data["install_tree"] + "/images/pxeboot/initrd.img"
 
 
-        # find the correct file download location 
+        # find the correct file download location
         if not self.is_virt:
             if os.path.exists("/boot/efi/EFI/redhat/elilo.conf"):
                 # elilo itanium support, may actually still work
@@ -545,7 +545,7 @@ class Koan:
                 elif profile_data.has_key("file"):
                     print "- ISO or Image based installation, always uses --virt-type=qemu"
                     self.virt_type = "qemu"
-                    
+
                 else:
                     # FIXME: auto never selects vmware, maybe it should if we find it?
 
@@ -609,18 +609,18 @@ class Koan:
 
             if self.virt_type in [ "xenpv" ]:
                 # we need to fetch the kernel/initrd to do this
-                download = "/var/lib/xen" 
+                download = "/var/lib/xen"
             elif self.virt_type in [ "xenfv", "vmware", "vmwarew" ] :
                 # we are downloading sufficient metadata to initiate PXE, no D/L needed
-                download = None 
+                download = None
             else: # qemu
                 # fullvirt, can use set_location in virtinst library, no D/L needed yet
-                download = None 
+                download = None
 
         # download required files
         if not self.is_display and download is not None:
            self.get_distro_files(profile_data, download)
-  
+
         # perform specified action
         after_download(self, profile_data)
 
@@ -671,7 +671,7 @@ class Koan:
                     print "install_tree:", profile_data["install_tree"]
                 else:
                     print "warning: kickstart found but no install_tree found"
-                            
+
             except:
                 # unstable to download the kickstart, however this might not
                 # be an error.  For instance, xen FV installations of non
@@ -722,7 +722,7 @@ class Koan:
         return self.net_install(after_download)
 
     #---------------------------------------------------
-                 
+
     def virt(self):
         """
         Handle virt provisioning.
@@ -741,7 +741,7 @@ class Koan:
         files in cobbler that we are providing to nodes.  Basically
         this turns cobbler into a lighweight configuration management
         system for folks who are not needing a more complex CMS.
-        
+
         Read more at:
         https://fedorahosted.org/cobbler/wiki/BuiltinConfigManagement
         """
@@ -784,8 +784,8 @@ class Koan:
                 os.makedirs(os.path.dirname(save_as))
             cmd = [ "/usr/bin/wget", url, "--output-document", save_as ]
             utils.subprocess_call(cmd)
-       
-        return True 
+
+        return True
 
     #---------------------------------------------------
 
@@ -805,7 +805,7 @@ class Koan:
             traceback.print_exc()
             self.connect_fail()
 
-        # FIXME should we version this, maybe append a timestamp? 
+        # FIXME should we version this, maybe append a timestamp?
         node_config_data = "/var/lib/koan/config/localconfig.json"
         f = open(node_config_data, 'w')
         f.write(config)
@@ -814,21 +814,21 @@ class Koan:
         print "- Starting configuration run for %s" % (hostname)
         runtime_start = time.time()
         configure = configurator.KoanConfigure(config)
-        stats = configure.run() 
+        stats = configure.run()
         runtime_end = time.time()
-        
+
         if self.summary:
             pstats = (stats["pkg"]['nsync'],stats["pkg"]['osync'],stats["pkg"]['fail'],stats["pkg"]['runtime'])
             dstats = (stats["dir"]['nsync'],stats["dir"]['osync'],stats["dir"]['fail'],stats["dir"]['runtime'])
-            fstats = (stats["files"]['nsync'],stats["files"]['osync'],stats["files"]['fail'],stats["files"]['runtime'])                                          
-            
+            fstats = (stats["files"]['nsync'],stats["files"]['osync'],stats["files"]['fail'],stats["files"]['runtime'])
+
             nsync = pstats[0] + dstats[0] + fstats[0]
             osync = pstats[1] + dstats[1] + fstats[1]
             fail  = pstats[2] + dstats[2] + fstats[2]
-            
+
             total_resources = (nsync + osync + fail)
             total_runtime   = (runtime_end - runtime_start)
-           
+
             print
             print "\tResource Report"
             print "\t-------------------------"
@@ -838,15 +838,15 @@ class Koan:
             print "\t-------------------------"
             print "\tTotal Resources: %d" % total_resources
             print "\t  Total Runtime: %.02f" % total_runtime
-            
+
             for status in ["repos_status", "ldap_status", "monit_status"]:
                 if status in stats:
                     print
                     print "\t%s" % status
                     print "\t-------------------------"
                     print "\t%s" % stats[status]
-                    print "\t-------------------------"          
-            
+                    print "\t-------------------------"
+
             print
             print "\tResource |In Sync|OO Sync|Failed|Runtime"
             print "\t----------------------------------------"
@@ -856,7 +856,7 @@ class Koan:
             print
 
     #---------------------------------------------------
-  
+
     def kexec_replace(self):
         """
         Prepare to morph existing system by downloading new kernel and initrd
@@ -913,14 +913,14 @@ class Koan:
 
 
     #---------------------------------------------------
-        
+
     def get_boot_loader_info(self):
         if ANCIENT_PYTHON:
             # FIXME: implement this to work w/o subprocess
             if os.path.exists("/etc/grub.conf"):
                return (0, "grub")
             else:
-               return (0, "lilo") 
+               return (0, "lilo")
         cmd = [ "/sbin/grubby", "--bootloader-probe" ]
         probe_process = sub_process.Popen(cmd, stdout=sub_process.PIPE)
         which_loader = probe_process.communicate()[0]
@@ -942,7 +942,7 @@ class Koan:
         except OSError, (err, msg):
             if err != errno.EEXIST:
                 raise
-    
+
 
         def after_download(self, profile_data):
             if not os.path.exists("/sbin/grubby"):
@@ -1007,7 +1007,7 @@ class Koan:
             else:
                cmd.append("--make-default")
                cmd.append("--title=kick%s" % int(time.time()))
-               
+
             if self.live_cd:
                cmd.append("--bad-image-okay")
                cmd.append("--boot-filesystem=/")
@@ -1114,7 +1114,7 @@ class Koan:
         if data == {}:
             raise InfoException("No entry/entries found")
         return data
-    
+
     #---------------------------------------------------
 
     def get_ips(self,strdata):
@@ -1199,7 +1199,7 @@ class Koan:
             elif breed is not None and breed == "debian" or breed =="ubuntu":
                 kextra = "auto url=" + kickstart
             else:
-                kextra = "ks=" + kickstart 
+                kextra = "ks=" + kickstart
 
         if options !="":
             kextra = kextra + " " + options
@@ -1310,7 +1310,7 @@ class Koan:
                    return "failed"
                elif state == "shutdown":
                    print "- shutdown VM detected, is the install done?  Restarting!"
-                   utils.find_vm(conn, virtname).create()    
+                   utils.find_vm(conn, virtname).create()
                    return results
                else:
                    raise InfoException("internal error, bad virt state")
@@ -1351,7 +1351,7 @@ class Koan:
             import xencreate
             creator = xencreate.start_install
             if self.virt_type == "xenfv":
-               fullvirt = True 
+               fullvirt = True
             can_poll = "xen"
         elif self.virt_type == "qemu":
             fullvirt = True
@@ -1378,7 +1378,7 @@ class Koan:
         disks = []
         for p in paths:
             path = paths[counter]
-            if counter >= len(sizes): 
+            if counter >= len(sizes):
                 size = sizes[-1]
             else:
                 size = sizes[counter]
@@ -1426,7 +1426,7 @@ class Koan:
 
     def calc_virt_filesize(self,data,default_filesize=0):
 
-        # MAJOR FIXME: are there overrides?  
+        # MAJOR FIXME: are there overrides?
         size = self.safe_load(data,'virt_file_size','xen_file_size',0)
 
         tokens = str(size).split(",")
@@ -1491,7 +1491,7 @@ class Koan:
 
     def calc_virt_mac(self,data):
         if not self.is_virt:
-            return None # irrelevant 
+            return None # irrelevant
         if self.is_mac(self.system):
             return self.system.upper()
         return self.random_mac()
@@ -1500,7 +1500,7 @@ class Koan:
 
     def calc_virt_uuid(self,data):
         # TODO: eventually we may want to allow some koan CLI
-        # option (or cobbler system option) for passing in the UUID.  
+        # option (or cobbler system option) for passing in the UUID.
         # Until then, it's random.
         return None
         """
@@ -1551,7 +1551,7 @@ class Koan:
 
         # ok, so now we have a user that either through cobbler or some other
         # source *did* specify a location.   It might be a list.
-            
+
         virt_sizes = self.calc_virt_filesize(pd)
 
         path_splitted = location.split(",")
@@ -1568,12 +1568,12 @@ class Koan:
 
     def calc_virt_path2(self,pd,name,offset=0,location=None,sizes=[]):
 
-        # Parse the command line to determine if this is a 
+        # Parse the command line to determine if this is a
         # path, a partition, or a volume group parameter
         #   Ex:   /foo
         #   Ex:   partition:/dev/foo
         #   Ex:   volume-group:/dev/foo/
-            
+
         # chosing the disk image name (if applicable) is somewhat
         # complicated ...
 
@@ -1605,7 +1605,7 @@ class Koan:
 
             if vgnames.find(location) == -1:
                 raise InfoException, "The volume group [%s] does not exist." % location
-            
+
             # check free space
             args = "LANG=C vgs --noheadings -o vg_free --units g %s" % location
             print args
@@ -1619,20 +1619,20 @@ class Koan:
             virt_size = self.calc_virt_filesize(pd)
 
             if len(virt_size) > offset:
-                virt_size = sizes[offset] 
+                virt_size = sizes[offset]
             else:
                 return sizes[-1]
 
             if freespace >= int(virt_size):
-            
+
                 # look for LVM partition named foo, create if doesn't exist
                 args = "lvs -o lv_name %s" % location
                 print "%s" % args
                 lvs_str=sub_process.Popen(args, stdout=sub_process.PIPE, shell=True).communicate()[0]
                 print lvs_str
-         
+
                 name = "%s-disk%s" % (name,offset)
- 
+
                 # have to create it?
                 if lvs_str.find(name) == -1:
                     args = "lvcreate -L %sG -n %s %s" % (virt_size, name, location)
@@ -1661,7 +1661,7 @@ class Koan:
                     args = "/usr/sbin/semanage fcontext -a -t %s %s" % (context_type, partition_location)
                     print "%s" % args
                     change_context |= sub_process.call(args, close_fds=True, shell=True)
-                    
+
                     if change_context != 0:
                         raise InfoException, "SELinux security context setting to LVM partition failed"
 
diff --git a/koan/configurator.py b/koan/configurator.py
index de351fc..c2a3d63 100644
--- a/koan/configurator.py
+++ b/koan/configurator.py
@@ -45,15 +45,15 @@ except:
 class KoanConfigure:
     """
     Used for all configuration methods, used by koan
-    to configure repos, ldap, files, packages, and monit. 
+    to configure repos, ldap, files, packages, and monit.
     """
-    
+
     def __init__(self, config):
         """Constructor. Requires json config object."""
         self.config = json.JSONDecoder().decode(config)
         self.stats = {}
         self.dist = utils.check_dist()
-        
+
     #----------------------------------------------------------------------
 
     def configure_repos(self):
@@ -63,15 +63,15 @@ class KoanConfigure:
 
     def configure_yum_repos(self):
         """Configure YUM repositories."""
-        print "- Configuring Repos"  
+        print "- Configuring Repos"
         old_repo = '/etc/yum.repos.d/config.repo'
-        
+
         # Stage a tempfile to hold new file contents
         _tempfile = tempfile.NamedTemporaryFile()
         _tempfile.write(self.config['repo_data'])
         _tempfile.flush()
         new_repo = _tempfile.name
-        
+
         # Check if repo resource exist, create if missing
         if os.path.isfile(old_repo):
             if not filecmp.cmp(old_repo, new_repo):
@@ -85,7 +85,7 @@ class KoanConfigure:
             utils.sync_file(old_repo, new_repo, 0, 0, 644)
             self.stats['repos_status'] = "Success: Repos in sync"
         _tempfile.close()
-        
+
     #----------------------------------------------------------------------
 
     def configure_ldap(self):
@@ -96,9 +96,9 @@ class KoanConfigure:
             self.stats['ldap_status'] = "Success: LDAP has been configured"
         else:
             self.stats['ldap_status'] = "ERROR: configuring LDAP failed"
-    
+
     #----------------------------------------------------------------------
-        
+
     def configure_monit(self):
         """Start or reload Monit"""
         print "- Configuring Monit"
@@ -113,9 +113,9 @@ class KoanConfigure:
                 self.stats['monit_status'] = "Running: Monit has been started"
             else:
                 self.stats['monit_status'] = "Stopped: Failed to start monit"
-            
+
     #----------------------------------------------------------------------
-    
+
     def configure_packages(self):
         # Enables the possibility to use different types of package configurators
         if yum_available and self.dist == "redhat":
@@ -135,22 +135,22 @@ class KoanConfigure:
         yb.preconf.errorlevel = 0
         yb.doTsSetup()
         yb.doRpmDBSetup()
-        
+
         ybc = cli.YumBaseCli()
         ybc.preconf.debuglevel = 0
         ybc.preconf.errorlevel = 0
         ybc.conf.assumeyes = True
         ybc.doTsSetup()
         ybc.doRpmDBSetup()
-        
+
         create_pkg_list = []
-        remove_pkg_list = []   
+        remove_pkg_list = []
         for package in packages:
             action = packages[package]['action']
             # In the near future, will use install_name vs package
             # as it includes a more specific package name: "package-version"
-            install_name = packages[package]['install_name']  
-                    
+            install_name = packages[package]['install_name']
+
             if yb.isPackageInstalled(package):
                 if action == 'create':
                     nsync += 1
@@ -161,10 +161,10 @@ class KoanConfigure:
                     create_pkg_list.append(package)
                 if action == 'remove':
                     nsync += 1
-        
+
         # Don't waste time with YUM if there is nothing to do.
         doTransaction = False
-        
+
         if create_pkg_list:
             print "  Packages out of sync: %s" % create_pkg_list
             ybc.installPkgs(create_pkg_list)
@@ -178,13 +178,13 @@ class KoanConfigure:
         if doTransaction:
             ybc.buildTransaction()
             ybc.doTransaction()
-            
+
         runtime_end = time.time()
         runtime = (runtime_end - runtime_start)
         self.stats['pkg'] = {'runtime': runtime,'nsync': nsync,'osync': osync,'fail' : fail}
-    
+
     #----------------------------------------------------------------------
-   
+
     def configure_directories(self):
         """ Configure directory resources."""
         print "- Configuring Directories"
@@ -195,25 +195,25 @@ class KoanConfigure:
         files = self.config['files']
         # Split out directories
         _dirs  = [d for d in files if files[d]['is_dir']]
-        
+
         # Configure directories first
         for dir in _dirs:
             action  = files[dir]['action']
             odir = files[dir]['path']
-            
+
             protected_dirs = ['/','/bin','/boot','/dev','/etc','/lib','/lib64','/proc','/sbin','/sys','/usr','/var']
             if os.path.isdir(odir):
                 if os.path.realpath(odir) in protected_dirs:
                     print " %s is a protected directory, skipping..." % os.path.realpath(odir)
                     fail += 1
-                    continue          
-          
+                    continue
+
             if action == 'create':
                 nmode = int(files[dir]['mode'],8)
                 nuid  = pwd.getpwnam(files[dir]['owner'])[2]
-                ngid  = grp.getgrnam(files[dir]['group'])[2]  
-                
-                # Compare old and new directories, sync if permissions mismatch       
+                ngid  = grp.getgrnam(files[dir]['group'])[2]
+
+                # Compare old and new directories, sync if permissions mismatch
                 if os.path.isdir(odir):
                     dstat = os.stat(odir)
                     omode = stat.S_IMODE(dstat.st_mode)
@@ -242,9 +242,9 @@ class KoanConfigure:
         runtime_end = time.time()
         runtime = (runtime_end - runtime_start)
         self.stats['dir'] = {'runtime': runtime,'nsync': nsync,'osync': osync,'fail': fail}
-            
+
     #----------------------------------------------------------------------
-    
+
     def configure_files(self):
         """ Configure file resources."""
         print "- Configuring Files"
@@ -255,31 +255,31 @@ class KoanConfigure:
         files = self.config['files']
         # Split out files
         _files = [f for f in files if files[f]['is_dir'] is False]
-        
+
         for file in _files:
             action   = files[file]['action']
-            ofile = files[file]['path']         
-            
+            ofile = files[file]['path']
+
             if action == 'create':
                 nmode = int(files[file]['mode'],8)
                 nuid  = pwd.getpwnam(files[file]['owner'])[2]
                 ngid  = grp.getgrnam(files[file]['group'])[2]
-                
+
                 # Stage a tempfile to hold new file contents
                 _tempfile = tempfile.NamedTemporaryFile()
                 _tempfile.write(files[file]['content'])
                 _tempfile.flush()
-                nfile = _tempfile.name    
-                
+                nfile = _tempfile.name
+
                 # Compare new and old files, sync if permissions or contents mismatch
                 if os.path.isfile(ofile):
                     fstat = os.stat(ofile)
                     omode = stat.S_IMODE(fstat.st_mode)
                     ouid  = pwd.getpwuid(fstat.st_uid)[2]
-                    ogid  = grp.getgrgid(fstat.st_gid)[2]             
+                    ogid  = grp.getgrgid(fstat.st_gid)[2]
                     if not filecmp.cmp(ofile, nfile) or omode != nmode or ogid != ngid or ouid != nuid:
                         utils.sync_file(ofile, nfile, nuid, ngid, nmode)
-                        osync += 1      
+                        osync += 1
                     else:
                         nsync += 1
                 elif os.path.dirname(ofile):
@@ -299,17 +299,17 @@ class KoanConfigure:
                     nsync += 1
             else:
                 pass
-        
+
         runtime_end = time.time()
         runtime = (runtime_end - runtime_start)
         self.stats['files'] = {'runtime': runtime,'nsync': nsync,'osync': osync,'fail': fail}
-    
+
     #----------------------------------------------------------------------
-    
+
     def run(self):
-        # Configure resources in a specific order: repos, ldap, packages, directories, files, monit    
+        # Configure resources in a specific order: repos, ldap, packages, directories, files, monit
         if self.config['repos_enabled']:
-            self.configure_repos()    
+            self.configure_repos()
         if self.config['ldap_enabled']:
             self.configure_ldap()
         self.configure_packages()
@@ -317,5 +317,5 @@ class KoanConfigure:
         self.configure_files()
         if self.config['monit_enabled']:
             self.configure_monit()
-            
-        return self.stats
\ No newline at end of file
+
+        return self.stats
diff --git a/koan/imagecreate.py b/koan/imagecreate.py
index c336dcb..e9c3b77 100644
--- a/koan/imagecreate.py
+++ b/koan/imagecreate.py
@@ -60,12 +60,12 @@ def transform_arch(arch):
         return "i686"
     else:
         return arch
-        
+
 def copy_image(original_file, new_location):
     shutil.copyfile(original_file, new_location)
     return new_location
-    
-    
+
+
 def process_disk(image, boot, file, location, target):
     image_location = copy_image(file, location)
     # Create the disk
@@ -75,17 +75,17 @@ def process_disk(image, boot, file, location, target):
     disk.use = "user"
     disk.id = image_location
     image.storage[disk.id] = disk
-    
+
     #Create the drive
     drive = ImageParser.Drive()
     drive.id = image_location
-    drive.target = target 
+    drive.target = target
     drive.disk = disk
     boot.disks.append(drive)
     #dev api
-    #boot.drives.append(drive)  
-    
-    
+    #boot.drives.append(drive)
+
+
 def process_networks(domain, guest, profile_data, bridge):
     # Create a bridge or default network for every requested nic. If there are more
     # bridges then nics discard the last one.
@@ -95,57 +95,57 @@ def process_networks(domain, guest, profile_data, bridge):
     guest_bridge = bridge
     if guest_bridge is None:
         guest_bridge = profile_data["virt_bridge"]
-        
+
     # Look for commas
     if (guest_bridge is not None) and (len(guest_bridge.strip()) > 0):
         if guest_bridge.find(",") == -1:
             bridges.append(guest_bridge)
         else:
             bridges == guest_bridge.split(",")
-    
+
     for cnt in range(0,domain.interface):
         if cnt < len(bridges):
             nic = VirtualNetworkInterface(random_mac(), type="bridge", bridge = bridges[cnt])
             #dev api
-            #nic = VirtualNetworkInterface(random_mac(), type="bridge", bridge = bridge, conn=guest.conn)                
-        else: 
+            #nic = VirtualNetworkInterface(random_mac(), type="bridge", bridge = bridge, conn=guest.conn)
+        else:
             default_network = virtinst.util.default_network()
             #dev api
             #default_network = virtinst.util.default_network(guest.conn)
             nic = VirtualNetworkInterface(random_mac(), type=default_network[0], network=default_network[1])
         guest.nics.append(nic)
 
-def start_install(name=None, 
-                  ram=None, 
+def start_install(name=None,
+                  ram=None,
                   disks=None,
-                  uuid=None,  
-                  extra=None, 
-                  vcpus=None,  
-                  profile_data=None, 
-                  arch=None, 
-                  no_gfx=False, 
-                  fullvirt=False, 
-                  bridge=None, 
+                  uuid=None,
+                  extra=None,
+                  vcpus=None,
+                  profile_data=None,
+                  arch=None,
+                  no_gfx=False,
+                  fullvirt=False,
+                  bridge=None,
                   virt_type=None,
                   virt_auto_boot=False,
                   qemu_driver_type=None):
-                           
+
     #FIXME how to do a non-default connection
     #Can we drive off of virt-type?
     connection = None
-    
+
     if (virt_type is None ) or (virt_type == "auto"):
         connection = virtinst.util.default_connection()
     elif virt_type.lower()[0:3] == "xen":
         connection = "xen"
     else:
         connection = "qemu:///system"
-        
+
     connection = libvirt.open(connection)
-    capabilities = virtinst.CapabilitiesParser.parse(connection.getCapabilities())   
-    image_arch = transform_arch(arch)       
+    capabilities = virtinst.CapabilitiesParser.parse(connection.getCapabilities())
+    image_arch = transform_arch(arch)
 
-    image = ImageParser.Image() 
+    image = ImageParser.Image()
     #dev api
     #image = ImageParser.Image(filename="") #FIXME, ImageParser should take in None
     image.name = name
@@ -154,19 +154,19 @@ def start_install(name=None,
     domain.vcpu = vcpus
     domain.memory = ram
     image.domain = domain
-    
+
     boot = ImageParser.Boot()
     boot.type = "hvm" #FIXME HARDCODED
     boot.loader = "hd" #FIXME HARDCODED
     boot.arch = image_arch
     domain.boots.append(boot)
-    
+
     #FIXME Several issues. Single Disk, type is hardcoded
     #And there is no way to provision with access to "file"
     process_disk(image, boot, profile_data["file"], disks[0][0], "hda")
-    
+
     #FIXME boot_index??
-    installer = virtinst.ImageInstaller(boot_index = 0, image=image, capabilities=capabilities)                               
+    installer = virtinst.ImageInstaller(boot_index = 0, image=image, capabilities=capabilities)
     guest = virtinst.FullVirtGuest(connection = connection, installer=installer, arch=image_arch)
 
     extra = extra.replace("&","&amp;")
@@ -183,10 +183,10 @@ def start_install(name=None,
 
     if uuid is not None:
         guest.set_uuid(uuid)
-                   
-    process_networks(domain, guest, profile_data, bridge)                   
-    
+
+    process_networks(domain, guest, profile_data, bridge)
+
     guest.start_install()
-    
-    return "use virt-manager or reconnect with virsh console %s" % name 
-     
+
+    return "use virt-manager or reconnect with virsh console %s" % name
+
diff --git a/koan/qcreate.py b/koan/qcreate.py
index 1116b19..5e123ab 100755
--- a/koan/qcreate.py
+++ b/koan/qcreate.py
@@ -1,5 +1,5 @@
 """
-Virtualization installation functions.  
+Virtualization installation functions.
 
 Copyright 2007-2008 Red Hat, Inc.
 Michael DeHaan <mdehaan@redhat.com>
@@ -86,11 +86,11 @@ def start_install(name=None,
     guest = virtinst.FullVirtGuest(hypervisorURI="qemu:///system",type=vtype, arch=arch)
 
     if not profile_data.has_key("file"):
-        # images don't need to source this 
+        # images don't need to source this
         if not profile_data.has_key("install_tree"):
             raise koan.InfoException("Cannot find install source in kickstart file, aborting.")
-   
- 
+
+
         if not profile_data["install_tree"].endswith("/"):
             profile_data["install_tree"] = profile_data["install_tree"] + "/"
 
@@ -107,7 +107,7 @@ def start_install(name=None,
             guest.cdrom = input_path
         else:
             (tempdir, filename) = utils.nfsmount(input_path)
-            guest.cdrom = os.path.join(tempdir, filename)     
+            guest.cdrom = os.path.join(tempdir, filename)
 
         kickstart = profile_data.get("kickstart","")
         if kickstart != "":
@@ -116,12 +116,12 @@ def start_install(name=None,
             print "I want to make a floppy for %s" % kickstart
             floppy_path = utils.make_floppy(kickstart)
             guest.disks.append(virtinst.VirtualDisk(device=virtinst.VirtualDisk.DEVICE_FLOPPY, path=floppy_path))
-        
+
 
     else:
         guest.location = profile_data["install_tree"]
-   
-    extra = extra.replace("&","&amp;") 
+
+    extra = extra.replace("&","&amp;")
     guest.extraargs = extra
 
     if profile_data.has_key("breed"):
@@ -201,7 +201,7 @@ def start_install(name=None,
                 if bridge.find(",") == -1:
                     intf_bridge = bridge
                 else:
-                    bridges = bridge.split(",")  
+                    bridges = bridge.split(",")
                     intf_bridge = bridges[counter]
             nic_obj = virtinst.VirtualNetworkInterface(macaddr=mac, bridge=intf_bridge, model=qemu_net_type)
             guest.nics.append(nic_obj)
diff --git a/koan/register.py b/koan/register.py
index 1a208bc..3ec9d3f 100755
--- a/koan/register.py
+++ b/koan/register.py
@@ -8,12 +8,12 @@ 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
@@ -130,12 +130,12 @@ class Register:
         """
         Commence with the registration already.
         """
-      
+
         # not really required, but probably best that ordinary users don't try
         # to run this not knowing what it does.
         if os.getuid() != 0:
            raise InfoException("root access is required to register")
- 
+
         print "- preparing to koan home"
         self.conn = utils.connect_to_server(self.server, self.port)
         reg_info = {}
@@ -149,7 +149,7 @@ class Register:
             sysname  = self.hostname
         else:
             hostname = socket.getfqdn()
-            if hostname == "localhost.localdomain": 
+            if hostname == "localhost.localdomain":
                 if self.hostname == '*AUTO*':
                     hostname = ""
                     sysname = str(time.time())
@@ -170,13 +170,13 @@ class Register:
             if x.get("name","") == self.profile:
                matched_profile=True
                break
-        
+
         reg_info['name'] = sysname
         reg_info['profile'] = self.profile
         reg_info['hostname'] = hostname
-        
+
         if not matched_profile:
-            raise InfoException("no such remote profile, see 'koan --list-profiles'") 
+            raise InfoException("no such remote profile, see 'koan --list-profiles'")
 
         if not self.batch:
             self.conn.register_new_system(reg_info)
@@ -190,7 +190,7 @@ class Register:
                 print "- registration failed, ignoring because of --batch"
 
         return
-   
+
 if __name__ == "__main__":
     main()
- 
+
diff --git a/koan/utils.py b/koan/utils.py
index 5ce1a00..262087a 100644
--- a/koan/utils.py
+++ b/koan/utils.py
@@ -99,7 +99,7 @@ def setupLogging(appname):
 
 def urlread(url):
     """
-    to support more distributions, implement (roughly) some 
+    to support more distributions, implement (roughly) some
     parts of urlread and urlgrab from urlgrabber, in ways that
     are less cool and less efficient.
     """
@@ -124,7 +124,7 @@ def urlread(url):
         except:
             traceback.print_exc()
             raise InfoException, "Couldn't mount and read URL: %s" % url
-          
+
     elif url[0:4] == "http":
         try:
             fd = urllib2.urlopen(url)
@@ -149,7 +149,7 @@ def urlread(url):
             return data
         except:
             raise InfoException, "Couldn't read file from URL: %s" % url
-              
+
     else:
         raise InfoException, "Unhandled URL protocol: %s" % url
 
@@ -286,7 +286,7 @@ def find_vm(conn, vmid):
     for id in ids:
         vm = conn.lookupByID(id)
         vms.append(vm)
-        
+
     # get defined domain
     names = conn.listDefinedDomains()
     for name in names:
@@ -299,7 +299,7 @@ def find_vm(conn, vmid):
     for vm in vms:
         if vm.name() == vmid:
             return vm
-     
+
     raise InfoException("koan could not find the VM to watch: %s" % vmid)
 
 def get_vm_state(conn, vmid):
@@ -312,7 +312,7 @@ def get_vm_state(conn, vmid):
 
 def check_dist():
     """
-    Determines what distro we're running under.  
+    Determines what distro we're running under.
     """
     if os.path.exists("/etc/debian_version"):
        import lsb_release
@@ -436,9 +436,9 @@ def connect_to_server(server=None,port=None):
     if server == "":
         raise InfoException("--server must be specified")
 
-    if port is None: 
+    if port is None:
         port = 80
-        
+
     connect_ok = 0
 
     try_urls = [
@@ -511,7 +511,7 @@ def make_floppy(kickstart):
     save_file = os.path.join(mount_path, "unattended.txt")
     urlgrabber.urlgrab(kickstart,filename=save_file)
 
-    # umount    
+    # umount
     cmd = "umount %s" % mount_path
     print "- %s" % cmd
     rc = os.system(cmd)
diff --git a/koan/vmwcreate.py b/koan/vmwcreate.py
index b7ef448..a12dab4 100755
--- a/koan/vmwcreate.py
+++ b/koan/vmwcreate.py
@@ -1,5 +1,5 @@
 """
-Virtualization installation functions.  
+Virtualization installation functions.
 
 Copyright 2007-2008 Red Hat, Inc.
 Michael DeHaan <mdehaan@redhat.com>
@@ -106,7 +106,7 @@ def register_vmx(vmx_file):
     rc = os.system(cmd)
     if rc!=0:
        raise VirtCreateException("vmware registration failed")
-    
+
 def start_vm(vmx_file):
     os.chmod(vmx_file,0755)
     cmd = "vmware-cmd %s start" % vmx_file
@@ -115,18 +115,18 @@ def start_vm(vmx_file):
     if rc != 0:
        raise VirtCreateException("vm start failed")
 
-def start_install(name=None, 
-                  ram=None, 
-                  disks=None, 
+def start_install(name=None,
+                  ram=None,
+                  disks=None,
                   mac=None,
-                  uuid=None,  
+                  uuid=None,
                   extra=None,
-                  vcpus=None, 
-                  profile_data=None, 
-                  arch=None, 
-                  no_gfx=False, 
-                  fullvirt=True, 
-                  bridge=None, 
+                  vcpus=None,
+                  profile_data=None,
+                  arch=None,
+                  no_gfx=False,
+                  fullvirt=True,
+                  bridge=None,
                   virt_type=None,
                   virt_auto_boot=False,
                   qemu_driver_type=None):
diff --git a/koan/xencreate.py b/koan/xencreate.py
index 2228d69..acd23d0 100755
--- a/koan/xencreate.py
+++ b/koan/xencreate.py
@@ -1,5 +1,5 @@
 """
-Virtualization installation functions.  
+Virtualization installation functions.
 Currently somewhat Xen/paravirt specific, will evolve later.
 
 Copyright 2006-2008 Red Hat, Inc.
@@ -58,17 +58,17 @@ def random_mac():
     return ':'.join(map(lambda x: "%02x" % x, mac))
 
 
-def start_install(name=None, 
-                  ram=None, 
+def start_install(name=None,
+                  ram=None,
                   disks=None,
-                  uuid=None,  
-                  extra=None, 
-                  vcpus=None,  
-                  profile_data=None, 
-                  arch=None, 
-                  no_gfx=False, 
-                  fullvirt=False, 
-                  bridge=None, 
+                  uuid=None,
+                  extra=None,
+                  vcpus=None,
+                  profile_data=None,
+                  arch=None,
+                  no_gfx=False,
+                  fullvirt=False,
+                  bridge=None,
                   virt_type=None,
                   virt_auto_boot=False,
                   qemu_driver_type=None):
@@ -169,7 +169,7 @@ def start_install(name=None,
             nic_obj = virtinst.XenNetworkInterface(macaddr=mac, bridge=intf_bridge)
             guest.nics.append(nic_obj)
             counter = counter + 1
-   
+
     else:
             # for --profile you just get one NIC, go define a system if you want more.
             # FIXME: can mac still be sent on command line in this case?
@@ -184,11 +184,11 @@ def start_install(name=None,
 
             nic_obj = virtinst.XenNetworkInterface(macaddr=random_mac(), bridge=profile_bridge)
             guest.nics.append(nic_obj)
-            
-        
+
+
 
 
     guest.start_install()
-    
-    return "use virt-manager or reconnect with virsh console %s" % name 
-     
+
+    return "use virt-manager or reconnect with virsh console %s" % name
+
-- 
1.7.3.4

