diff options
| author | Brian Waldon <brian.waldon@rackspace.com> | 2011-06-23 20:08:10 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-23 20:08:10 +0000 |
| commit | a44f7dfa3af8dc8c605ff52ed536dae8f9ee23bb (patch) | |
| tree | 6d547ef228b00ca061fbe09a5480c8cd10d51180 /nova/api | |
| parent | df8448f9f63c9f610c23cf092c14f4eb8547fe46 (diff) | |
| parent | 7398819cc00a078a486b4d2f11846ff32db19a88 (diff) | |
Adding dict with single 'meta' key to /imgages/<id>/meta/<key> GET and PUT
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/image_metadata.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/nova/api/openstack/image_metadata.py b/nova/api/openstack/image_metadata.py index 691264553..c0e92f2fc 100644 --- a/nova/api/openstack/image_metadata.py +++ b/nova/api/openstack/image_metadata.py @@ -60,7 +60,7 @@ class Controller(object): context = req.environ['nova.context'] metadata = self._get_metadata(context, image_id) if id in metadata: - return {id: metadata[id]} + return {'meta': {id: metadata[id]}} else: return faults.Fault(exc.HTTPNotFound()) @@ -78,15 +78,22 @@ class Controller(object): def update(self, req, image_id, id, body): context = req.environ['nova.context'] - if not id in body: + + try: + meta = body['meta'] + except KeyError: + expl = _('Incorrect request body format') + raise exc.HTTPBadRequest(explanation=expl) + + if not id in meta: expl = _('Request body and URI mismatch') raise exc.HTTPBadRequest(explanation=expl) - if len(body) > 1: + if len(meta) > 1: expl = _('Request body contains too many items') raise exc.HTTPBadRequest(explanation=expl) img = self.image_service.show(context, image_id) metadata = self._get_metadata(context, image_id, img) - metadata[id] = body[id] + metadata[id] = meta[id] self._check_quota_limit(context, metadata) img['properties'] = metadata self.image_service.update(context, image_id, img, None) |
