From db7798a973bb05af5d4668a9f9b20ce62e8a47af Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Tue, 23 Oct 2012 22:37:04 -0400 Subject: Fix Incorrect Exception when metadata is over 255 characters Need to be in sync with Essex. Throw a new exception in api.py when key or value is over 255 chars. Catch this exception end return back HTTP error 413. add extra lines in exception.py to make pep8 happy Fixes bug 1004007 Change-Id: I67694e3a9600b7dd0b80c519327327568751c2a4 --- nova/api/openstack/compute/server_metadata.py | 3 +++ nova/api/openstack/compute/servers.py | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/server_metadata.py b/nova/api/openstack/compute/server_metadata.py index dfb4b55a8..4e5a3ee02 100644 --- a/nova/api/openstack/compute/server_metadata.py +++ b/nova/api/openstack/compute/server_metadata.py @@ -129,6 +129,9 @@ class Controller(object): except exception.InvalidMetadata as error: raise exc.HTTPBadRequest(explanation=unicode(error)) + except exception.InvalidMetadataSize as error: + raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error)) + except exception.QuotaError as error: raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error), headers={'Retry-After': 0}) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index c5e829d52..1ceb5d34e 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -873,6 +873,8 @@ class Controller(wsgi.Controller): raise exc.HTTPBadRequest(explanation=unicode(error)) except exception.InvalidMetadata as error: raise exc.HTTPBadRequest(explanation=unicode(error)) + except exception.InvalidMetadataSize as error: + raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error)) except exception.ImageNotFound as error: msg = _("Can not find requested image") raise exc.HTTPBadRequest(explanation=msg) @@ -1224,6 +1226,8 @@ class Controller(wsgi.Controller): raise exc.HTTPNotFound(explanation=msg) except exception.InvalidMetadata as error: raise exc.HTTPBadRequest(explanation=unicode(error)) + except exception.InvalidMetadataSize as error: + raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error)) except exception.ImageNotFound: msg = _("Cannot find image for rebuild") raise exc.HTTPBadRequest(explanation=msg) -- cgit