]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
To support both CW and CM, return alarmurl from policy ref
authorAngus Salkeld <asalkeld@redhat.com>
Mon, 19 Aug 2013 23:46:59 +0000 (09:46 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Fri, 23 Aug 2013 00:41:36 +0000 (10:41 +1000)
This is so we can still have the following:
  AlarmActions:
  - {Ref: ServerScaleUpPolicy}

and use Ceilometer underneath.

The watchrule now tries to look up the resource by
both name and resource_by_refid.

Change-Id: I4759806919ab4f3ccef66698235b23f7f310cb03

heat/engine/resources/autoscaling.py
heat/engine/watchrule.py
heat/tests/test_autoscaling.py
heat/tests/test_engine_service.py
heat/tests/test_watch.py

index 04987b8892cee2df7d03f20b7930c86b89013512..dbcf2e3a63924dd284e96ca4f497a811c3f97f55 100644 (file)
@@ -509,7 +509,10 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
             return unicode(self._get_signed_url())
 
     def FnGetRefId(self):
-        return unicode(self.name)
+        if self.resource_id is not None:
+            return unicode(self._get_signed_url())
+        else:
+            return unicode(self.name)
 
 
 def resource_mapping():
index e791088e22d90e61064b48083a409f9e1a0c551b..b9316b8c3e6b7274ef47459ac872f6528ab4de4f 100644 (file)
@@ -257,8 +257,8 @@ class WatchRule(object):
             stack = parser.Stack.load(self.context, stack=s)
             if (stack.action != stack.DELETE
                     and stack.status == stack.COMPLETE):
-                for a in self.rule[self.ACTION_MAP[new_state]]:
-                    actions.append(stack[a].signal)
+                for refid in self.rule[self.ACTION_MAP[new_state]]:
+                    actions.append(stack.resource_by_refid(refid).signal)
             else:
                 logger.warning("Could not process watch state %s for stack" %
                                new_state)
index 7ea0b1c71f47c90b4d9ef92cd7fbf30090a80be3..5bffbe5c35890cff8759ba4775bda0b8cc06ca5d 100644 (file)
@@ -1299,6 +1299,11 @@ class AutoScalingTest(HeatTestCase):
         self._stub_lb_reload(2)
         self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2)
         self._stub_create(1)
+
+        self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone')
+        asc.ScalingPolicy.keystone().MultipleTimes().AndReturn(
+            self.fc)
+
         self.m.ReplayAll()
 
         # Trigger alarm
index 403c5b85bfa9e0956791d6125cd6551abbe2138b..8fd5d3d125346db5581cb133881df1e0e7db8698 100644 (file)
@@ -1423,8 +1423,8 @@ class StackServiceTest(HeatTestCase):
             signal = "dummyfoo"
 
         dummy_action = DummyAction()
-        self.m.StubOutWithMock(parser.Stack, '__getitem__')
-        parser.Stack.__getitem__(
+        self.m.StubOutWithMock(parser.Stack, 'resource_by_refid')
+        parser.Stack.resource_by_refid(
             'WebServerRestartPolicy').AndReturn(dummy_action)
 
         # Replace the real stack threadgroup with a dummy one, so we can
index 6d5fb4b38482c74fccd507d48b362d35ed70aa65..15c07964db71c0902d66ca79333288ccef938db0 100644 (file)
@@ -75,9 +75,9 @@ class WatchRuleTest(HeatTestCase):
 
         if action_expected:
             dummy_action = DummyAction()
-            self.m.StubOutWithMock(parser.Stack, '__getitem__')
-            parser.Stack.__getitem__(mox.IgnoreArg()
-                                     ).MultipleTimes().AndReturn(dummy_action)
+            self.m.StubOutWithMock(parser.Stack, 'resource_by_refid')
+            parser.Stack.resource_by_refid(mox.IgnoreArg()).\
+                MultipleTimes().AndReturn(dummy_action)
 
         self.m.ReplayAll()