summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-09-02 15:53:57 -0400
committerMichael Gundlach <michael.gundlach@rackspace.com>2010-09-02 15:53:57 -0400
commit3075cc7440a37118d7784057874887f751e1f6a3 (patch)
tree48c41297acba3b5ea4206b60c84f74887709d692 /nova/api
parentb360aded9cfeebfd7594b1b649bd2a1573203cd3 (diff)
downloadnova-3075cc7440a37118d7784057874887f751e1f6a3.tar.gz
nova-3075cc7440a37118d7784057874887f751e1f6a3.tar.xz
nova-3075cc7440a37118d7784057874887f751e1f6a3.zip
OMG got api_unittests to pass
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/__init__.py11
-rw-r--r--nova/api/ec2/apirequest.py6
2 files changed, 12 insertions, 5 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index 1722617ae..e53e7d964 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -28,6 +28,7 @@ import webob.exc
from nova import exception
from nova import wsgi
+from nova.api.ec2 import apirequest
from nova.api.ec2 import context
from nova.api.ec2 import admin
from nova.api.ec2 import cloud
@@ -174,7 +175,7 @@ class Authorizer(wsgi.Middleware):
@webob.dec.wsgify
def __call__(self, req):
context = req.environ['ec2.context']
- controller_name = req.environ['ec2.controller'].__name__
+ controller_name = req.environ['ec2.controller'].__class__.__name__
action = req.environ['ec2.action']
allowed_roles = self.action_roles[controller_name].get(action, [])
if self._matches_any_role(context, allowed_roles):
@@ -205,14 +206,16 @@ class Executor(wsgi.Application):
action = req.environ['ec2.action']
args = req.environ['ec2.action_args']
- api_request = APIRequest(controller, action)
+ api_request = apirequest.APIRequest(controller, action)
try:
- return api_request.send(context, **args)
+ result = api_request.send(context, **args)
+ req.headers['Content-Type'] = 'text/xml'
+ return result
except exception.ApiError as ex:
return self._error(req, type(ex).__name__ + "." + ex.code, ex.message)
# TODO(vish): do something more useful with unknown exceptions
except Exception as ex:
- return self._error(type(ex).__name__, str(ex))
+ return self._error(req, type(ex).__name__, str(ex))
def _error(self, req, code, message):
resp = webob.Response()
diff --git a/nova/api/ec2/apirequest.py b/nova/api/ec2/apirequest.py
index 261346a09..85ff2fa5e 100644
--- a/nova/api/ec2/apirequest.py
+++ b/nova/api/ec2/apirequest.py
@@ -20,9 +20,14 @@
APIRequest class
"""
+import logging
+import re
# TODO(termie): replace minidom with etree
from xml.dom import minidom
+_log = logging.getLogger("api")
+_log.setLevel(logging.DEBUG)
+
_c2u = re.compile('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))')
@@ -79,7 +84,6 @@ class APIRequest(object):
result = method(context, **args)
- req.headers['Content-Type'] = 'text/xml'
return self._render_response(result, context.request_id)
def _render_response(self, response_data, request_id):