diff options
| author | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-12-20 20:34:15 +0000 |
|---|---|---|
| committer | Johannes Erdfelt <johannes.erdfelt@rackspace.com> | 2011-12-20 21:00:31 +0000 |
| commit | 81559a88884fdde14d6ca6bd788c0e37ca3d56cf (patch) | |
| tree | f7ac0482d49beb441eec1f1ddab155932b14a481 /nova/api | |
| parent | 5895a74c8b90f9b5436d0961d3b2b319f64bc826 (diff) | |
| download | nova-81559a88884fdde14d6ca6bd788c0e37ca3d56cf.tar.gz nova-81559a88884fdde14d6ca6bd788c0e37ca3d56cf.tar.xz nova-81559a88884fdde14d6ca6bd788c0e37ca3d56cf.zip | |
Set Location header in server create and rebuild actions
The API documentation states that the Location header should be filled
with the URL of the server. This change implemnts this for both the
create and rebuild actions.
Change-Id: Ic0372aeaea58c9288065e2cfc222ca9257d35c87
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/v2/servers.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/nova/api/openstack/v2/servers.py b/nova/api/openstack/v2/servers.py index 049a17ef6..e2d84b688 100644 --- a/nova/api/openstack/v2/servers.py +++ b/nova/api/openstack/v2/servers.py @@ -876,13 +876,25 @@ class Controller(wsgi.Controller): class HeadersSerializer(wsgi.ResponseHeadersSerializer): + def _add_server_location(self, response, data): + link = filter(lambda l: l['rel'] == 'self', data['server']['links']) + if link: + response.headers['Location'] = link[0]['href'] + def create(self, response, data): + if 'server' in data: + self._add_server_location(response, data) response.status_int = 202 def delete(self, response, data): response.status_int = 204 def action(self, response, data): + # FIXME(jerdfelt): This is kind of a hack. Unfortunately the original + # action requested isn't available to us, so we need to look at the + # response to see if it looks like a rebuild response. + if data.get('server', {}).get('status') == 'REBUILD': + self._add_server_location(response, data) response.status_int = 202 |
