diff --git a/vmware_nsx/extension_drivers/dns_integration.py b/vmware_nsx/extension_drivers/dns_integration.py index 1093729de8..4bbdf189f8 100644 --- a/vmware_nsx/extension_drivers/dns_integration.py +++ b/vmware_nsx/extension_drivers/dns_integration.py @@ -496,12 +496,13 @@ def _update_port_in_external_dns_service(resource, event, trigger, **kwargs): updated_ips) -def _delete_port_in_external_dns_service(resource, event, trigger, **kwargs): +def _delete_port_in_external_dns_service(resource, event, + trigger, payload=None): dns_driver = _get_dns_driver() if not dns_driver: return - context = kwargs['context'] - port_id = kwargs['port_id'] + context = payload.context + port_id = payload.resource_id dns_data_db = obj_reg.load_class('PortDNS').get_object( context, port_id=port_id) if not dns_data_db: diff --git a/vmware_nsx/plugins/nsx/plugin.py b/vmware_nsx/plugins/nsx/plugin.py index 614e588a8e..fae4843b13 100644 --- a/vmware_nsx/plugins/nsx/plugin.py +++ b/vmware_nsx/plugins/nsx/plugin.py @@ -297,15 +297,16 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, resources.PORT, events.BEFORE_DELETE) @staticmethod - def _prevent_l3_port_delete_callback(resource, event, trigger, **kwargs): + def _prevent_l3_port_delete_callback(resource, event, + trigger, payload=None): """Register a callback to replace the default one This callback will prevent port deleting only if the port plugin is not NSX-T (in NSX-T plugin it was already handled) """ - context = kwargs['context'] - port_id = kwargs['port_id'] - port_check = kwargs['port_check'] + context = payload.context + port_id = payload.resource_id + port_check = payload.metadata['port_check'] l3plugin = directory.get_plugin(plugin_constants.L3) if l3plugin and port_check: # if not nsx-t - call super code diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index ccaa5e1709..2f73cf144d 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -2562,13 +2562,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, def delete_port(self, context, id, l3_port_check=True, nw_gw_port_check=True, force_delete_dhcp=False, allow_delete_internal=False): - kwargs = { - 'context': context, - 'port_check': l3_port_check, - 'port_id': id, - } # Send delete port notification to any interested service plugin - registry.notify(resources.PORT, events.BEFORE_DELETE, self, **kwargs) + registry.publish(resources.PORT, events.BEFORE_DELETE, self, + payload=events.DBEventPayload( + context, resource_id=id, + metadata={'port_check': l3_port_check})) neutron_db_port = self.get_port(context, id) device_id = neutron_db_port['device_id'] diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index e3e04f1ee0..4eb198a054 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -1667,14 +1667,12 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base, def _pre_delete_port_check(self, context, port_id, l2gw_port_check): """Perform checks prior to deleting a port.""" try: - kwargs = { - 'context': context, - 'port_check': l2gw_port_check, - 'port_id': port_id, - } # Send delete port notification to any interested service plugin - registry.notify( - resources.PORT, events.BEFORE_DELETE, self, **kwargs) + registry.publish( + resources.PORT, events.BEFORE_DELETE, self, + payload=events.DBEventPayload( + context, resource_id=port_id, + metadata={'port_check': l2gw_port_check})) except callback_exc.CallbackFailure as e: if len(e.errors) == 1: raise e.errors[0].error diff --git a/vmware_nsx/services/l2gateway/nsx_v3/driver.py b/vmware_nsx/services/l2gateway/nsx_v3/driver.py index 7d57784c77..cde4684426 100644 --- a/vmware_nsx/services/l2gateway/nsx_v3/driver.py +++ b/vmware_nsx/services/l2gateway/nsx_v3/driver.py @@ -132,10 +132,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin): def_l2gw_exists = True return l2_gateway - def _prevent_l2gw_port_delete(self, resource, event, trigger, **kwargs): - context = kwargs.get('context') - port_id = kwargs.get('port_id') - port_check = kwargs.get('port_check') + def _prevent_l2gw_port_delete(self, resource, event, + trigger, payload=None): + context = payload.context + port_id = payload.resource_id + port_check = payload.metadata['port_check'] if port_check: self.prevent_l2gw_port_deletion(context, port_id)