summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>2012-09-13 01:59:43 -0400
committerMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>2012-09-15 19:13:27 -0400
commit81e76480af6ad17943cd2385a045d24217b07a7b (patch)
tree0f840932a2a1ad1dd85664182f2732a1656e9214 /nova
parent9536b3fa9861e4b9c93b5cf0a91451a92c5df92c (diff)
Include Schedule Hints deserialization to XML API
So far the xml format to schedule hints were not defined. Once defined (in ML), this patch add support to its deserialization. This patch also includes a xml deserialization method to get the Elements between the childs of a node. Partially fixes bug 1050997 Change-Id: I2a34dbbd6200755818d7eaa7330a96d61a043614
Diffstat (limited to 'nova')
-rw-r--r--nova/api/openstack/compute/servers.py15
-rw-r--r--nova/api/openstack/wsgi.py8
2 files changed, 23 insertions, 0 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index f448d3fb9..33e4d0689 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -163,6 +163,10 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer):
if server_node.getAttribute(attr):
server[attr] = server_node.getAttribute(attr)
+ scheduler_hints = self._extract_scheduler_hints(server_node)
+ if scheduler_hints:
+ server['os:scheduler_hints'] = scheduler_hints
+
metadata_node = self.find_first_child_named(server_node, "metadata")
if metadata_node is not None:
server["metadata"] = self.extract_metadata(metadata_node)
@@ -185,6 +189,17 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer):
return server
+ def _extract_scheduler_hints(self, server_node):
+ """Marshal the scheduler hints attribute of a parsed request"""
+ node = self.find_first_child_named(server_node, "scheduler_hints")
+ if node:
+ scheduler_hints = {}
+ for child in self.extract_elements(node):
+ scheduler_hints[child.nodeName] = self.extract_text(child)
+ return scheduler_hints
+ else:
+ return None
+
def _extract_networks(self, server_node):
"""Marshal the networks attribute of a parsed request."""
node = self.find_first_child_named(server_node, "networks")
diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py
index a9fa3847a..c3f631962 100644
--- a/nova/api/openstack/wsgi.py
+++ b/nova/api/openstack/wsgi.py
@@ -265,6 +265,14 @@ class XMLDeserializer(TextDeserializer):
return child.nodeValue
return ""
+ def extract_elements(self, node):
+ """Get only Element type childs from node"""
+ elements = []
+ for child in node.childNodes:
+ if child.nodeType == child.ELEMENT_NODE:
+ elements.append(child)
+ return elements
+
def find_attribute_or_element(self, parent, name):
"""Get an attribute value; fallback to an element if not found"""
if parent.hasAttribute(name):