summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorWilliam Wolf <throughnothing@gmail.com>2011-06-13 18:06:20 +0000
committerTarmac <>2011-06-13 18:06:20 +0000
commit06591f13dcf130d8fb035466bfbe5650acfddb28 (patch)
treed2e0a1ece6a3747708baad829fe27ced75e7def6 /nova/api
parent91e34d37d2907295e892e96ca2c3039c7fbe14bf (diff)
parent48813099bf88a7314b396d5e04beca9a6fc3ba7c (diff)
downloadnova-06591f13dcf130d8fb035466bfbe5650acfddb28.tar.gz
nova-06591f13dcf130d8fb035466bfbe5650acfddb28.tar.xz
nova-06591f13dcf130d8fb035466bfbe5650acfddb28.zip
This fixes the server_metadata create and update functions that were returning req.body (as a string) instead of body (deserialized body dictionary object). It also adds checks where appropriate to make sure that body is not empty (and return 400 if it is). Tests updated/added where appropriate.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/server_metadata.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/nova/api/openstack/server_metadata.py b/nova/api/openstack/server_metadata.py
index b38b84a2a..57666f6b7 100644
--- a/nova/api/openstack/server_metadata.py
+++ b/nova/api/openstack/server_metadata.py
@@ -37,12 +37,18 @@ class Controller(object):
meta_dict[key] = value
return dict(metadata=meta_dict)
+ def _check_body(self, body):
+ if body == None or body == "":
+ expl = _('No Request Body')
+ raise exc.HTTPBadRequest(explanation=expl)
+
def index(self, req, server_id):
""" Returns the list of metadata for a given instance """
context = req.environ['nova.context']
return self._get_metadata(context, server_id)
def create(self, req, server_id, body):
+ self._check_body(body)
context = req.environ['nova.context']
metadata = body.get('metadata')
try:
@@ -51,9 +57,10 @@ class Controller(object):
metadata)
except quota.QuotaError as error:
self._handle_quota_error(error)
- return req.body
+ return body
def update(self, req, server_id, id, body):
+ self._check_body(body)
context = req.environ['nova.context']
if not id in body:
expl = _('Request body and URI mismatch')
@@ -68,7 +75,7 @@ class Controller(object):
except quota.QuotaError as error:
self._handle_quota_error(error)
- return req.body
+ return body
def show(self, req, server_id, id):
""" Return a single metadata item """