From f9c4e6b2a3af1111f4458016a3aa3d03647445b0 Mon Sep 17 00:00:00 2001 From: asarfaty Date: Sun, 29 Mar 2020 07:01:27 +0200 Subject: [PATCH] Octavia: Improve callbacks for non TVD cases _check_lb_service_on_router should not call plugin get_router if hte core plugin is not TVD. The new code improves the general case of regular plugins. Change-Id: I4a63d5855c2a72e3b8d687d21f08e3718cd91981 --- .../services/lbaas/octavia/octavia_listener.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vmware_nsx/services/lbaas/octavia/octavia_listener.py b/vmware_nsx/services/lbaas/octavia/octavia_listener.py index a526959cb7..3d03897e66 100644 --- a/vmware_nsx/services/lbaas/octavia/octavia_listener.py +++ b/vmware_nsx/services/lbaas/octavia/octavia_listener.py @@ -140,12 +140,17 @@ class NSXOctaviaListenerEndpoint(object): payload=None): """Prevent removing a router GW or deleting a router used by LB""" router_id = payload.resource_id - # get the default core plugin so we can get the router project - default_core_plugin = self._get_default_core_plugin(payload.context) - router = default_core_plugin.get_router(payload.context, router_id) - # get the real core plugin - core_plugin = self._get_core_plugin( - payload.context, router['project_id']) + core_plugin = self.loadbalancer.core_plugin + if core_plugin.is_tvd_plugin(): + # TVD support + # get the default core plugin so we can get the router project + default_core_plugin = self._get_default_core_plugin( + payload.context) + router = default_core_plugin.get_router( + payload.context, router_id) + # get the real core plugin + core_plugin = self._get_core_plugin( + payload.context, router['project_id']) if core_plugin.service_router_has_loadbalancers( payload.context, router_id): msg = _('Cannot delete a %s as it still has lb service '