[Et-mgmt-commits-list] [SCM] cobbler branch, master now at v0.4.8-68-g94661f5

Michael DeHaan mdehaan at redhat.com
Mon Jul 9 16:03:32 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  94661f57c1e8a33688f20594dc304ce30ccd3ec1 (commit)
      from  224bb933094abd526c864f8ad6acd9be19e65130 (commit)

- Log -----------------------------------------------------------------
commit 94661f57c1e8a33688f20594dc304ce30ccd3ec1
Author: Michael DeHaan <mdehaan at mdehaan.rdu.redhat.com>
Date:   Mon Jul 9 12:05:13 2007 -0400

    Adding kickstart serving CGI script.
    Also fixing one error in the utils module.
-----------------------------------------------------------------------

Diffstat:
 AUTHORS            |    1 +
 MANIFEST.in        |    1 +
 cobbler.spec       |    3 +-
 cobbler/utils.py   |    2 +-
 scripts/findks.cgi |  116 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 setup.py           |    2 +
 6 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index b357819..b64031a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -16,6 +16,7 @@ Patches and other contributions from:
     Perry Myers <pmyers at redhat.com>
     Adam Rosenwald <thestrider at gmail.com>
     Scott Seago <sseago at redhat.com>
+    Adam Wolf <adamwolf at feelslikeburning.com>
 
     [...send patches to get your name here...]
 
diff --git a/MANIFEST.in b/MANIFEST.in
index d34e23a..5b23157 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -11,5 +11,6 @@ include docs/cobbler.1.gz
 include COPYING AUTHORS README CHANGELOG NEWS
 include scripts/watcher.py
 include scripts/cobblerd
+include scripts/findks.cgi
 recursive-include po *.pot
 recursive-include po *.po
diff --git a/cobbler.spec b/cobbler.spec
index d37d7f2..0eb814e 100644
--- a/cobbler.spec
+++ b/cobbler.spec
@@ -68,7 +68,8 @@ fi
 test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
 
 %files
-%defattr(2755,apache,apache)
+%defattr(2744,apache,apache)
+/var/www/cgi-bin/findks.cgi
 %dir /var/log/cobbler
 %dir /var/log/cobbler/kicklog
 %dir /var/www/cobbler/
diff --git a/cobbler/utils.py b/cobbler/utils.py
index acc748b..e9705e4 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -70,7 +70,7 @@ def get_config_filename(sys):
     if mac != None:
         return "01-" + "-".join(mac.split(":")).lower()
     elif ip != None:
-        return utils.get_host_ip(ip)
+        return get_host_ip(ip)
     else:
         return sys.name
 
diff --git a/scripts/findks.cgi b/scripts/findks.cgi
new file mode 100755
index 0000000..be8afdf
--- /dev/null
+++ b/scripts/findks.cgi
@@ -0,0 +1,116 @@
+#!/usr/bin/env python
+
+# This software may be freely redistributed under the terms of the GNU
+# general public license.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+# based on:
+# Cobbler ks-serving script
+# July 5 2007
+# Adam Wolf <adamwolf at feelslikeburning.com>
+# http://feelslikeburning.com/projects/live-cd-restoring-with-cobbler/
+
+import cgi
+import cgitb
+import time
+import os
+import sys
+import socket
+import xmlrpclib
+
+COBBLER_BASE = "/var/www/cobbler"
+XMLRPC_SERVER = "http://127.0.0.1:25151"
+
+#----------------------------------------------------------------------
+
+class ServerProxy(xmlrpclib.ServerProxy):
+
+    def __init__(self, url=None):
+        xmlrpclib.ServerProxy.__init__(self, url, allow_none=True)
+
+#----------------------------------------------------------------------
+
+def parse_query():
+
+    form = cgi.parse()
+
+    if form.has_key("system"):
+        name = form["system"][0]
+        type = "system"
+    elif form.has_key("profile"):
+        name = form["profile"][0]
+        type = "profile"
+    else:
+        type = "system"
+        name = autodetect_ip()
+    return (name,type)
+
+#----------------------------------------------------------------------
+
+def autodetect_ip():
+
+    ip = os.environ["REMOTE_ADDR"]
+    xmlrpc_server = ServerProxy(XMLRPC_SERVER)
+    systems = xmlrpc_server.get_systems()
+    candidates = [system['name'] for system in systems if system['ip_address'] == ip]
+
+    if len(candidates) == 0:
+	print "# No system entries with ip %s found" % ip
+	sys.exit(1)
+    elif len(candidates) > 1:
+	print "# Multiple system entries with ip %s found" % ip
+	sys.exit(1)
+    elif len(candidates) == 1:
+	return candidates[0]
+
+#----------------------------------------------------------------------
+
+def serve_file(name):
+
+    # never hurts to be safe...
+    name = name.replace("/","")
+    name = name.replace("..","")
+    name = name.replace(";","")
+
+    if type == "system":
+        ks_path = "%s/kickstarts_sys/%s/ks.cfg" % (COBBLER_BASE, name)
+    elif type == "profile":
+        ks_path = "%s/kickstarts/%s/ks.cfg" % (COBBLER_BASE, name)
+
+    if not os.path.exists(ks_path):
+        print "# No such cobbler object"
+        sys.exit(1)
+
+    try:
+        ksfile = open(ks_path)
+    except:
+        print "# Cannot open file %s" % ks_path
+        sys.exit(1)
+
+    for line in ksfile:
+        print line.strip()
+    ksfile.close()
+
+#----------------------------------------------------------------------
+
+def header():
+    print "Content-type: text/plain"
+    print
+
+#----------------------------------------------------------------------
+
+if __name__ == "__main__":
+    cgitb.enable(format='text')
+    header()
+    (name, type) = parse_query()
+    print "# kickstart for cobbler %s %s" % (type,name)
+    print "# served on %s" % time.ctime() 
+    print "# requestor ip = %s" % os.environ["REMOTE_ADDR"]
+    print "# ============================="
+    print " "
+    serve_file(name)
+
+
diff --git a/setup.py b/setup.py
index 064105c..b9e1c4b 100644
--- a/setup.py
+++ b/setup.py
@@ -35,6 +35,7 @@ if __name__ == "__main__":
         tftp_cfg      = "/tftpboot/pxelinux.cfg"
         tftp_images   = "/tftpboot/images"
         rotpath       = "/etc/logrotate.d"
+        cgipath       = "/var/www/cgi-bin"
         setup(
                 name="cobbler",
                 version = VERSION,
@@ -48,6 +49,7 @@ if __name__ == "__main__":
                 ],
                 scripts = ["scripts/cobbler", "scripts/cobblerd"],
                 data_files = [ 
+                                (cgipath,  ['scripts/findks.cgi']),
                                 (rotpath,  ['config/cobblerd_rotate']),
                                 (wwwconf,  ['config/cobbler.conf']),
                                 (cobpath,  ['loaders/elilo-3.6-ia64.efi']),

hooks/update
---
Git Source Code Management System
hooks/update refs/heads/master \
  224bb933094abd526c864f8ad6acd9be19e65130 \
  94661f57c1e8a33688f20594dc304ce30ccd3ec1




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