Change log message to avoid typeFormat exception

When a ClimateException is thrown when executing the end_lease action,
a LOG.exception with an invalid typeFormat was executed.
We changed that and also added a test to verify the changes.

Closes-Bug: #1294734
Change-Id: Idff6ffe2c5438192ec2470aeceb858045ce9d297
This commit is contained in:
cmart 2014-04-03 17:08:46 -03:00
parent 615d4c9fee
commit ca6d12458b
2 changed files with 16 additions and 1 deletions

View File

@ -357,7 +357,7 @@ class ManagerService(service_utils.RPCServer):
)
except common_ex.ClimateException:
LOG.exception("Failed to execute action %(action)s "
"for lease %(lease)d"
"for lease %(lease)s"
% {
'action': action_time,
'lease': lease_id,

View File

@ -564,6 +564,21 @@ class ServiceTestCase(tests.TestCase):
'111', {'status': 'IN_USE'})
self.event_update.assert_called_once_with('1', {'status': 'DONE'})
def test_basic_action_raise_exception(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'})
def test_getattr_with_correct_plugin_and_method(self):
self.fake_list_computehosts = \
self.patch(self.fake_phys_plugin, 'list_computehosts')