summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortengqm <tengqim@cn.ibm.com>2014-04-03 04:44:40 +0800
committerSteve Baker <sbaker@redhat.com>2014-05-28 09:40:00 +1200
commit930cb3c3e72829c959e128d4a6e4002265697a59 (patch)
treebe69aedfb66851f8eb08eab2f05efa9ef6ef3389
parent03dd894de4ad905dc170e358fad27d9c8ed62a73 (diff)
downloadheat-930cb3c3e72829c959e128d4a6e4002265697a59.tar.gz
Fix status reason in events for deployment signals
When a signal is received and processed by a Resource, there could be an event generated automatically. For such an event, Heat is supposed to provide some useful message (including status_reason). But currently, the resource code can only process ceilometer alarms and watch rules, for signals sent for a SoftwareDeployment resource, the signal is only providing an string 'Unknown' as the status change reason. This is confusing when a user performs 'heat event-list stack'. This patch adds an additional check (guess) whether the signal comes from a SoftwareDeployment. If that is the case, fill in the status reason as 'deployment succeeded', or 'deployment failed (n)', where n is the deploy_status_code that comes with the signal. Closes-Bug: #1300679 Change-Id: Ic970a5dac923fffdcdd365983df58f4d338de849
-rw-r--r--heat/engine/resource.py7
-rw-r--r--heat/tests/test_signal.py18
2 files changed, 23 insertions, 2 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py
index d65f67dad..2e3532b24 100644
--- a/heat/engine/resource.py
+++ b/heat/engine/resource.py
@@ -880,6 +880,13 @@ 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'
diff --git a/heat/tests/test_signal.py b/heat/tests/test_signal.py
index 090ab4e8b..bc0f5c2c8 100644
--- a/heat/tests/test_signal.py
+++ b/heat/tests/test_signal.py
@@ -295,6 +295,16 @@ 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')
@@ -306,11 +316,15 @@ 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):
+ for test_d in (ceilo_details, watch_details, str_details,
+ none_details, sds_details, sdf_details):
rsrc.signal(details=test_d)
self.m.VerifyAll()