]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Provide kwargs for callback abort
authorPaul Michali <pc@michali.net>
Tue, 12 Jan 2016 21:44:47 +0000 (21:44 +0000)
committerPaul Michali <pc@michali.net>
Tue, 12 Jan 2016 21:48:05 +0000 (21:48 +0000)
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
neutron/tests/unit/callbacks/test_manager.py

index 2f050d7e3dc6349ba8f65454111a72080807989a..625f52070ebe76dcad744197de73b2590e683ec5 100644 (file)
@@ -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):
index cdf32e020fc02f4604f414714d05da6a7a9aa684..f013afa78631b558623710dd39a095038e18e2b3 100644 (file)
@@ -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)