From 85f4e2b993ca767dc266dd89bd305c5e2a00c550 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 12 Apr 2021 10:53:31 -0700 Subject: [PATCH] [V2T] Fetch routers for network instead of interfaces This commit will ensure the actual number of routers attached to a given network is retrieved and considered for migration. Applies set logic to rule out duplicates, and prints the list of routers attached to the network in case multiple are found. Change-Id: Ia033a9229e77b49d96cb9885ecc69e22821be696 --- .../shell/admin/plugins/nsxv/resources/migration.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py index f2a66a1df9..8412695dfe 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/migration.py @@ -160,15 +160,16 @@ def _validate_networks(plugin, admin_context, transit_networks): "allowed." % (net['id'], n_dhcp_subnets)) # Network attached to multiple routers - intf_ports = plugin._get_network_interface_ports( - admin_context, net['id']) - if len(intf_ports) > 1: + router_ids = set(plugin._get_network_router_ids( + admin_context, net['id'])) + if len(router_ids) > 1: log_error("Network %s has interfaces on multiple " - "routers. Only 1 is allowed." % net['id']) + "routers (%s). Only 1 is allowed." + % (net['id'], ",".join(router_ids))) if (cfg.CONF.vlan_transparent and net.get('vlan_transparent') is True): - if len(intf_ports) > 0: + if len(router_ids) > 0: log_error("VLAN Transparent network %s cannot be " "attached to a logical router." % net['id']) if n_dhcp_subnets > 0: @@ -177,6 +178,8 @@ def _validate_networks(plugin, admin_context, transit_networks): # Subnets overlapping with the transit network ipv6_subnets = 0 + intf_ports = plugin._get_network_interface_ports( + admin_context, net['id']) for subnet in subnets: # get the subnet IPs if ('allocation_pools' in subnet and