From a69d92e0e82fc028c626d3e9bf155a070931de4f Mon Sep 17 00:00:00 2001 From: Boden R Date: Wed, 29 Aug 2018 09:11:28 -0600 Subject: [PATCH] use payloads for SUBNET BEFORE_DELETE events This patch switches over to the payload style of callbacks for the BEFORE_DELETE events of SUBNET resources. NeutronLibImpact Change-Id: I08998302319f433b5f210e7c9db359d3142dcb67 --- neutron/db/db_base_plugin_v2.py | 6 +++--- neutron/tests/unit/db/test_db_base_plugin_v2.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index 826e8dc56e5..967ac026331 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -79,9 +79,9 @@ AUTO_DELETE_PORT_OWNERS = [constants.DEVICE_OWNER_DHCP] def _check_subnet_not_used(context, subnet_id): try: - kwargs = {'context': context, 'subnet_id': subnet_id} - registry.notify( - resources.SUBNET, events.BEFORE_DELETE, None, **kwargs) + registry.publish( + resources.SUBNET, events.BEFORE_DELETE, None, + payload=events.DBEventPayload(context, resource_id=subnet_id)) except exceptions.CallbackFailure as e: raise exc.SubnetInUse(subnet_id=subnet_id, reason=e) diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 8373c019d47..e3245ca1edd 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -5499,13 +5499,13 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): def test_delete_subnet_with_callback(self): with self.subnet() as subnet,\ - mock.patch.object(registry, 'notify') as notify: + mock.patch.object(registry, 'publish') as publish: errors = [ exceptions.NotificationError( 'fake_id', lib_exc.NeutronException()), ] - notify.side_effect = [ + publish.side_effect = [ exceptions.CallbackFailure(errors=errors), None ]