Merge "Fix dvr update for subnet attach multi subnets"
This commit is contained in:
commit
866bafa631
@ -106,7 +106,6 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
||||
filter_sub = {'fixed_ips': {'subnet_id': [subnet]},
|
||||
'device_owner':
|
||||
[n_const.DEVICE_OWNER_DVR_INTERFACE]}
|
||||
router_id = None
|
||||
ports = self._core_plugin.get_ports(context, filters=filter_sub)
|
||||
for port in ports:
|
||||
router_id = port['device_id']
|
||||
@ -115,8 +114,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
|
||||
payload = {'subnet_id': subnet}
|
||||
self.l3_rpc_notifier.routers_updated(
|
||||
context, [router_id], None, payload)
|
||||
break
|
||||
LOG.debug('DVR: dvr_update_router_addvm %s ', router_id)
|
||||
LOG.debug('DVR: dvr_update_router_addvm %s ', router_id)
|
||||
|
||||
def get_dvr_routers_by_portid(self, context, port_id):
|
||||
"""Gets the dvr routers on vmport subnets."""
|
||||
|
@ -948,7 +948,8 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
|
||||
}
|
||||
]
|
||||
}
|
||||
dvr_port = {
|
||||
dvr_ports = [
|
||||
{
|
||||
'id': 'dvr_port1',
|
||||
'device_id': 'r1',
|
||||
'device_owner': 'network:router_interface_distributed',
|
||||
@ -958,23 +959,52 @@ class L3DvrSchedulerTestCase(testlib_api.SqlTestCase):
|
||||
'ip_address': '10.10.10.1'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
'id': 'dvr_port2',
|
||||
'device_id': 'r2',
|
||||
'device_owner': 'network:router_interface_distributed',
|
||||
'fixed_ips': [
|
||||
{
|
||||
'subnet_id': '80947d4a-fbc8-484b-9f92-623a6bfcf3e0',
|
||||
'ip_address': '10.10.10.123'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
r1 = {
|
||||
'id': 'r1',
|
||||
'distributed': True,
|
||||
}
|
||||
r2 = {
|
||||
'id': 'r2',
|
||||
'distributed': True,
|
||||
}
|
||||
|
||||
with mock.patch(
|
||||
'neutron.db.db_base_plugin_v2.NeutronDbPluginV2' '.get_ports',
|
||||
return_value=[dvr_port]),\
|
||||
return_value=dvr_ports),\
|
||||
mock.patch(
|
||||
'neutron.manager.NeutronManager.get_service_plugins',
|
||||
return_value=mock.Mock()),\
|
||||
mock.patch('neutron.db.l3_db.L3_NAT_db_mixin.get_router',
|
||||
return_value=r1),\
|
||||
router_id='r1', return_value=r1),\
|
||||
mock.patch('neutron.db.l3_db.L3_NAT_db_mixin.get_router',
|
||||
router_id='r2', return_value=r2),\
|
||||
mock.patch('neutron.api.rpc.agentnotifiers.l3_rpc_agent_api'
|
||||
'.L3AgentNotifyAPI'):
|
||||
self.dut.dvr_update_router_addvm(self.adminContext, port)
|
||||
self.assertEqual(
|
||||
self.dut.l3_rpc_notifier.routers_updated.call_count, 2)
|
||||
payload = {'subnet_id': port['fixed_ips'][0]['subnet_id']}
|
||||
expected_calls = [
|
||||
mock.call.routers_updated(
|
||||
self.adminContext, ['r1'], None, payload),
|
||||
mock.call.routers_updated(
|
||||
self.adminContext, ['r2'], None, payload)
|
||||
]
|
||||
self.dut.l3_rpc_notifier.routers_updated.assert_has_calls(
|
||||
expected_calls, any_order=True)
|
||||
|
||||
def test_get_dvr_routers_by_portid(self):
|
||||
dvr_port = {
|
||||
|
Loading…
Reference in New Issue
Block a user