To support both CW and CM, return alarmurl from policy ref
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
This commit is contained in:
parent
ffddeaa934
commit
cd927f7018
|
@ -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():
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue