Merge "Signal SoftwareDeployment resource"
This commit is contained in:
commit
0b69e23038
|
@ -129,6 +129,9 @@ class Resource(object):
|
||||||
# Default name to use for calls to self.client()
|
# Default name to use for calls to self.client()
|
||||||
default_client_name = None
|
default_client_name = None
|
||||||
|
|
||||||
|
# no signal actions
|
||||||
|
no_signal_actions = (SUSPEND, DELETE)
|
||||||
|
|
||||||
def __new__(cls, name, definition, stack):
|
def __new__(cls, name, definition, stack):
|
||||||
'''Create a new Resource of the appropriate class for its type.'''
|
'''Create a new Resource of the appropriate class for its type.'''
|
||||||
|
|
||||||
|
@ -1259,7 +1262,7 @@ class Resource(object):
|
||||||
to implement the signal, the base-class raise an exception if no
|
to implement the signal, the base-class raise an exception if no
|
||||||
handler is implemented.
|
handler is implemented.
|
||||||
'''
|
'''
|
||||||
if self.action in (self.SUSPEND, self.DELETE):
|
if self.action in self.no_signal_actions:
|
||||||
self._add_event(self.action, self.status,
|
self._add_event(self.action, self.status,
|
||||||
'Cannot signal resource during %s' % self.action)
|
'Cannot signal resource during %s' % self.action)
|
||||||
ex = Exception(_('Cannot signal resource during %s') % self.action)
|
ex = Exception(_('Cannot signal resource during %s') % self.action)
|
||||||
|
|
|
@ -178,6 +178,8 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
|
|
||||||
default_client_name = 'heat'
|
default_client_name = 'heat'
|
||||||
|
|
||||||
|
no_signal_actions = ()
|
||||||
|
|
||||||
def _signal_transport_cfn(self):
|
def _signal_transport_cfn(self):
|
||||||
return self.properties[
|
return self.properties[
|
||||||
self.SIGNAL_TRANSPORT] == self.CFN_SIGNAL
|
self.SIGNAL_TRANSPORT] == self.CFN_SIGNAL
|
||||||
|
|
|
@ -762,6 +762,23 @@ class SoftwareDeploymentTest(common.HeatTestCase):
|
||||||
self.assertEqual({'foo': 'bar', 'deploy_status_code': 0}, ca[2])
|
self.assertEqual({'foo': 'bar', 'deploy_status_code': 0}, ca[2])
|
||||||
self.assertIsNotNone(ca[3])
|
self.assertIsNotNone(ca[3])
|
||||||
|
|
||||||
|
def test_no_signal_action(self):
|
||||||
|
self._create_stack(self.template)
|
||||||
|
self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
|
||||||
|
rpcc = self.rpc_client
|
||||||
|
rpcc.signal_software_deployment.return_value = 'deployment succeeded'
|
||||||
|
details = {
|
||||||
|
'foo': 'bar',
|
||||||
|
'deploy_status_code': 0
|
||||||
|
}
|
||||||
|
actions = [self.deployment.SUSPEND, self.deployment.DELETE]
|
||||||
|
ev = self.patchobject(self.deployment, 'handle_signal')
|
||||||
|
for action in actions:
|
||||||
|
for status in self.deployment.STATUSES:
|
||||||
|
self.deployment.state_set(action, status)
|
||||||
|
self.deployment.signal(details)
|
||||||
|
ev.assert_called_with(details)
|
||||||
|
|
||||||
def test_handle_signal_ok_str_zero(self):
|
def test_handle_signal_ok_str_zero(self):
|
||||||
self._create_stack(self.template)
|
self._create_stack(self.template)
|
||||||
self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
|
self.deployment.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c'
|
||||||
|
|
Loading…
Reference in New Issue