From: Angus Salkeld Date: Mon, 12 Aug 2013 10:50:52 +0000 (+1000) Subject: Resolve LaunchConfig references X-Git-Tag: 2014.1~231^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=6c842ed0bc7a76f2b57ec43f61160964ad209f27;p=openstack-build%2Fheat-build.git Resolve LaunchConfig references Autoscaling was not working if there were references in the launchconfig. bug 1211125 Change-Id: Ie3be79d579e87a8026690cbe40c9056591c00e31 --- diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index 270d27bd..d541de7a 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -157,9 +157,13 @@ class InstanceGroup(stack_resource.StackResource): instance_definition = self.stack.t['Resources'][conf_name].copy() instance_definition['Type'] = 'AWS::EC2::Instance' instance_definition['Properties']['Tags'] = self._tags() + # resolve references within the context of this stack. + static_parsed = self.stack.resolve_static_data(instance_definition) + fully_parsed = self.stack.resolve_runtime_data(static_parsed) + resources = {} for i in range(num_instances): - resources["%s-%d" % (self.name, i)] = instance_definition + resources["%s-%d" % (self.name, i)] = fully_parsed return {"Resources": resources} def resize(self, new_capacity): diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index 110e41bf..aaeb0237 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -39,9 +39,8 @@ as_template = ''' "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "AutoScaling Test", "Parameters" : { - "KeyName": { - "Type": "String" - } + "ImageId": {"Type": "String"}, + "KeyName": {"Type": "String"} }, "Resources" : { "WebServerGroup" : { @@ -86,7 +85,7 @@ as_template = ''' "LaunchConfig" : { "Type" : "AWS::AutoScaling::LaunchConfiguration", "Properties": { - "ImageId" : "foo", + "ImageId" : {"Ref": "ImageId"}, "InstanceType" : "bar", } } @@ -97,7 +96,7 @@ as_template = ''' class AutoScalingTest(HeatTestCase): dummy_instance_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' - params = {'KeyName': 'test'} + params = {'KeyName': 'test', 'ImageId': 'foo'} def setUp(self): super(AutoScalingTest, self).setUp()