Merge "Allow complex scheduler hints for AWS Instance"

This commit is contained in:
Jenkins 2014-04-14 05:36:39 +00:00 committed by Gerrit Code Review
commit 3a61debdec
2 changed files with 16 additions and 2 deletions

View File

@ -12,6 +12,7 @@
# under the License.
from oslo.config import cfg
import six
cfg.CONF.import_opt('instance_user', 'heat.common.config')
@ -424,7 +425,15 @@ class Instance(resource.Resource):
scheduler_hints = {}
if self.properties[self.NOVA_SCHEDULER_HINTS]:
for tm in self.properties[self.NOVA_SCHEDULER_HINTS]:
scheduler_hints[tm[self.TAG_KEY]] = tm[self.TAG_VALUE]
# adopted from novaclient shell
hint = tm[self.TAG_KEY]
hint_value = tm[self.TAG_VALUE]
if hint in scheduler_hints:
if isinstance(scheduler_hints[hint], six.string_types):
scheduler_hints[hint] = [scheduler_hints[hint]]
scheduler_hints[hint].append(hint_value)
else:
scheduler_hints[hint] = hint_value
else:
scheduler_hints = None

View File

@ -52,6 +52,10 @@ wp_template = '''
"ImageId" : "F17-x86_64-gold",
"InstanceType" : "m1.large",
"KeyName" : "test",
"NovaSchedulerHints" : [{"Key": "foo", "Value": "spam"},
{"Key": "bar", "Value": "eggs"},
{"Key": "foo", "Value": "ham"},
{"Key": "foo", "Value": "baz"}],
"UserData" : "wordpress"
}
}
@ -101,7 +105,8 @@ class InstancesTest(HeatTestCase):
instance.name,
limit=instance.physical_resource_name_limit),
security_groups=None,
userdata=mox.IgnoreArg(), scheduler_hints=None,
userdata=mox.IgnoreArg(),
scheduler_hints={'foo': ['spam', 'ham', 'baz'], 'bar': 'eggs'},
meta=None, nics=None, availability_zone=None).AndReturn(
return_server)