From 903b51e148c2f9e858b5ea0ca5b230ac308d76c5 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 4 Oct 2012 10:20:58 -0400 Subject: Fix XML response for return_reservation_id. The XML serializer for create uses the server template for it's response. However, when return_reservation_id is set, only a reservation_id is going to be returned. To enable the XML response to be serialized the reservation id is now returned in a server tag/object. This commit fixes bug 1061124 Change-Id: Ic74071b1d527c3f3752e296d3fd46a28a99beb76 Signed-off-by: Matthew Treinish --- nova/api/openstack/compute/servers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 07731e3ba..89eac8bfd 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -66,6 +66,7 @@ def make_server(elem, detailed=False): elem.set('accessIPv6') elem.set('status') elem.set('progress') + elem.set('reservation_id') # Attach image node image = xmlutil.SubTemplateElement(elem, 'image', selector='image') @@ -889,7 +890,13 @@ class Controller(wsgi.Controller): # Let the caller deal with unhandled exceptions. # If the caller wanted a reservation_id, return it - if ret_resv_id: + + # NOTE(treinish): XML serialization will not work without a root + # selector of 'server' however JSON return is not expecting a server + # field/object + if ret_resv_id and (req.get_content_type() == 'application/xml'): + return {'server': {'reservation_id': resv_id}} + elif ret_resv_id: return {'reservation_id': resv_id} req.cache_db_instances(instances) -- cgit