Merge "Allow plugins to specify signal event reason"
This commit is contained in:
commit
377da55d51
@ -901,8 +901,12 @@ class Resource(object):
|
|||||||
str(self))
|
str(self))
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
|
|
||||||
self._add_event('signal', self.status, get_string_details())
|
signal_result = self.handle_signal(details)
|
||||||
self.handle_signal(details)
|
if signal_result:
|
||||||
|
reason_string = "Signal: %s" % signal_result
|
||||||
|
else:
|
||||||
|
reason_string = get_string_details()
|
||||||
|
self._add_event('signal', self.status, reason_string)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
LOG.exception(_('signal %(name)s : %(msg)s') % {'name': str(self),
|
LOG.exception(_('signal %(name)s : %(msg)s') % {'name': str(self),
|
||||||
'msg': ex})
|
'msg': ex})
|
||||||
|
@ -297,6 +297,30 @@ class SignalTest(HeatTestCase):
|
|||||||
|
|
||||||
self.m.VerifyAll()
|
self.m.VerifyAll()
|
||||||
|
|
||||||
|
def test_signal_plugin_reason(self):
|
||||||
|
# Ensure if handle_signal returns data, we use it as the reason
|
||||||
|
self.stack = self.create_stack()
|
||||||
|
self.stack.create()
|
||||||
|
|
||||||
|
rsrc = self.stack['signal_handler']
|
||||||
|
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
|
||||||
|
|
||||||
|
self.m.StubOutWithMock(generic_resource.SignalResource,
|
||||||
|
'handle_signal')
|
||||||
|
signal_details = {'status': 'COMPLETE'}
|
||||||
|
ret_expected = "Received COMPLETE signal"
|
||||||
|
generic_resource.SignalResource.handle_signal(
|
||||||
|
signal_details).AndReturn(ret_expected)
|
||||||
|
|
||||||
|
self.m.StubOutWithMock(generic_resource.SignalResource,
|
||||||
|
'_add_event')
|
||||||
|
generic_resource.SignalResource._add_event(
|
||||||
|
'signal', 'COMPLETE', 'Signal: %s' % ret_expected).AndReturn(None)
|
||||||
|
self.m.ReplayAll()
|
||||||
|
|
||||||
|
rsrc.signal(details=signal_details)
|
||||||
|
self.m.VerifyAll()
|
||||||
|
|
||||||
def test_signal_wrong_resource(self):
|
def test_signal_wrong_resource(self):
|
||||||
# assert that we get the correct exception when calling a
|
# assert that we get the correct exception when calling a
|
||||||
# resource.signal() that does not have a handle_signal()
|
# resource.signal() that does not have a handle_signal()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user