Merge "Event status set to ERROR when it fails"
This commit is contained in:
commit
1493e2823f
@ -423,6 +423,7 @@ class ManagerService(service_utils.RPCServer):
|
||||
"""Commits basic lease actions such as starting and ending."""
|
||||
lease = self.get_lease(lease_id)
|
||||
|
||||
event_status = 'DONE'
|
||||
for reservation in lease['reservations']:
|
||||
resource_type = reservation['resource_type']
|
||||
try:
|
||||
@ -436,12 +437,15 @@ class ManagerService(service_utils.RPCServer):
|
||||
'action': action_time,
|
||||
'lease': lease_id,
|
||||
})
|
||||
|
||||
if reservation_status is not None:
|
||||
event_status = 'ERROR'
|
||||
db_api.reservation_update(reservation['id'],
|
||||
{'status': reservation_status})
|
||||
{'status': 'error'})
|
||||
else:
|
||||
if reservation_status is not None:
|
||||
db_api.reservation_update(reservation['id'],
|
||||
{'status': reservation_status})
|
||||
|
||||
db_api.event_update(event_id, {'status': 'DONE'})
|
||||
db_api.event_update(event_id, {'status': event_status})
|
||||
|
||||
def _send_notification(self, lease, ctx, events=[]):
|
||||
payload = notification_api.format_lease_payload(lease)
|
||||
|
@ -1103,9 +1103,29 @@ class ServiceTestCase(tests.TestCase):
|
||||
|
||||
self.patch(self.manager, 'get_lease').return_value = self.lease
|
||||
|
||||
self.manager._basic_action(self.lease_id, '1', 'on_end',
|
||||
reservation_status='done')
|
||||
|
||||
self.reservation_update.assert_called_once_with(
|
||||
'111', {'status': 'error'})
|
||||
self.event_update.assert_called_once_with('1', {'status': 'ERROR'})
|
||||
|
||||
def test_basic_action_raise_exception_no_reservation_status(self):
|
||||
def raiseClimateException(resource_id):
|
||||
raise exceptions.ClimateException(resource_id)
|
||||
|
||||
self.manager.resource_actions = (
|
||||
{'virtual:instance':
|
||||
{'on_start': self.fake_plugin.on_start,
|
||||
'on_end': raiseClimateException}})
|
||||
|
||||
self.patch(self.manager, 'get_lease').return_value = self.lease
|
||||
|
||||
self.manager._basic_action(self.lease_id, '1', 'on_end')
|
||||
|
||||
self.event_update.assert_called_once_with('1', {'status': 'DONE'})
|
||||
self.reservation_update.assert_called_once_with(
|
||||
'111', {'status': 'error'})
|
||||
self.event_update.assert_called_once_with('1', {'status': 'ERROR'})
|
||||
|
||||
def test_getattr_with_correct_plugin_and_method(self):
|
||||
self.fake_list_computehosts = (
|
||||
|
Loading…
Reference in New Issue
Block a user