Merge "Takes hosting information into account when determining updated routers"

This commit is contained in:
Jenkins 2017-06-28 15:59:16 +00:00 committed by Gerrit Code Review
commit 569bc7def1
2 changed files with 24 additions and 3 deletions

View File

@ -597,11 +597,16 @@ class RoutingServiceHelper(object):
:return: None
"""
try:
ids_previously_hosted_routers = (
set(r_id for r_id, rdata in self.router_info.items()
if rdata.router.get('hosting_device',
{}).get('id') == device_id))
if all_routers:
prev_router_ids = set(self.router_info)
prev_router_ids = ids_previously_hosted_routers
else:
prev_router_ids = set(self.router_info) & set(
[router['id'] for router in routers])
prev_router_ids = (ids_previously_hosted_routers &
set([router['id'] for router in routers]))
cur_router_ids = set()
deleted_routerids_list = []

View File

@ -871,6 +871,22 @@ class TestBasicRoutingOperations(base.BaseTestCase):
self.routing_helper._router_removed.assert_any_call(router2['id'])
self.routing_helper._process_router.assert_called_with(ri1)
def test_process_routers_skips_routers_on_other_hosting_devices(self):
router1, port1 = prepare_router_data()
r1_id = router1['id']
r1_info = routing_svc_helper.RouterInfo(r1_id, router1)
router2, port2 = prepare_router_data()
r2_id = router2['id']
self.routing_helper.router_info = {
r1_id: r1_info,
r2_id: routing_svc_helper.RouterInfo(r2_id, router2)}
self.routing_helper._process_router = mock.Mock()
self.routing_helper._router_removed = mock.Mock()
self.routing_helper._process_routers([router1], [],
router1['hosting_device']['id'])
self.routing_helper._process_router.assert_called_once_with(r1_info)
self.assertEqual(0, self.routing_helper._router_removed.call_count)
class TestDeviceSyncOperations(base.BaseTestCase):