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,6 +509,9 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
|
||||||
return unicode(self._get_signed_url())
|
return unicode(self._get_signed_url())
|
||||||
|
|
||||||
def FnGetRefId(self):
|
def FnGetRefId(self):
|
||||||
|
if self.resource_id is not None:
|
||||||
|
return unicode(self._get_signed_url())
|
||||||
|
else:
|
||||||
return unicode(self.name)
|
return unicode(self.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -257,8 +257,8 @@ class WatchRule(object):
|
||||||
stack = parser.Stack.load(self.context, stack=s)
|
stack = parser.Stack.load(self.context, stack=s)
|
||||||
if (stack.action != stack.DELETE
|
if (stack.action != stack.DELETE
|
||||||
and stack.status == stack.COMPLETE):
|
and stack.status == stack.COMPLETE):
|
||||||
for a in self.rule[self.ACTION_MAP[new_state]]:
|
for refid in self.rule[self.ACTION_MAP[new_state]]:
|
||||||
actions.append(stack[a].signal)
|
actions.append(stack.resource_by_refid(refid).signal)
|
||||||
else:
|
else:
|
||||||
logger.warning("Could not process watch state %s for stack" %
|
logger.warning("Could not process watch state %s for stack" %
|
||||||
new_state)
|
new_state)
|
||||||
|
|
|
@ -1299,6 +1299,11 @@ class AutoScalingTest(HeatTestCase):
|
||||||
self._stub_lb_reload(2)
|
self._stub_lb_reload(2)
|
||||||
self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2)
|
self._stub_meta_expected(now, 'ChangeInCapacity : 1', 2)
|
||||||
self._stub_create(1)
|
self._stub_create(1)
|
||||||
|
|
||||||
|
self.m.StubOutWithMock(asc.ScalingPolicy, 'keystone')
|
||||||
|
asc.ScalingPolicy.keystone().MultipleTimes().AndReturn(
|
||||||
|
self.fc)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
# Trigger alarm
|
# Trigger alarm
|
||||||
|
|
|
@ -1423,8 +1423,8 @@ class StackServiceTest(HeatTestCase):
|
||||||
signal = "dummyfoo"
|
signal = "dummyfoo"
|
||||||
|
|
||||||
dummy_action = DummyAction()
|
dummy_action = DummyAction()
|
||||||
self.m.StubOutWithMock(parser.Stack, '__getitem__')
|
self.m.StubOutWithMock(parser.Stack, 'resource_by_refid')
|
||||||
parser.Stack.__getitem__(
|
parser.Stack.resource_by_refid(
|
||||||
'WebServerRestartPolicy').AndReturn(dummy_action)
|
'WebServerRestartPolicy').AndReturn(dummy_action)
|
||||||
|
|
||||||
# Replace the real stack threadgroup with a dummy one, so we can
|
# Replace the real stack threadgroup with a dummy one, so we can
|
||||||
|
|
|
@ -75,9 +75,9 @@ class WatchRuleTest(HeatTestCase):
|
||||||
|
|
||||||
if action_expected:
|
if action_expected:
|
||||||
dummy_action = DummyAction()
|
dummy_action = DummyAction()
|
||||||
self.m.StubOutWithMock(parser.Stack, '__getitem__')
|
self.m.StubOutWithMock(parser.Stack, 'resource_by_refid')
|
||||||
parser.Stack.__getitem__(mox.IgnoreArg()
|
parser.Stack.resource_by_refid(mox.IgnoreArg()).\
|
||||||
).MultipleTimes().AndReturn(dummy_action)
|
MultipleTimes().AndReturn(dummy_action)
|
||||||
|
|
||||||
self.m.ReplayAll()
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue