summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/__init__.py1
-rw-r--r--nova/api/cloudpipe/__init__.py3
-rw-r--r--nova/api/ec2/__init__.py50
-rw-r--r--nova/api/ec2/metadatarequesthandler.py3
-rw-r--r--nova/api/openstack/__init__.py13
5 files changed, 67 insertions, 3 deletions
diff --git a/nova/api/__init__.py b/nova/api/__init__.py
index 80f9f2109..92b495e8c 100644
--- a/nova/api/__init__.py
+++ b/nova/api/__init__.py
@@ -29,7 +29,6 @@ import routes
import webob.dec
from nova import flags
-from nova import utils
from nova import wsgi
from nova.api import cloudpipe
from nova.api import ec2
diff --git a/nova/api/cloudpipe/__init__.py b/nova/api/cloudpipe/__init__.py
index 6d40990a8..47349d9f9 100644
--- a/nova/api/cloudpipe/__init__.py
+++ b/nova/api/cloudpipe/__init__.py
@@ -67,3 +67,6 @@ class API(wsgi.Application):
project_id = self.get_project_id_from_ip(req.remote_addr)
cert = self.str_params['cert']
return crypto.sign_csr(urllib.unquote(cert), project_id)
+
+def cloudpipe_factory(global_opts, **local_opts):
+ return API()
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index a6ee16c33..50cb18078 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -225,10 +225,9 @@ class Executor(wsgi.Application):
args = req.environ['ec2.action_args']
api_request = apirequest.APIRequest(controller, action)
+ result = None
try:
result = api_request.send(context, **args)
- req.headers['Content-Type'] = 'text/xml'
- return result
except exception.ApiError as ex:
if ex.code:
@@ -238,6 +237,13 @@ class Executor(wsgi.Application):
# TODO(vish): do something more useful with unknown exceptions
except Exception as ex:
return self._error(req, type(ex).__name__, str(ex))
+ else:
+ resp = webob.Response()
+ resp.status = 200
+ resp.headers['Content-Type'] = 'text/xml'
+ resp.body = str(result)
+ return resp
+
def _error(self, req, code, message):
logging.error("%s: %s", code, message)
@@ -249,3 +255,43 @@ class Executor(wsgi.Application):
'<Message>%s</Message></Error></Errors>'
'<RequestID>?</RequestID></Response>' % (code, message))
return resp
+
+class Versions(wsgi.Application):
+
+ @webob.dec.wsgify
+ def __call__(self, req):
+ """Respond to a request for all EC2 versions."""
+ # available api versions
+ versions = [
+ '1.0',
+ '2007-01-19',
+ '2007-03-01',
+ '2007-08-29',
+ '2007-10-10',
+ '2007-12-15',
+ '2008-02-01',
+ '2008-09-01',
+ '2009-04-04',
+ ]
+ return ''.join('%s\n' % v for v in versions)
+
+def authenticate_factory(global_args, **local_args):
+ def authenticator(app):
+ return Authenticate(app)
+ return authenticator
+
+def router_factory(global_args, **local_args):
+ def router(app):
+ return Router(app)
+ return router
+
+def authorizer_factory(global_args, **local_args):
+ def authorizer(app):
+ return Authorizer(app)
+ return authorizer
+
+def executor_factory(global_args, **local_args):
+ return Executor()
+
+def versions_factory(global_args, **local_args):
+ return Versions()
diff --git a/nova/api/ec2/metadatarequesthandler.py b/nova/api/ec2/metadatarequesthandler.py
index 2f4f414cc..fffefb97b 100644
--- a/nova/api/ec2/metadatarequesthandler.py
+++ b/nova/api/ec2/metadatarequesthandler.py
@@ -72,3 +72,6 @@ class MetadataRequestHandler(object):
if data is None:
raise webob.exc.HTTPNotFound()
return self.print_data(data)
+
+def metadata_factory(global_args, **local_args):
+ return MetadataRequestHandler()
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index b9ecbd9b8..cb825cf41 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -210,3 +210,16 @@ def limited(items, req):
limit = min(1000, limit)
range_end = offset + limit
return items[offset:range_end]
+
+def auth_factory(global_conf, **local_conf):
+ def auth(app):
+ return AuthMiddleware(app)
+ return auth
+
+def ratelimit_factory(global_conf, **local_conf):
+ def rl(app):
+ return RateLimitingMiddleware(app)
+ return rl
+
+def router_factory(global_cof, **local_conf):
+ return APIRouter()