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
This commit is contained in:
asarfaty 2020-03-29 07:01:27 +02:00 committed by Adit Sarfaty
parent ca84633fb1
commit 990baaffc6
1 changed files with 11 additions and 6 deletions

View File

@ -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 '