Merge "Refresh router objects after port binding" into stable/pike

This commit is contained in:
Zuul 2018-08-13 11:47:47 +00:00 committed by Gerrit Code Review
commit b87eb4814a
2 changed files with 20 additions and 7 deletions

View File

@ -117,6 +117,15 @@ class L3RpcCallback(object):
router_ids = kwargs.get('router_ids')
host = kwargs.get('host')
context = neutron_context.get_admin_context()
routers = self._routers_to_sync(context, router_ids, host)
if utils.is_extension_supported(
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self._ensure_host_set_on_ports(context, host, routers)
# refresh the data structure after ports are bound
routers = self._routers_to_sync(context, router_ids, host)
return routers
def _routers_to_sync(self, context, router_ids, host=None):
if utils.is_extension_supported(
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
routers = (
@ -124,9 +133,6 @@ class L3RpcCallback(object):
context, host, router_ids))
else:
routers = self.l3plugin.get_sync_data(context, router_ids)
if utils.is_extension_supported(
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self._ensure_host_set_on_ports(context, host, routers)
return routers
def _ensure_host_set_on_ports(self, context, host, routers):

View File

@ -1641,9 +1641,6 @@ class TestDvrRouter(framework.L3AgentTestFramework):
self.agent.conf.agent_mode = 'dvr'
router_info = self.generate_dvr_router_info(
enable_snat=True, enable_gw=True, enable_floating_ip=True)
fip_agent_gw_port = router_info[n_const.FLOATINGIP_AGENT_INTF_KEY]
self.mock_plugin_api.get_agent_gateway_port.return_value = (
fip_agent_gw_port[0])
router_info[lib_constants.FLOATINGIP_KEY] = []
if address_scopes:
address_scope1 = {
@ -1661,6 +1658,12 @@ class TestDvrRouter(framework.L3AgentTestFramework):
address_scope1)
router_info[lib_constants.INTERFACE_KEY][1]['address_scopes'] = (
address_scope2)
# should have the same address_scopes as gw_port
fip_agent_gw_ports = router_info[n_const.FLOATINGIP_AGENT_INTF_KEY]
fip_agent_gw_ports[0]['address_scopes'] = (
router_info['gw_port']['address_scopes'])
self.mock_plugin_api.get_agent_gateway_port.return_value = (
fip_agent_gw_ports[0])
router1 = self.manage_router(self.agent, router_info)
fip_ns_name = router1.fip_ns.get_name()
self.assertTrue(self._namespace_exists(router1.ns_name))
@ -1695,7 +1698,7 @@ class TestDvrRouter(framework.L3AgentTestFramework):
# Now remove the gateway and validate if the respective interface
# routes in router namespace is deleted respectively.
self. _assert_interface_rules_on_gateway_remove(
router1, self.agent, address_scopes, fip_agent_gw_port[0],
router1, self.agent, address_scopes, fip_agent_gw_ports[0],
rfp_device, fpr_device)
def test_dvr_fip_and_router_namespace_rules_with_address_scopes_match(
@ -1763,6 +1766,10 @@ class TestDvrRouter(framework.L3AgentTestFramework):
if gw_address_scope:
router_info['gw_port']['address_scopes'] = {
str(lib_constants.IP_VERSION_4): gw_address_scope}
fip_agent_gw_ports = router_info[
n_const.FLOATINGIP_AGENT_INTF_KEY]
fip_agent_gw_ports[0]['address_scopes'] = router_info['gw_port'][
'address_scopes']
router_info[lib_constants.INTERFACE_KEY][0]['address_scopes'] = (
address_scope1)
router_info[lib_constants.INTERFACE_KEY][1]['address_scopes'] = (