Allow complex scheduler hints for AWS Instance

Nova supports providing several values for the same scheduler hint,
in which case the hint value is formed as a list. This functionality was
missing in AWS::EC2::Instance resource.

Change-Id: Id05e4f2ebe89871c1f27f8d97441f3b6cf469dd3
Closes-Bug: #1297667
This commit is contained in:
Pavlo Shchelokovskyy 2014-04-03 18:35:47 +03:00
parent b83396804f
commit 28ade4a5be
2 changed files with 16 additions and 2 deletions

View File

@ -13,6 +13,7 @@
# under the License.
from oslo.config import cfg
import six
cfg.CONF.import_opt('instance_user', 'heat.common.config')
@ -425,7 +426,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)