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
13 from mod_python import apache
15 from sfa.plc.api import SfaAPI
16 from sfa.util.sfalogging import sfa_logger
18 api = SfaAPI(interface='slicemgr')
22 if req.method != "POST":
23 req.content_type = "text/html"
24 req.send_http_header()
27 <title>SFA SliceMgr API XML-RPC/SOAP Interface</title>
29 <h1>SFA SliceMgr API XML-RPC/SOAP Interface</h1>
30 <p>Please use XML-RPC or SOAP to access the SFA API.</p>
36 request = req.read(int(req.headers_in['content-length']))
38 # mod_python < 3.2: The IP address portion of remote_addr is
39 # incorrect (always 0.0.0.0) when IPv6 is enabled.
40 # http://issues.apache.org/jira/browse/MODPYTHON-64?page=all
41 (remote_ip, remote_port) = req.connection.remote_addr
42 remote_addr = (req.connection.remote_ip, remote_port)
45 response = api.handle(remote_addr, request)
48 req.content_type = "text/xml; charset=" + api.encoding
49 req.send_http_header()
54 except Exception, err:
55 # Log error in /var/log/httpd/(ssl_)?error_log
56 sfa_logger().log_exc('%r'%err)
57 return apache.HTTP_INTERNAL_SERVER_ERROR