From 8771ab481635e0d98bf5f0d34c1dbae1c872bed9 Mon Sep 17 00:00:00 2001 From: Paul Michali Date: Tue, 12 Jan 2016 21:44:47 +0000 Subject: [PATCH] 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 --- neutron/callbacks/manager.py | 2 +- neutron/tests/unit/callbacks/test_manager.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) 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) -- 2.45.2