diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index cd01dc0e7..26618b416 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -461,7 +461,7 @@ class ScalingPolicy(resource.Resource, CooldownMixin): self.stack.resolve_runtime_data, self.name) - def alarm(self): + def handle_signal(self, details=None): if self._cooldown_inprogress(): logger.info("%s NOT performing scaling action, cooldown %s" % (self.name, self.properties['Cooldown'])) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 9e588e818..db56d0a84 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -51,7 +51,7 @@ class Restarter(resource.Resource): return resource return None - def alarm(self): + def handle_signal(self, details=None): victim = self._find_resource(self.properties['InstanceId']) if victim is None: diff --git a/heat/engine/service.py b/heat/engine/service.py index e500f42e1..430c29c9c 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -619,9 +619,9 @@ class EngineService(service.Service): ('watch rule removed?', str(ex))) return - def run_alarm_action(actions): + def run_alarm_action(actions, details): for action in actions: - action() + action(details=details) stk = parser.Stack.load(stack_context, stack=stack) for res in stk: @@ -631,7 +631,8 @@ class EngineService(service.Service): rule = watchrule.WatchRule.load(stack_context, watch=wr) actions = rule.evaluate() if actions: - self._start_in_thread(sid, run_alarm_action, actions) + self._start_in_thread(sid, run_alarm_action, actions, + rule.get_details()) @request_context def create_watch_data(self, cnxt, watch_name, stats_data): diff --git a/heat/engine/watchrule.py b/heat/engine/watchrule.py index 3dc8e9837..7f6d30fd8 100644 --- a/heat/engine/watchrule.py +++ b/heat/engine/watchrule.py @@ -225,6 +225,10 @@ class WatchRule(object): return [] return self.run_rule() + def get_details(self): + return {'alarm': self.name, + 'state': self.state} + def run_rule(self): new_state = self.get_alarm_state() actions = self.rule_actions(new_state) @@ -247,7 +251,7 @@ class WatchRule(object): if (stack.action != stack.DELETE and stack.status == stack.COMPLETE): for a in self.rule[self.ACTION_MAP[new_state]]: - actions.append(stack[a].alarm) + actions.append(stack[a].signal) else: logger.warning("Could not process watch state %s for stack" % new_state) diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index ff2394886..5b7bc201b 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -942,7 +942,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -972,7 +972,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() down_policy = self.create_scaling_policy(t, stack, 'WebServerScaleDownPolicy') - down_policy.alarm() + down_policy.signal() self.assertEqual('WebServerGroup-0', rsrc.resource_id) rsrc.delete() @@ -999,7 +999,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1022,7 +1022,7 @@ class AutoScalingTest(HeatTestCase): ).AndReturn(previous_meta) self.m.ReplayAll() - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1050,7 +1050,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1072,7 +1072,7 @@ class AutoScalingTest(HeatTestCase): self._stub_create(1) self.m.ReplayAll() - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1,WebServerGroup-2', rsrc.resource_id) @@ -1102,7 +1102,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1122,7 +1122,7 @@ class AutoScalingTest(HeatTestCase): self._stub_create(1) self.m.ReplayAll() - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1,WebServerGroup-2', rsrc.resource_id) @@ -1154,7 +1154,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() up_policy = self.create_scaling_policy(t, stack, 'WebServerScaleUpPolicy') - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1174,7 +1174,7 @@ class AutoScalingTest(HeatTestCase): self._stub_create(1) self.m.ReplayAll() - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1,WebServerGroup-2', rsrc.resource_id) @@ -1206,7 +1206,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() # Trigger alarm - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1', rsrc.resource_id) @@ -1237,7 +1237,7 @@ class AutoScalingTest(HeatTestCase): self.m.ReplayAll() # Trigger alarm - up_policy.alarm() + up_policy.signal() self.assertEqual('WebServerGroup-0,WebServerGroup-1,' 'WebServerGroup-2,WebServerGroup-3', rsrc.resource_id) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index a32f29436..069ed1fe6 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -1341,7 +1341,7 @@ class StackServiceTest(HeatTestCase): self.wr.store() class DummyAction(object): - alarm = "dummyfoo" + signal = "dummyfoo" dummy_action = DummyAction() self.m.StubOutWithMock(parser.Stack, '__getitem__') @@ -1373,7 +1373,7 @@ class StackServiceTest(HeatTestCase): watch_name="OverrideAlarm", state=state) self.assertEqual(state, result[engine_api.WATCH_STATE_VALUE]) - self.assertEqual([DummyAction.alarm], + self.assertEqual([DummyAction.signal], self.eng.stg[self.stack.id].threads) self.m.VerifyAll() diff --git a/heat/tests/test_watch.py b/heat/tests/test_watch.py index e0732cab4..b3238f077 100644 --- a/heat/tests/test_watch.py +++ b/heat/tests/test_watch.py @@ -34,7 +34,7 @@ class WatchData(object): class DummyAction(object): - alarm = "DummyAction" + signal = "DummyAction" class WatchRuleTest(HeatTestCase):