summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-18 22:41:18 +0000
committerGerrit Code Review <review@openstack.org>2012-09-18 22:41:18 +0000
commitebb2814524dee09cb2f84ceafb2d9888863af8de (patch)
treee3fd5e0b9102920dec2103f9a96d56b937b6f032 /nova/api
parent1071af1d8f11e26cd4512f7c2addfdce862c9834 (diff)
parent8d43c3fba1a5e07703cae6f7b631d0787c4f41bb (diff)
downloadnova-ebb2814524dee09cb2f84ceafb2d9888863af8de.tar.gz
nova-ebb2814524dee09cb2f84ceafb2d9888863af8de.tar.xz
nova-ebb2814524dee09cb2f84ceafb2d9888863af8de.zip
Merge "Makes scheduler hints and disk config xml correct"
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/scheduler_hints.py14
-rw-r--r--nova/api/openstack/compute/servers.py25
2 files changed, 27 insertions, 12 deletions
diff --git a/nova/api/openstack/compute/contrib/scheduler_hints.py b/nova/api/openstack/compute/contrib/scheduler_hints.py
index e8d65a741..f5c10fea1 100644
--- a/nova/api/openstack/compute/contrib/scheduler_hints.py
+++ b/nova/api/openstack/compute/contrib/scheduler_hints.py
@@ -29,13 +29,13 @@ class SchedulerHintsController(wsgi.Controller):
def _extract_scheduler_hints(body):
hints = {}
+ attr = '%s:scheduler_hints' % Scheduler_hints.alias
try:
- hints.update(body['os:scheduler_hints'])
-
- # Ignore if data is not present
- except KeyError:
- pass
-
+ if 'os:scheduler_hints' in body:
+ # NOTE(vish): This is for legacy support
+ hints.update(body['os:scheduler_hints'])
+ elif attr in body:
+ hints.update(body[attr])
# Fail if non-dict provided
except ValueError:
msg = _("Malformed scheduler_hints attribute")
@@ -56,7 +56,7 @@ class Scheduler_hints(extensions.ExtensionDescriptor):
"""Pass arbitrary key/value pairs to the scheduler"""
name = "SchedulerHints"
- alias = "os-scheduler-hints"
+ alias = "OS-SCH-HNT"
namespace = ("http://docs.openstack.org/compute/ext/"
"scheduler-hints/api/v2")
updated = "2011-07-19T00:00:00+00:00"
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py
index 5cb7369c0..c9bc4430e 100644
--- a/nova/api/openstack/compute/servers.py
+++ b/nova/api/openstack/compute/servers.py
@@ -171,7 +171,7 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer):
scheduler_hints = self._extract_scheduler_hints(server_node)
if scheduler_hints:
- server['os:scheduler_hints'] = scheduler_hints
+ server['OS-SCH-HNT:scheduler_hints'] = scheduler_hints
metadata_node = self.find_first_child_named(server_node, "metadata")
if metadata_node is not None:
@@ -193,19 +193,34 @@ class CommonDeserializer(wsgi.MetadataXMLDeserializer):
if security_groups is not None:
server["security_groups"] = security_groups
+ # NOTE(vish): Support this incorrect version because it was in the code
+ # base for a while and we don't want to accidentally break
+ # anyone that might be using it.
auto_disk_config = server_node.getAttribute('auto_disk_config')
if auto_disk_config:
- server['auto_disk_config'] = utils.bool_from_str(auto_disk_config)
+ server['OS-DCF:diskConfig'] = utils.bool_from_str(auto_disk_config)
+
+ auto_disk_config = server_node.getAttribute('OS-DCF:diskConfig')
+ if auto_disk_config:
+ server['OS-DCF:diskConfig'] = utils.bool_from_str(auto_disk_config)
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")
+ node = self.find_first_child_named(server_node,
+ "OS-SCH-HNT:scheduler_hints")
+ # NOTE(vish): Support the os: prefix because it is what we use
+ # for json, even though OS-SCH-HNT: is more correct
+ if not node:
+ node = self.find_first_child_named(server_node,
+ "os:scheduler_hints")
if node:
scheduler_hints = {}
for child in self.extract_elements(node):
- scheduler_hints[child.nodeName] = self.extract_text(child)
+ scheduler_hints.setdefault(child.nodeName, [])
+ value = self.extract_text(child).strip()
+ scheduler_hints[child.nodeName].append(value)
return scheduler_hints
else:
return None
@@ -774,7 +789,7 @@ class Controller(wsgi.Controller):
auto_disk_config = server_dict.get('auto_disk_config')
scheduler_hints = {}
- if self.ext_mgr.is_loaded('os-scheduler-hints'):
+ if self.ext_mgr.is_loaded('OS-SCH-HNT'):
scheduler_hints = server_dict.get('scheduler_hints', {})
try: