From f56cef93ea6e3746a17152bcd1850ccf4b3dad3d Mon Sep 17 00:00:00 2001 From: Mark Washenberger Date: Fri, 2 Mar 2012 15:57:55 -0500 Subject: Better glance exception handling - Adds a conversion step that turns glance exceptions into nova exceptions - Converts Invalid to HTTPBadRequest in /images and /images/detail, fixing bug 944846 - Makes stub glance client return glance exceptions instead of nova exceptions - Rebased off of http://review.openstack.org/4788 to pick up MissingCredentialError handling as well, and added a test - A few small, miscellaneous testing fixes for issues I noticed Change-Id: I88eebfe7a7ac21cc5cd84ad84d64b311ddccf91e --- nova/api/openstack/compute/images.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/images.py b/nova/api/openstack/compute/images.py index 1a957bc56..eceee6651 100644 --- a/nova/api/openstack/compute/images.py +++ b/nova/api/openstack/compute/images.py @@ -171,8 +171,11 @@ class Controller(wsgi.Controller): for key, val in page_params.iteritems(): params[key] = val - images = self._image_service.index(context, filters=filters, - **page_params) + try: + images = self._image_service.index(context, filters=filters, + **page_params) + except exception.Invalid as e: + raise webob.exc.HTTPBadRequest(explanation=str(e)) return self._view_builder.index(req, images) @wsgi.serializers(xml=ImagesTemplate) @@ -188,8 +191,11 @@ class Controller(wsgi.Controller): page_params = common.get_pagination_params(req) for key, val in page_params.iteritems(): params[key] = val - images = self._image_service.detail(context, filters=filters, - **page_params) + try: + images = self._image_service.detail(context, filters=filters, + **page_params) + except exception.Invalid as e: + raise webob.exc.HTTPBadRequest(explanation=str(e)) return self._view_builder.detail(req, images) -- cgit