From: Paul Michali Date: Tue, 12 Jan 2016 21:44:47 +0000 (+0000) Subject: Provide kwargs for callback abort X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8771ab481635e0d98bf5f0d34c1dbae1c872bed9;p=openstack-build%2Fneutron-build.git Provide kwargs for callback abort The callback mechanism allows notifiers to provide keyword args in the notification. If this is a create callback, and there is an exception, then the notifier will call an abort callback. However, currently, the keyword arguments are not provided to the abort callback. This information could be useful for the callbacks, and would make the mechanism consistent. This commit provides that information. Change-Id: I2ee0363b52f9de5fcd72905957e8f7e7796f630e --- diff --git a/neutron/callbacks/manager.py b/neutron/callbacks/manager.py index 2f050d7e3..625f52070 100644 --- a/neutron/callbacks/manager.py +++ b/neutron/callbacks/manager.py @@ -119,7 +119,7 @@ class CallbacksManager(object): if errors and event.startswith(events.BEFORE): abort_event = event.replace( events.BEFORE, events.ABORT) - self._notify_loop(resource, abort_event, trigger) + self._notify_loop(resource, abort_event, trigger, **kwargs) raise exceptions.CallbackFailure(errors=errors) def clear(self): diff --git a/neutron/tests/unit/callbacks/test_manager.py b/neutron/tests/unit/callbacks/test_manager.py index cdf32e020..f013afa78 100644 --- a/neutron/tests/unit/callbacks/test_manager.py +++ b/neutron/tests/unit/callbacks/test_manager.py @@ -149,10 +149,13 @@ class CallBacksManagerTestCase(base.BaseTestCase): n.return_value = ['error'] self.assertRaises(exceptions.CallbackFailure, self.manager.notify, - mock.ANY, events.BEFORE_CREATE, mock.ANY) + mock.ANY, events.BEFORE_CREATE, + 'trigger', params={'a': 1}) expected_calls = [ - mock.call(mock.ANY, 'before_create', mock.ANY), - mock.call(mock.ANY, 'abort_create', mock.ANY) + mock.call(mock.ANY, 'before_create', + 'trigger', params={'a': 1}), + mock.call(mock.ANY, 'abort_create', + 'trigger', params={'a': 1}) ] n.assert_has_calls(expected_calls)