]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Override events for AutoScalingGroup instances
authorSteven Hardy <shardy@redhat.com>
Wed, 12 Dec 2012 14:59:02 +0000 (14:59 +0000)
committerSteven Hardy <shardy@redhat.com>
Wed, 12 Dec 2012 17:21:30 +0000 (17:21 +0000)
Override state-transition events by subclassing the Instance
resource to AutoScalingGroupInstance, this avoids problems where
events can't lookup the resource via parser.Stack (since these
resources aren't "real" resources defined in the template)

fixes bug 1089338

Change-Id: Ia064cd067eefdaa5ca81b0cb822ce2fa443bac85
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/resources/autoscaling.py

index eec9db20f5edd6f54c997fdf8e079d2f32f7ba5d..0ce69609601917497358bb6f89f5c54843d43e5a 100644 (file)
@@ -65,10 +65,22 @@ class AutoScalingGroup(resource.Resource):
         return self.UPDATE_REPLACE
 
     def _make_instance(self, name):
+
         Instance = resource.get_class('AWS::EC2::Instance')
+
+        class AutoScalingGroupInstance(Instance):
+            '''
+            Subclass instance.Instance to supress event transitions, since the
+            scaling-group instances are not "real" resources, ie defined in the
+            template, which causes problems for event handling since we can't
+            look up the resources via parser.Stack
+            '''
+            def state_set(self, new_state, reason="state changed"):
+                self._store_or_update(new_state, reason)
+
         conf = self.properties['LaunchConfigurationName']
         instance_definition = self.stack.t['Resources'][conf]
-        return Instance(name, instance_definition, self.stack)
+        return AutoScalingGroupInstance(name, instance_definition, self.stack)
 
     def handle_delete(self):
         if self.resource_id is not None: