diff --git a/heat/engine/resource.py b/heat/engine/resource.py index ae213b7a69..ea1f288cad 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -985,13 +985,6 @@ class Resource(object): elif 'state' in details: # this is from watchrule return 'alarm state changed to %(state)s' % details - elif 'deploy_status_code' in details: - # this is for SoftwareDeployment - if details['deploy_status_code'] == 0: - return 'deployment succeeded' - else: - return ('deployment failed ' - '(%(deploy_status_code)s)' % details) return 'Unknown' if not callable(getattr(self, 'handle_signal', None)): diff --git a/heat/engine/resources/software_config/software_deployment.py b/heat/engine/resources/software_config/software_deployment.py index 862c971648..26ddfe27c1 100644 --- a/heat/engine/resources/software_config/software_deployment.py +++ b/heat/engine/resources/software_config/software_deployment.py @@ -440,6 +440,9 @@ class SoftwareDeployment(signal_responder.SignalResponder): status_reasons[self.STATUS_CODE] = _( 'Deployment exited with non-zero status code: %s' ) % details.get(self.STATUS_CODE) + event_reason = 'deployment failed (%s)' % status_code + else: + event_reason = 'deployment succeeded' for output in sc.outputs or []: out_key = output['name'] @@ -448,6 +451,7 @@ class SoftwareDeployment(signal_responder.SignalResponder): if output.get('error_output', False): status = self.FAILED status_reasons[out_key] = details[out_key] + event_reason = 'deployment failed' for out_key in self.ATTRIBUTES: ov[out_key] = details.get(out_key) @@ -461,6 +465,8 @@ class SoftwareDeployment(signal_responder.SignalResponder): status = self.COMPLETE status_reason = _('Outputs received') sd.update(output_values=ov, status=status, status_reason=status_reason) + # Return a string describing the outcome of handling the signal data + return event_reason def FnGetAtt(self, key, *path): ''' diff --git a/heat/tests/test_signal.py b/heat/tests/test_signal.py index fcfededa15..cbef011429 100644 --- a/heat/tests/test_signal.py +++ b/heat/tests/test_signal.py @@ -263,16 +263,6 @@ class SignalTest(HeatTestCase): none_details = None none_expected = 'No signal details provided' - # signal from a successful deployment - sds_details = {'deploy_stdout': 'foo', 'deploy_stderr': 'bar', - 'deploy_status_code': 0} - sds_expected = 'deployment succeeded' - - # signal from a failed deployment - sdf_details = {'deploy_stdout': 'foo', 'deploy_stderr': 'bar', - 'deploy_status_code': -1} - sdf_expected = 'deployment failed (-1)' - # to confirm we get a string reason self.m.StubOutWithMock(generic_resource.SignalResource, '_add_event') @@ -284,15 +274,11 @@ class SignalTest(HeatTestCase): 'signal', 'COMPLETE', str_expected).AndReturn(None) generic_resource.SignalResource._add_event( 'signal', 'COMPLETE', none_expected).AndReturn(None) - generic_resource.SignalResource._add_event( - 'signal', 'COMPLETE', sds_expected).AndReturn(None) - generic_resource.SignalResource._add_event( - 'signal', 'COMPLETE', sdf_expected).AndReturn(None) self.m.ReplayAll() for test_d in (ceilo_details, watch_details, str_details, - none_details, sds_details, sdf_details): + none_details): rsrc.signal(details=test_d) self.m.VerifyAll() diff --git a/heat/tests/test_software_deployment.py b/heat/tests/test_software_deployment.py index e9189defdd..dae3cdfeb7 100644 --- a/heat/tests/test_software_deployment.py +++ b/heat/tests/test_software_deployment.py @@ -463,7 +463,8 @@ class SoftwareDeploymentTest(HeatTestCase): 'foo': 'bar', 'deploy_status_code': 0 } - self.deployment.handle_signal(details) + ret = self.deployment.handle_signal(details) + self.assertEqual('deployment succeeded', ret) args = sd.update.call_args[1] self.assertEqual({ 'output_values': { @@ -493,7 +494,8 @@ class SoftwareDeploymentTest(HeatTestCase): 'foo': 'bar', 'deploy_status_code': '0' } - self.deployment.handle_signal(details) + ret = self.deployment.handle_signal(details) + self.assertEqual('deployment succeeded', ret) args = sd.update.call_args[1] self.assertEqual({ 'output_values': { @@ -520,7 +522,8 @@ class SoftwareDeploymentTest(HeatTestCase): self.deployments.get.return_value = sd self.software_configs.get.return_value = sc details = {'failed': 'no enough memory found.'} - self.deployment.handle_signal(details) + ret = self.deployment.handle_signal(details) + self.assertEqual('deployment failed', ret) args = sd.update.call_args[1] self.assertEqual({ 'output_values': {