Merge "Enhance getting valid router bindings"
This commit is contained in:
commit
4b8e4a29e5
@ -1474,13 +1474,25 @@ class EdgeManager(object):
|
||||
def get_routers_on_same_edge(self, context, router_id):
|
||||
edge_binding = nsxv_db.get_nsxv_router_binding(
|
||||
context.session, router_id)
|
||||
router_ids = []
|
||||
valid_router_ids = []
|
||||
if edge_binding:
|
||||
return [
|
||||
router_ids = [
|
||||
binding['router_id']
|
||||
for binding in nsxv_db.get_nsxv_router_bindings_by_edge(
|
||||
context.session, edge_binding['edge_id'])]
|
||||
else:
|
||||
return []
|
||||
if router_ids:
|
||||
valid_router_ids = self.plugin.get_routers(
|
||||
context.elevated(),
|
||||
filters={'id': router_ids},
|
||||
fields=['id'])
|
||||
valid_router_ids = [ele['id'] for ele in valid_router_ids]
|
||||
|
||||
if set(valid_router_ids) != set(router_ids):
|
||||
LOG.error(_LE("Get invalid router bindings with "
|
||||
"router ids: %s"),
|
||||
str(set(router_ids) - set(valid_router_ids)))
|
||||
return valid_router_ids
|
||||
|
||||
def bind_router_on_available_edge(
|
||||
self, context, target_router_id,
|
||||
|
@ -3755,12 +3755,12 @@ class TestSharedRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
get_routers_on_same_edge(
|
||||
context.get_admin_context(),
|
||||
r1['router']['id']))
|
||||
self.assertEqual(routers_expected, routers_1)
|
||||
self.assertEqual(set(routers_expected), set(routers_1))
|
||||
routers_2 = (self.plugin_instance.edge_manager.
|
||||
get_routers_on_same_edge(
|
||||
context.get_admin_context(),
|
||||
r2['router']['id']))
|
||||
self.assertEqual(routers_expected, routers_2)
|
||||
self.assertEqual(set(routers_expected), set(routers_2))
|
||||
self._router_interface_action('remove',
|
||||
r1['router']['id'],
|
||||
s11['subnet']['id'],
|
||||
@ -3821,7 +3821,7 @@ class TestSharedRouterTestCase(L3NatTest, L3NatTestCaseBase,
|
||||
get_routers_on_same_edge(
|
||||
context.get_admin_context(),
|
||||
r1['router']['id']))
|
||||
self.assertEqual(r1_expected, routers_1)
|
||||
self.assertEqual(set(r1_expected), set(routers_1))
|
||||
self._router_interface_action('add',
|
||||
r2['router']['id'],
|
||||
s13['subnet']['id'],
|
||||
|
Loading…
Reference in New Issue
Block a user