summaryrefslogtreecommitdiffstats
path: root/scripts/services.py
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-04-18 17:31:26 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-04-18 17:31:26 -0400
commitefbcc041464733e90af670a5d1dfe13e70aaa05c (patch)
treee04450dfaed37ad8757f0e96d5314d36a46444b0 /scripts/services.py
parentb15ca0fe01a01ee6792c857e766642d9d50ab760 (diff)
downloadthird_party-cobbler-efbcc041464733e90af670a5d1dfe13e70aaa05c.tar.gz
third_party-cobbler-efbcc041464733e90af670a5d1dfe13e70aaa05c.tar.xz
third_party-cobbler-efbcc041464733e90af670a5d1dfe13e70aaa05c.zip
Kickstarts are now dynamically generated by mod_python, CGI's now fall
under mod_python, kickstart templating code now moved out of sync function.
Diffstat (limited to 'scripts/services.py')
-rwxr-xr-xscripts/services.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/services.py b/scripts/services.py
new file mode 100755
index 0000000..07243ae
--- /dev/null
+++ b/scripts/services.py
@@ -0,0 +1,67 @@
+"""
+mod_python gateway to cgi-like cobbler web functions
+
+Copyright 2007-2008, Red Hat, Inc
+Michael DeHaan <mdehaan@redhat.com>
+
+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.
+"""
+
+from mod_python import apache
+from mod_python import Session
+from mod_python import util
+
+import xmlrpclib
+import cgi
+import os
+from cobbler.services import CobblerSvc
+
+#=======================================
+
+def handler(req):
+
+ """
+ Right now, index serves everything.
+
+ Hitting this URL means we've already cleared authn/authz
+ but we still need to use the token for all remote requests.
+ """
+
+ my_uri = req.uri
+
+ # apache.log_error("cannot load /var/lib/cobbler/web.ss")
+ req.add_common_vars()
+
+ # process form and qs data, if any
+ fs = util.FieldStorage(req)
+ form = {}
+ for x in fs.keys():
+ form[x] = str(fs.get(x,'default'))
+
+ form["REMOTE_ADDR"] = req.subprocess_env.get("REMOTE_ADDR",None)
+ form["REMOTE_MAC"] = req.subprocess_env.get("HTTP_X_RHN_PROVISIONING_MAC_0",None)
+
+ # instantiate a CobblerWeb object
+ cw = CobblerSvc(
+ apache = apache,
+ server = "http://127.0.0.1/cobbler_api"
+ )
+
+ # check for a valid path/mode
+ # handle invalid paths gracefully
+ mode = form.get('op','index')
+
+ func = getattr( cw, mode )
+ content = func( **form )
+
+ # apache.log_error("%s:%s ... %s" % (my_user, my_uri, str(form)))
+ req.content_type = "text/plain"
+ req.write(content)
+
+ return apache.OK
+