diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-08-31 10:46:01 -0400 |
|---|---|---|
| committer | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-08-31 10:46:01 -0400 |
| commit | 070d87df264ca949b51131df9287fbcee373d480 (patch) | |
| tree | 32586e9aa224f4bee07ce4bf5410ce29c91e7aa0 | |
| parent | c54d6c3d1fcb0210e9f52097f1a1e85550c84bf6 (diff) | |
| download | nova-070d87df264ca949b51131df9287fbcee373d480.tar.gz nova-070d87df264ca949b51131df9287fbcee373d480.tar.xz nova-070d87df264ca949b51131df9287fbcee373d480.zip | |
Get rid of some convoluted exception handling that we don't need in eventlet
| -rw-r--r-- | nova/api/ec2/__init__.py | 23 | ||||
| -rw-r--r-- | nova/api/ec2/apirequest.py | 7 |
2 files changed, 11 insertions, 19 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index a4d9b95f9..46e543d0e 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -122,24 +122,15 @@ class Router(wsgi.Application): self._error('unhandled', 'no controller named %s' % controller_name) return - request = APIRequest(controller, req.environ['ec2.action']) + api_request = APIRequest(controller, req.environ['ec2.action']) context = req.environ['ec2.context'] try: - data = request.send(context, **args) - req.headers['Content-Type'] = 'text/xml' - return data - #TODO(gundlach) under what conditions would _error_callbock used to - #be called? What was 'failure' that you could call .raiseException - #on it? - except Exception, ex: - try: - #TODO - failure.raiseException() - except exception.ApiError as ex: - self._error(req, type(ex).__name__ + "." + ex.code, ex.message) - # TODO(vish): do something more useful with unknown exceptions - except Exception as ex: - self._error(type(ex).__name__, str(ex)) + return api_request.send(context, **args) + except exception.ApiError as ex: + self._error(req, type(ex).__name__ + "." + ex.code, ex.message) + # TODO(vish): do something more useful with unknown exceptions + except Exception as ex: + self._error(type(ex).__name__, str(ex)) def _error(self, req, code, message): req.status = 400 diff --git a/nova/api/ec2/apirequest.py b/nova/api/ec2/apirequest.py index 1fc84248b..77f1a7759 100644 --- a/nova/api/ec2/apirequest.py +++ b/nova/api/ec2/apirequest.py @@ -79,9 +79,10 @@ class APIRequest(object): s.sort() args[key] = [v for k, v in s] - d = defer.maybeDeferred(method, context, **args) - d.addCallback(self._render_response, context.request_id) - return d + 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): xml = minidom.Document() |
