From 98c9df4cc00817ce8bf808867b963e1357f94301 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Wed, 21 Apr 2021 06:36:04 -0700 Subject: [PATCH] [MP2P] Do not assume Tier0 uplink ports are attached to LS Attempt to collect uplink LS only if there is a linked logical port switch id for the uplink port Change-Id: I0774f7173d698039c80da85336a57cfd31c2add0 --- .../admin/plugins/nsxv3/resources/migration.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py index 186eb113f9..c901baf3c0 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/migration.py @@ -502,9 +502,19 @@ def migrate_tier0s(nsxlib, nsxpolicy, plugin): uplink_port = nsxlib.logical_router_port.get_tier0_uplink_port(tier0) if uplink_port: # Get the external LS id from the uplink port - port_id = uplink_port['linked_logical_switch_port_id']['target_id'] - port = nsxlib.logical_port.get(port_id) - public_switches.append(port['logical_switch_id']) + linked_ls_id = uplink_port.get('linked_logical_switch_port_id') + if linked_ls_id: + try: + port_id = linked_ls_id['target_id'] + port = nsxlib.logical_port.get(port_id) + public_switches.append(port['logical_switch_id']) + except KeyError as e: + LOG.info("Required attribute missing: %s. Cannot " + "add public switch to objects to migrate", e) + else: + LOG.info("Uplink port %s for Tier0 router %s is not " + "connected to a logical switch", + tier0, uplink_port['id']) return public_switches, migrated_tier0s