summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorDavanum Srinivas <davanum@gmail.com>2012-10-23 22:37:04 -0400
committerDavanum Srinivas <davanum@gmail.com>2012-10-24 08:27:41 -0400
commitdb7798a973bb05af5d4668a9f9b20ce62e8a47af (patch)
tree563aaef1b651d41a825994e3896bf3dad11583d3 /nova/api
parentdf1fb2978c854beb58646406796c2bef2bfb047f (diff)
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
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/server_metadata.py3
-rw-r--r--nova/api/openstack/compute/servers.py4
2 files changed, 7 insertions, 0 deletions
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)