77 lines
3.4 KiB
Diff
77 lines
3.4 KiB
Diff
|
diff -rupN cobbler-2.0.7.old/cobbler/services.py cobbler-2.0.7/cobbler/services.py
|
||
|
--- cobbler-2.0.7.old/cobbler/services.py 2014-09-11 11:51:46.494164060 -0400
|
||
|
+++ cobbler-2.0.7/cobbler/services.py 2014-09-11 11:52:33.163499576 -0400
|
||
|
@@ -217,25 +217,18 @@ class CobblerSvc(object):
|
||
|
def findks(self,system=None,profile=None,**rest):
|
||
|
self.__xmlrpc_setup()
|
||
|
|
||
|
- serverseg = self.server.replace("http://","")
|
||
|
- serverseg = self.server.replace("/cobbler_api","")
|
||
|
-
|
||
|
name = "?"
|
||
|
- type = "system"
|
||
|
if system is not None:
|
||
|
- url = "%s/cblr/svc/op/ks/system/%s" % (serverseg, name)
|
||
|
+ url = "/cblr/svc/op/ks/system/%s" % (system.name)
|
||
|
elif profile is not None:
|
||
|
- url = "%s/cblr/svc/op/ks/profile/%s" % (serverseg, name)
|
||
|
+ url = "/cblr/svc/op/ks/profile/%s" % (profile.name)
|
||
|
else:
|
||
|
name = self.autodetect(**rest)
|
||
|
if name.startswith("FAILED"):
|
||
|
return "# autodetection %s" % name
|
||
|
- url = "%s/cblr/svc/op/ks/system/%s" % (serverseg, name)
|
||
|
+ url = "/cblr/svc/op/ks/system/%s" % (name)
|
||
|
|
||
|
- try:
|
||
|
- return urlgrabber.urlread(url)
|
||
|
- except:
|
||
|
- return "# kickstart retrieval failed (%s)" % url
|
||
|
+ return url + "# redirect"
|
||
|
|
||
|
def puppet(self,hostname=None,**rest):
|
||
|
self.__xmlrpc_setup()
|
||
|
diff -rupN cobbler-2.0.7.old/scripts/services.wsgi cobbler-2.0.7/scripts/services.wsgi
|
||
|
--- cobbler-2.0.7.old/scripts/services.wsgi 2014-09-11 11:51:46.500164103 -0400
|
||
|
+++ cobbler-2.0.7/scripts/services.wsgi 2014-09-11 11:52:33.163499576 -0400
|
||
|
@@ -56,7 +56,11 @@ def application(environ, start_response)
|
||
|
# This MAC header is set by anaconda during a kickstart booted with the
|
||
|
# kssendmac kernel option. The field will appear here as something
|
||
|
# like: eth0 XX:XX:XX:XX:XX:XX
|
||
|
- form["REMOTE_MAC"] = form.get("HTTP_X_RHN_PROVISIONING_MAC_0", None)
|
||
|
+ form["REMOTE_MAC"] = environ.get("HTTP_X_RHN_PROVISIONING_MAC_0", None)
|
||
|
+
|
||
|
+ # REMOTE_ADDR isn't a required wsgi attribute so it may be naive to assume
|
||
|
+ # it's always present in this context.
|
||
|
+ form["REMOTE_ADDR"] = environ.get("REMOTE_ADDR", None)
|
||
|
|
||
|
# Save client remote address for ks/triggers
|
||
|
form["REMOTE_ADDR"] = environ['REMOTE_ADDR']
|
||
|
@@ -80,6 +84,7 @@ def application(environ, start_response)
|
||
|
|
||
|
# Execute corresponding operation on the CobblerSvc object:
|
||
|
func = getattr( cw, mode )
|
||
|
+ response_headers = [('Content-type', 'text/plain;charset=utf-8')]
|
||
|
try:
|
||
|
content = func( **form )
|
||
|
|
||
|
@@ -96,13 +101,16 @@ def application(environ, start_response)
|
||
|
content.find("# object not found") != -1:
|
||
|
print("content not found: %s" % my_uri)
|
||
|
status = "404 NOT FOUND"
|
||
|
+ elif content.find("# redirect") != -1:
|
||
|
+ status = "302 Found"
|
||
|
+ response_headers.append(('Location', content[:content.find("# redirect")]))
|
||
|
+ content = ""
|
||
|
except xmlrpclib.Fault, (err):
|
||
|
status = '500 SERVER ERROR'
|
||
|
content = err.faultString
|
||
|
|
||
|
# req.content_type = "text/plain;charset=utf-8"
|
||
|
- response_headers = [('Content-type', 'text/plain;charset=utf-8'),
|
||
|
- ('Content-Length', str(len(content)))]
|
||
|
+ response_headers.append(('Content-Length', str(len(content))))
|
||
|
start_response(status, response_headers)
|
||
|
|
||
|
return [content]
|