Merge "Fix status reason in events for deployment signals" into stable/icehouse

This commit is contained in:
Jenkins 2014-06-03 03:16:04 +00:00 committed by Gerrit Code Review
commit aed6a0401e
2 changed files with 23 additions and 2 deletions

View File

@ -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'

View File

@ -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()