From 76c1fd11b73fd8516bbde20cb46f627b658d4a6d Mon Sep 17 00:00:00 2001 From: John Griffith Date: Mon, 23 Jul 2012 22:42:25 -0600 Subject: Check for exception codes in openstack API results * Inspect all exceptions for code, not just nova.exceptions Originally the fault wrapper would only inspect an exception for status, header and safe attributes if it was a nova.exception. As a result, excecptions returned from Cinder were always being incorrectly interpretted/categorized as ComputeFaults (500). This results in tempest tests that expect exceptions such as 404 NotFound to fail. Now that we're checking all Exceptions the same way, there's no need for a specifying nova.exceptions or even doing the import. Change-Id: If49e364063d5288c81ce1557bddc6dcec3ec457e --- nova/api/openstack/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index c1ce7ee94..a2f73e852 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -25,7 +25,6 @@ import webob.dec import webob.exc from nova.api.openstack import wsgi -from nova import exception from nova.openstack.common import log as logging from nova import utils from nova import wsgi as base_wsgi @@ -47,8 +46,13 @@ class FaultWrapper(base_wsgi.Middleware): return FaultWrapper._status_to_type.get( status, webob.exc.HTTPInternalServerError)() - def _error(self, inner, req, headers=None, status=500, safe=False): + def _error(self, inner, req): LOG.exception(_("Caught error: %s"), unicode(inner)) + + safe = getattr(inner, 'safe', False) + headers = getattr(inner, 'headers', None) + status = getattr(inner, 'code', 500) + msg_dict = dict(url=req.url, status=status) LOG.info(_("%(url)s returned with HTTP %(status)d") % msg_dict) outer = self.status_to_type(status) @@ -70,8 +74,6 @@ class FaultWrapper(base_wsgi.Middleware): def __call__(self, req): try: return req.get_response(self.application) - except exception.NovaException as ex: - return self._error(ex, req, ex.headers, ex.code, ex.safe) except Exception as ex: return self._error(ex, req) -- cgit