summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-07-27 22:38:43 +0000
committerGerrit Code Review <review@openstack.org>2012-07-27 22:38:43 +0000
commit004c5fa9058f88d07cb4019c815e8c45e5be9af3 (patch)
tree641485ff0e801dfcbed6197a39b179b968923da4 /nova/api
parent3f315000755732c4780dae03ef65f67d3f87e8f7 (diff)
parent3f71934f0e05b43c2093104c0412e46f5343595a (diff)
Merge "Return location header on volume creation"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/volumes.py5
-rw-r--r--nova/api/openstack/volume/volumes.py6
-rw-r--r--nova/api/openstack/wsgi.py4
3 files changed, 11 insertions, 4 deletions
diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py
index 6b04e3240..085f8d7c5 100644
--- a/nova/api/openstack/compute/contrib/volumes.py
+++ b/nova/api/openstack/compute/contrib/volumes.py
@@ -220,8 +220,11 @@ class VolumeController(object):
# trying to lazy load, but for now we turn it into
# a dict to avoid an error.
retval = _translate_volume_detail_view(context, dict(new_volume))
+ result = {'volume': retval}
- return {'volume': retval}
+ location = '%s/%s' % (req.url, new_volume['id'])
+
+ return wsgi.ResponseObject(result, headers=dict(location=location))
def _translate_attachment_detail_view(volume_id, instance_uuid, mountpoint):
diff --git a/nova/api/openstack/volume/volumes.py b/nova/api/openstack/volume/volumes.py
index 1b0c8dfca..83a2b2f63 100644
--- a/nova/api/openstack/volume/volumes.py
+++ b/nova/api/openstack/volume/volumes.py
@@ -247,7 +247,11 @@ class VolumeController(object):
# a dict to avoid an error.
retval = _translate_volume_detail_view(context, dict(new_volume))
- return {'volume': retval}
+ result = {'volume': retval}
+
+ location = '%s/%s' % (req.url, new_volume['id'])
+
+ return wsgi.ResponseObject(result, headers=dict(location=location))
def create_resource():
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index e92954711..229783d54 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -454,7 +454,7 @@ class ResponseObject(object):
optional.
"""
- def __init__(self, obj, code=None, **serializers):
+ def __init__(self, obj, code=None, headers=None, **serializers):
"""Binds serializers with an object.
Takes keyword arguments akin to the @serializer() decorator
@@ -467,7 +467,7 @@ class ResponseObject(object):
self.serializers = serializers
self._default_code = 200
self._code = code
- self._headers = {}
+ self._headers = headers or {}
self.serializer = None
self.media_type = None