'GW port AFTER_DELETE event handler to cleanup DVR ports.
This event is emitted when a router gateway port is being deleted,
so go ahead and delete the csnat ports and the floatingip
agent gateway port associated with the dvr router.'

@registry.receives(resources.ROUTER_GATEWAY, [events.AFTER_DELETE])
def _delete_dvr_internal_ports(self, event, trigger, resource, context, router, network_id, new_network_id, **kwargs):

    if (not is_distributed_router(router)):
        return
    if (not new_network_id):
        self.delete_csnat_router_interface_ports(context.elevated(), router)
    filters = {'network_id': [network_id], 'device_owner': [const.DEVICE_OWNER_ROUTER_GW]}
    ext_net_gw_ports = self._core_plugin.get_ports(context.elevated(), filters)
    if (not ext_net_gw_ports):
        self.delete_floatingip_agent_gateway_port(context.elevated(), None, network_id)
        self.l3plugin.l3_rpc_notifier.delete_fipnamespace_for_ext_net(context, network_id)
