From: Steven Hardy Date: Wed, 12 Dec 2012 14:59:02 +0000 (+0000) Subject: Override events for AutoScalingGroup instances X-Git-Tag: 2014.1~1087 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=772818102cc815186ed44bfb2f78ca6c36266fbf;p=openstack-build%2Fheat-build.git Override events for AutoScalingGroup instances 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 --- diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index eec9db20..0ce69609 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -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: