From 09c7fc3b694ab401d42c9e59b17e24bbe4383588 Mon Sep 17 00:00:00 2001 From: Chris Yeoh Date: Tue, 16 Apr 2013 23:01:26 +0930 Subject: Catch glance image create exceptions Catch exception from glance when image creation fails because the requested name is too long. Currently the exception is not caught in the api which results in an 400 Bad Request correctly being returned, but also leaving a traceback in the logs. Correctly catching the exception and explicitly raising an HTTPBadRequest removes the production of the traceback. Fixes bug #1169560 Change-Id: I511da79cb0b1b4578bf43f0819b2ac64fb6e5fb3 --- nova/api/openstack/compute/servers.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 12efa5eb4..7c56d77c1 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -1366,6 +1366,8 @@ class Controller(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage') + except exception.Invalid as err: + raise exc.HTTPBadRequest(explanation=str(err)) # build location of newly-created image entity image_id = str(image['id']) -- cgit