diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-11-29 17:14:14 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-11-29 17:14:14 +0000 |
| commit | 85ae44a753281d7ed6019020cbdfcf7dd52dfd55 (patch) | |
| tree | 107c704afb48ac1a4a81111421e2742a3c608f4d /nova/api | |
| parent | 5c33ce67908f03a620f4b9f2abc54ac7f0de993a (diff) | |
| parent | f58f2b48a1c5ebb01ef998720e5dbd1d88ed6e5d (diff) | |
| download | nova-85ae44a753281d7ed6019020cbdfcf7dd52dfd55.tar.gz nova-85ae44a753281d7ed6019020cbdfcf7dd52dfd55.tar.xz nova-85ae44a753281d7ed6019020cbdfcf7dd52dfd55.zip | |
Merge "Fix HostDeserializer to enable multiple line xml"
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/hosts.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py index 3479e41e2..8982f5724 100644 --- a/nova/api/openstack/compute/contrib/hosts.py +++ b/nova/api/openstack/compute/contrib/hosts.py @@ -70,7 +70,7 @@ class HostShowTemplate(xmlutil.TemplateBuilder): return xmlutil.MasterTemplate(root, 1) -class HostDeserializer(wsgi.XMLDeserializer): +class HostUpdateDeserializer(wsgi.XMLDeserializer): def default(self, string): try: node = minidom.parseString(string) @@ -79,8 +79,16 @@ class HostDeserializer(wsgi.XMLDeserializer): raise exception.MalformedRequestBody(reason=msg) updates = {} - for child in node.childNodes[0].childNodes: - updates[child.tagName] = self.extract_text(child) + updates_node = self.find_first_child_named(node, 'updates') + if updates_node is not None: + maintenance = self.find_first_child_named(updates_node, + 'maintenance_mode') + if maintenance is not None: + updates[maintenance.tagName] = self.extract_text(maintenance) + + status = self.find_first_child_named(updates_node, 'status') + if status is not None: + updates[status.tagName] = self.extract_text(status) return dict(body=updates) @@ -131,7 +139,7 @@ class HostController(object): return {'hosts': _list_hosts(req)} @wsgi.serializers(xml=HostUpdateTemplate) - @wsgi.deserializers(xml=HostDeserializer) + @wsgi.deserializers(xml=HostUpdateDeserializer) @check_host def update(self, req, id, body): authorize(req.environ['nova.context']) |
