diff options
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)} |
