2 # Apache mod_python interface
4 # Aaron Klingaman <alk@absarokasoft.com>
5 # Mark Huang <mlhuang@cs.princeton.edu>
7 # Copyright (C) 2004-2006 The Trustees of Princeton University
12 from mod_python import apache
14 from sfa.util.sfalogging import logger
15 from sfa.planetlab.server import SfaApi
17 api = SfaApi(interface='aggregate')
21 if req.method != "POST":
22 req.content_type = "text/html"
23 req.send_http_header()
26 <title>SFA Aggregate API XML-RPC/SOAP Interface</title>
28 <h1>SFA Aggregate API XML-RPC/SOAP Interface</h1>
29 <p>Please use XML-RPC or SOAP to access the SFA API.</p>
35 request = req.read(int(req.headers_in['content-length']))
37 # mod_python < 3.2: The IP address portion of remote_addr is
38 # incorrect (always 0.0.0.0) when IPv6 is enabled.
39 # http://issues.apache.org/jira/browse/MODPYTHON-64?page=all
40 (remote_ip, remote_port) = req.connection.remote_addr
41 remote_addr = (req.connection.remote_ip, remote_port)
44 response = api.handle(remote_addr, request)
47 req.content_type = "text/xml; charset=" + api.encoding
48 req.send_http_header()
53 except Exception, err:
54 # Log error in /var/log/httpd/(ssl_)?error_log
55 logger.log_exc('%r'%err)
56 return apache.HTTP_INTERNAL_SERVER_ERROR