[Et-mgmt-commits-list] [SCM] koan branch, master now at v0.2.9-31-g9660caf

Michael DeHaan mdehaan at redhat.com
Fri Jul 13 20:06:31 UTC 2007


Hello,

This is an automated email from the git hooks/update script, it was
generated because a ref change was pushed to the repository.

Updating branch, master,
       via  9660caf2349731f314dd577827fb579e8d3bbab6 (commit)
      from  707d46f92ff33cd39fd20d5999feb8639b651d70 (commit)

- Log -----------------------------------------------------------------
commit 9660caf2349731f314dd577827fb579e8d3bbab6
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Fri Jul 13 16:08:22 2007 -0400

    Misc fixes...
-----------------------------------------------------------------------

Diffstat:
 koan.pod    |   45 ++++++++++++++++++--
 koan/app.py |  133 ++++++++++++++++++++++++++++++++++-------------------------
 2 files changed, 118 insertions(+), 60 deletions(-)

diff --git a/koan.pod b/koan.pod
index 7fc1e0c..359aaa2 100644
--- a/koan.pod
+++ b/koan.pod
@@ -6,15 +6,13 @@ koan stands for "kickstart-over-a-network" and allows for both network provision
 
 koan --server=<host> [--list-profiles|--list-systems]
 
-koan --server=<host> --virt [--profile=<name>|--system=<name>] [--virt-name=<name>] [--virt-path=<path>] [--virt-type=<type>]
-
-koan --server=<host> --replace-self [--profile=<name>|--system=<name>]
+koan --server=<host> [--virt|--replace-self|--display] [--profile=<name>|--system=<name>] [--virt-name=<name>] [--virt-path=<path>] [--virt-type=<type>]
 
 =head1 DESCRIPTION
 
 When invoked, koan requests install information from a remote cobbler boot server.   What koan does with the profile data depends on whether it was invoked with --virt or --replace-self.
 
-=head1 COMMON ARGUMENTS
+=head1 THE COBBLER SERVER
 
 =over 
 
@@ -24,6 +22,16 @@ Indicates the hostname of the Cobbler boot server to be contacted.  Successful
 communication requires that no firewalls are blocking the cobbler XMLRPC port,
 which is usually 25151, and that "cobblerd" is running on the cobbler server.
 
+This argument must be specified for all koan commands.
+
+=back
+
+=head1 LISTING AVAILABLE RESOURCES
+
+Lists of the resources that can be installed from a remote server can be obtained by using the following commands:
+
+=over
+
 =item --list-profiles
 
 Shows a list of profiles that can be remotely installed from the cobbler server.
@@ -32,6 +40,18 @@ Shows a list of profiles that can be remotely installed from the cobbler server.
 
 Shows a list of systems that can be remotely installed from the cobbler server.  Systems contain the same information as profiles but may be further customized in terms of parameters or kickstart information.  The level of customization varies depending on what has been specified on the cobbler server.
 
+=back
+
+Example:  koan --server=cobbler.example.org --list-systems
+
+=back
+
+=head1 MAIN COMMANDS
+
+The commands --virt, --replace-self, and --display all take the following arguments:
+
+=over
+
 =item --profile
 
 Names a profile, known to cobbler, that is to be installed.
@@ -43,10 +63,21 @@ be used at the same time as --profile; pick one or the other.
 
 =back
 
+=head1 VIEWING THE INSTALLATION DATA
+
+In depth data about what is being installed can be viewed prior to
+kicking off an installation.  Use --display instead of --virt or
+--replace-self.  When using this argument, specify the data to display
+with --profile or --system.
+
+Example:  koan --server=cobbler.example.org --display --profile=fedora7-xen-i386
+
 =head1 VIRTUALIZED INSTALLS
 
 When using --virt, koan will create new virtualized guests on a machine in accordance to the orders from cobbler.  You can then, once finished, use "virsh" and "xm" commands to access the guest.  These can be Xen or QEMU/KVM guests.
 
+Example:  koan --server=cobbler.example.org --virt --profile=fedora7-xen-i386
+
 If --profile is specified, cobbler will default to naming domains based on their mac addresses, using --system will use the exact name given to the cobbler system object.  To install using a more descriptive name, specify one with --virtname.  
 
 The additional parameters --virt-path, and --virt-type allow overriding certain defaults that are ordinarily defined by the remote cobbler server.
@@ -71,6 +102,8 @@ will provide reasonable defaults.
 
 =back
 
+Example:  koan --server=cobbler.example.org --virt --profile=rhel5-x86_64 --virt-type="qemu" --virt-path="/home/username/qemu/" --virt-name="test_setup"
+
 =head1 REINSTALLATION 
 
 When using '--replace-self', cobbler will reprovision the system, blowing away any current data and replacing it with the results of a network install.  Specify a specific item from cobbler with --system or --profile, otherwise cobbler will try to see if there is a cobbler system record that matches a MAC address on the system.
@@ -79,6 +112,10 @@ This is useful to reinstall systems in conditions where ordinary PXE is not poss
 
 After using this feature, run "/sbin/reboot" to initiate the fully automatic reinstallation.
 
+Example:  koan --server=cobbler.example.org --profile=fedora7-xen-i386 --replace-self
+
+Example:  koan --server=cobbler.example.org --replace-self
+
 =head1 NOTES FOR USERS OF COBBLER TEMPLATING
 
 Cobbler contains a templating feature that allows a single kickstart file to be customized on a per-system basis.  See the cobbler manpage for more details.
diff --git a/koan/app.py b/koan/app.py
index 17b455e..8072bcd 100755
--- a/koan/app.py
+++ b/koan/app.py
@@ -38,6 +38,15 @@ koan --virt [--profile=webserver|--system=name] --server=hostname
 koan --replace-self --profile=foo --server=hostname
 """
 
+DISPLAY_PARAMS = [
+   "name",
+   "distro","profile",
+   "kernel","initrd",
+   "kernel_options","kickstart","ks_meta",
+   "repos",
+   "virt_ram","virt_disk","virt_type", "virt_path"
+]
+
 def main():
     """
     Command line stuff...
@@ -55,10 +64,6 @@ def main():
                  dest="list_systems",
                  action="store_true",
                  help="list systems the server can provision")
-    p.add_option("-x", "--xen",
-                 dest="is_virt",
-                 action="store_true",
-                 help="alias for --virt")
     p.add_option("-v", "--virt",
                  dest="is_virt",
                  action="store_true",
@@ -70,6 +75,10 @@ def main():
                  dest="is_replace",
                  action="store_true",
                  help="requests re-provisioning of this host")
+    p.add_option("-D", "--display",
+                 dest="is_display",
+                 action="store_true",
+                 help="display the configuration, don't install it")
     p.add_option("-p", "--profile",
                  dest="profile",
                  help="cobbler profile to install")
@@ -79,10 +88,6 @@ def main():
     p.add_option("-s", "--server",
                  dest="server",
                  help="specify the cobbler server")
-    p.add_option("-q", "--quiet",
-                 dest="verbose",
-                 action="store_false",
-                 help="run (more) quietly")
     p.add_option("-t", "--port",
                  dest="port",
                  help="cobbler xmlrpc port (default 25151)")
@@ -95,13 +100,8 @@ def main():
  
     (options, args) = p.parse_args()
 
-    full_access = 1
-    for x in [ "/etc", "/boot", "/var/spool"]:
-        if not os.access(x, os.O_RDWR):
-            print "Unable to write to %s (which usually means root)" % x
-            full_access = 0
-
-    if not full_access:
+    if not os.getuid() == 0:
+        print "koan requires root access"
         return 3
 
     try:
@@ -111,9 +111,9 @@ def main():
         k.server            = options.server
         k.is_virt           = options.is_virt
         k.is_replace        = options.is_replace
+        k.is_display        = options.is_display
         k.profile           = options.profile
         k.system            = options.system
-        k.verbose           = options.verbose
         k.live_cd           = options.live_cd
         k.virt_path         = options.virt_path
         k.virt_type         = options.virt_type
@@ -159,7 +159,6 @@ class Koan:
         self.profile           = None
         self.list_profiles     = None
         self.list_systems      = None
-        self.verbose           = None
         self.is_virt           = None
         self.is_replace        = None
         self.dryrun            = None
@@ -177,30 +176,32 @@ class Koan:
         self.xmlrpc_server = ServerProxy(url)
         if self.list_systems:
             self.do_list_systems()
+            return
         if self.list_profiles:
             self.do_list_profiles()
+            return
         if (self.list_systems or self.list_profiles):
             return
-	if not self.is_virt and not self.is_replace:
-            raise InfoException, "--virt or --replace-self is required"
-        if self.is_virt and self.is_replace:
-            raise InfoException, "--virt or --replace-self is required"
-        if self.is_virt and not self.profile and not self.system:
-            raise InfoException, "--profile or --system is required"
-        if self.verbose is None:
-            self.verbose = True
+        found = 0
+        for x in (self.is_virt, self.is_replace, self.is_display):
+            if x:
+               found = found+1
+        if found != 1:
+            raise InfoException, "choose: --virt, --replace-self or --display"
+
         if (not self.profile and not self.system):
             self.system = self.autodetect_system()
-        if self.profile and self.system:
-            raise InfoException, "--profile and --system are exclusive"
+
         if self.virt_type is not None:
             if self.virt_type not in [ "qemu", "xenpv" ]:
                raise InfoException, "--virttype should be qemu or xenpv"
 
         if self.is_virt:
             self.do_virt()
-        else:
+        elif self.is_replace:
             self.do_replace()
+        else:
+            self.do_display()
     
     #---------------------------------------------------
 
@@ -249,9 +250,8 @@ class Koan:
 
     def mkdir(self,path):
         """
-        A more verbose and tolerant mkdir
+        A more tolerant mkdir
         """
-        print "mkdir: %s" % path
         try:
             os.mkdir(path)
         except OSError, (err, msg):
@@ -262,9 +262,8 @@ class Koan:
 
     def rmtree(self,path):
         """
-        A more verbose and tolerant rmtree
+        A more tolerant rmtree
         """
-        print "removing: %s" % path
         try:
             shutil.rmtree(path)
         except OSError, (err, msg):
@@ -277,7 +276,7 @@ class Koan:
         """
         Wrapper around subprocess.call(...)
         """
-        print cmd
+        print "- %s" % cmd
         rc = sub_process.call(cmd)
         if rc != 0 and not ignore_rc:
             raise InfoException, "command failed (%s)" % rc
@@ -295,10 +294,12 @@ class Koan:
 
     #---------------------------------------------------
 
-    def do_net_install(self,download_root,after_download):
+    def do_net_install(self,after_download):
         """
         Actually kicks off downloads and auto-ks or virt installs
         """
+
+        # load the data via XMLRPC
         if self.profile:
             profile_data = self.get_profile_xmlrpc(self.profile)
             filler = "kickstarts"
@@ -308,7 +309,32 @@ class Koan:
         if profile_data.has_key("kickstart"):
             if profile_data["kickstart"].startswith("/"):
                profile_data["kickstart"] = "http://%s/cblr/%s/%s/ks.cfg" % (profile_data['server'], filler, profile_data['name'])
-        self.get_distro_files(profile_data, download_root)
+       
+        # find the correct file download location 
+        if not self.is_virt:
+            download = "/boot"
+            if self.live_cd:
+                download = "/tmp/boot/boot"
+
+        else:
+            # ensure we have a good virt type choice and know where
+            # to download the kernel/initrd
+            if self.virt_type is None:
+                self.virt_type = self.safe_load(profile_data,'virt_type',default=None)
+            if self.virt_type is None:
+                self.virt_type = 'xenpv'
+
+            if self.virt_type == "xenpv":
+                download = "/var/lib/xen" 
+            else:
+                # FIXME: should use temp dir to allow parallel installs?
+                download = "/var/spool/koan" 
+
+        # download required files
+        if not self.is_display:
+           self.get_distro_files(profile_data, download)
+  
+        # perform specified action
         after_download(self, profile_data)
 
     #---------------------------------------------------
@@ -342,6 +368,15 @@ class Koan:
         return True
 
     #---------------------------------------------------
+
+    def do_display(self):
+        def after_download(self, profile_data):
+            for x in DISPLAY_PARAMS:
+                if profile_data.has_key(x):
+                    print "%20s  : %s" % (x, profile_data[x])
+        return self.do_net_install(after_download)
+
+    #---------------------------------------------------
                  
     def do_virt(self):
         """
@@ -351,19 +386,7 @@ class Koan:
         def after_download(self, profile_data):
             self.do_virt_net_install(profile_data)
 
-        # ensure we have a good virt type choice and know where
-        # to download the kernel/initrd
-        if self.virt_type is None:
-            self.virt_type = self.safe_load(profile_data,'virt_type',default=None)
-        if self.virt_type is None:
-            self.virt_type = 'xenpv'
-        if self.virt_type == "xenpv":
-            download = "/var/lib/xen" 
-        else:
-            # FIXME: should use temp dir to allow parallel installs?
-            download = "/var/spool/koan" 
-
-        return self.do_net_install(download,after_download)
+        return self.do_net_install(after_download)
 
     #---------------------------------------------------
 
@@ -413,20 +436,17 @@ class Koan:
                cmd.append("--bad-image-okay")
                cmd.append("--boot-filesystem=/dev/sda1")
                cmd.append("--config-file=/tmp/boot/boot/grub/grub.conf")
-            self.subprocess_call(cmd, fake_it=self.dryrun)
+            self.subprocess_call(cmd)
 
             if loader == "--lilo":
                 print "- applying lilo changes"
                 cmd = [ "/sbin/lilo" ]
                 sub_process.Popen(cmd, stdout=sub_process.PIPE).communicate()[0]
 
-            print "reboot to apply changes"
+            print "- reboot to apply changes"
 
-        boot_path = "/boot"
-        if self.live_cd:
-            boot_path = "/tmp/boot/boot"
 
-        return self.do_net_install(boot_path,after_download)
+        return self.do_net_install(after_download)
 
     #---------------------------------------------------
 
@@ -452,7 +472,7 @@ class Koan:
             self.subprocess_call(cmd)
             return data
         elif kickstart.startswith("http") or kickstart.startswith("ftp"):
-            print "urlread %s" % kickstart
+            print "- downloading %s" % kickstart
             try:
                 return self.urlread(kickstart)
             except:
@@ -593,7 +613,6 @@ class Koan:
             self.connect_fail()
         if system_data == {}:
             raise InfoException("no cobbler entry for system")        
-        print system_data
         return system_data
 
     #---------------------------------------------------
@@ -676,6 +695,8 @@ class Koan:
             mac     = None
             uuid    = None
             creator = qcreate.start_install
+        else:
+            raise InfoException, "Unspecified virt type: %s" % self.virt_type
 
         results = creator(
                 name         =  name,

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  707d46f92ff33cd39fd20d5999feb8639b651d70 \
  9660caf2349731f314dd577827fb579e8d3bbab6




More information about the Et-mgmt-commits-list mailing list