Update the host_id for network:router_gateway interfaces
The ports owned by a router_gateway need to get its host_id property
updated during the failover of a router. Otherwise the port connected
to the external network will always have its host_id set to the value
obtained during creation.
Change-Id: I5eca20e3cc64d7a9e52b0556a3cadd29eb4c821d
Closes-Bug: 1694337
(cherry picked from commit d8334b41d2
)
This commit is contained in:
parent
59c6530990
commit
f6b3d25c6e
|
@ -776,7 +776,8 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin,
|
|||
device_filter = {'device_id': list(states.keys()),
|
||||
'device_owner':
|
||||
[constants.DEVICE_OWNER_HA_REPLICATED_INT,
|
||||
constants.DEVICE_OWNER_ROUTER_SNAT]}
|
||||
constants.DEVICE_OWNER_ROUTER_SNAT,
|
||||
constants.DEVICE_OWNER_ROUTER_GW]}
|
||||
ports = self._core_plugin.get_ports(admin_ctx, filters=device_filter)
|
||||
active_ports = (port for port in ports
|
||||
if states[port['device_id']] == n_const.HA_ROUTER_STATE_ACTIVE)
|
||||
|
|
|
@ -84,6 +84,7 @@ class L3HATestFramework(testlib_api.SqlTestCase):
|
|||
router['ha'] = ha
|
||||
if distributed is not None:
|
||||
router['distributed'] = distributed
|
||||
|
||||
return self.plugin.create_router(ctx, {'router': router})
|
||||
|
||||
def _migrate_router(self, router_id, ha):
|
||||
|
@ -1061,26 +1062,41 @@ class L3HAModeDbTestCase(L3HATestFramework):
|
|||
self.admin_ctx,
|
||||
filters=device_filter)[0]
|
||||
|
||||
def _get_router_port_bindings(self, router_id):
|
||||
device_filter = {'device_id': [router_id],
|
||||
'device_owner':
|
||||
[constants.DEVICE_OWNER_HA_REPLICATED_INT,
|
||||
constants.DEVICE_OWNER_ROUTER_SNAT,
|
||||
constants.DEVICE_OWNER_ROUTER_GW]}
|
||||
return self.core_plugin.get_ports(
|
||||
self.admin_ctx,
|
||||
filters=device_filter)
|
||||
|
||||
def test_update_router_port_bindings_updates_host(self):
|
||||
ext_net = self._create_network(self.core_plugin, self.admin_ctx,
|
||||
external=True)
|
||||
network_id = self._create_network(self.core_plugin, self.admin_ctx)
|
||||
subnet = self._create_subnet(self.core_plugin, self.admin_ctx,
|
||||
network_id)
|
||||
interface_info = {'subnet_id': subnet['id']}
|
||||
|
||||
router = self._create_router()
|
||||
self.plugin._update_router_gw_info(self.admin_ctx, router['id'],
|
||||
{'network_id': ext_net})
|
||||
self.plugin.add_router_interface(self.admin_ctx,
|
||||
router['id'],
|
||||
interface_info)
|
||||
self.plugin._update_router_port_bindings(
|
||||
self.admin_ctx, {router['id']: 'active'}, self.agent1['host'])
|
||||
|
||||
port = self._get_first_interface(router['id'])
|
||||
self.assertEqual(self.agent1['host'], port[portbindings.HOST_ID])
|
||||
for port in self._get_router_port_bindings(router['id']):
|
||||
self.assertEqual(self.agent1['host'], port[portbindings.HOST_ID])
|
||||
|
||||
self.plugin._update_router_port_bindings(
|
||||
self.admin_ctx, {router['id']: 'active'}, self.agent2['host'])
|
||||
port = self._get_first_interface(router['id'])
|
||||
self.assertEqual(self.agent2['host'], port[portbindings.HOST_ID])
|
||||
|
||||
for port in self._get_router_port_bindings(router['id']):
|
||||
self.assertEqual(self.agent2['host'], port[portbindings.HOST_ID])
|
||||
|
||||
def test_ensure_host_set_on_ports_dvr_ha_binds_to_active(self):
|
||||
agent3 = helpers.register_l3_agent('host_3',
|
||||
|
|
Loading…
Reference in New Issue