diff options
| author | Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> | 2013-03-07 13:25:09 -0500 |
|---|---|---|
| committer | Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> | 2013-03-07 13:48:24 -0500 |
| commit | dc29ab91e434335f4468427475baea23d2c68b7b (patch) | |
| tree | aa30f800e24e5883d1510afe8342197cd6e981ef /nova/api | |
| parent | 436282fad2b5ab4dfc69b49442aaedd8d123f1e8 (diff) | |
Add MultipleCreate template and fix conflict with other templates
This patch creates a dedicated xml template to the os-multiple-create extension
when using return_reservation_id=True in the request. The previous code, with
all extensions loaded, conflicted with security_groups extension.
There is also a change in the response due to the new Template, but the only
information removed is an empty metadata field (which made the previous xml
output even more inconsisten with json). The consistency between json and xml
will be treated in the next api version.
DocImpact
Fixes bug 1149526
Change-Id: I3ca0129086ff1df3a8faa2b3b8bd959c9b74103c
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 3464cfdbd..c21599300 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -134,6 +134,13 @@ class ServerAdminPassTemplate(xmlutil.TemplateBuilder): return xmlutil.SlaveTemplate(root, 1, nsmap=server_nsmap) +class ServerMultipleCreateTemplate(xmlutil.TemplateBuilder): + def construct(self): + root = xmlutil.TemplateElement('server') + root.set('reservation_id') + return xmlutil.MasterTemplate(root, 1, nsmap=server_nsmap) + + def FullServerTemplate(): master = ServerTemplate() master.attach(ServerAdminPassTemplate()) @@ -917,14 +924,9 @@ class Controller(wsgi.Controller): # Let the caller deal with unhandled exceptions. # If the caller wanted a reservation_id, return it - - # 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} + if ret_resv_id: + return wsgi.ResponseObject({'reservation_id': resv_id}, + xml=ServerMultipleCreateTemplate) req.cache_db_instances(instances) server = self._view_builder.create(req, instances[0]) |
