]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Resolve LaunchConfig references
authorAngus Salkeld <asalkeld@redhat.com>
Mon, 12 Aug 2013 10:50:52 +0000 (20:50 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Mon, 12 Aug 2013 10:51:14 +0000 (20:51 +1000)
Autoscaling was not working if there were references in the launchconfig.

bug 1211125
Change-Id: Ie3be79d579e87a8026690cbe40c9056591c00e31

heat/engine/resources/autoscaling.py
heat/tests/test_autoscaling.py

index 270d27bd5120e1d26da7c88eef9b88a976388ee3..d541de7ac204874e7637b9f63c611113397b0acc 100644 (file)
@@ -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):
index 110e41bf3504e4b914e55583fa9400c76b1eea86..aaeb023708fdb395b3c41b181a5cfe4e81edf1f7 100644 (file)
@@ -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()