diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-17 21:00:48 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-17 21:00:48 +0000 |
| commit | 454ca0c12da8967352a1b189256f307d8ad3da3f (patch) | |
| tree | c56d9da28c85c3b3b97eb2193fb2ea689f1172fc /nova/api | |
| parent | 4a9791b4c76e2516586caa72effda3c1f8e635ab (diff) | |
| parent | 6a951c77adf6d513a434bf65d46e3a0745b750f7 (diff) | |
Merge "The security_group name should be an XML attribute"
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 6 | ||||
| -rw-r--r-- | nova/api/openstack/wsgi.py | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 87e66b71f..26ed42f20 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -222,9 +222,9 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer): security_groups = [] for sg_node in self.find_children_named(node, "security_group"): item = {} - name_node = self.find_first_child_named(sg_node, "name") - if name_node: - item["name"] = self.extract_text(name_node) + name = self.find_attribute_or_element(sg_node, 'name') + if name: + item["name"] = name security_groups.append(item) return security_groups else: diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index c86d86a5f..c887701a7 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -200,6 +200,17 @@ class XMLDeserializer(TextDeserializer): return child.nodeValue return "" + def find_attribute_or_element(self, parent, name): + """Get an attribute value; fallback to an element if not found""" + if parent.hasAttribute(name): + return parent.getAttribute(name) + + node = self.find_first_child_named(parent, name) + if node: + return self.extract_text(node) + + return None + def default(self, datastring): return {'body': self._from_xml(datastring)} |
