Update _check_router_retain_needed()

Change to do a direct return of
_check_dvr_serviceable_ports_on_host() by moving distributed
check earlier.

Note: _check_dvr_serviceable_ports_on_host() can be called
with subnet_ids=[]

Trivialfix

Change-Id: I50987858b04fb1cf57109517b82624760ce089dc
This commit is contained in:
Brian Haley 2018-07-16 14:36:22 -04:00
parent e446b1e35c
commit 5a25548ada
1 changed files with 6 additions and 10 deletions

View File

@ -177,19 +177,15 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
"""Check whether a router needs to be retained on a host.
Check whether there are DVR serviceable ports owned by the host of
a l3 agent. If so, then the routers should be retained.
an l3 agent. If so, then the routers should be retained.
"""
if not host:
if not host or not router.get('distributed'):
return False
retain_router = False
if router.get('distributed'):
plugin = directory.get_plugin(plugin_constants.L3)
subnet_ids = plugin.get_subnet_ids_on_router(context, router['id'])
if subnet_ids:
retain_router = plugin._check_dvr_serviceable_ports_on_host(
context, host, subnet_ids)
return retain_router
plugin = directory.get_plugin(plugin_constants.L3)
subnet_ids = plugin.get_subnet_ids_on_router(context, router['id'])
return plugin._check_dvr_serviceable_ports_on_host(context, host,
subnet_ids)
def remove_router_from_l3_agent(self, context, agent_id, router_id):
"""Remove the router from l3 agent.