From c5166f39162324f3de70c77647bcc686f241d22a Mon Sep 17 00:00:00 2001 From: asarfaty Date: Tue, 16 Mar 2021 10:19:32 +0200 Subject: [PATCH] V2T migration: remove non-neutron ports after migration Change-Id: I52a68b3858e2cdd9e8bfed0a010bb21b39ad22e7 --- .../admin/plugins/nsxp/resources/migration.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py b/vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py index 1adb44eeb8..deb631a860 100644 --- a/vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py +++ b/vmware_nsx/shell/admin/plugins/nsxp/resources/migration.py @@ -42,7 +42,7 @@ def cleanup_db_mappings(resource, event, trigger, **kwargs): def post_v2t_migration_cleanups(resource, event, trigger, **kwargs): """Cleanup unneeded migrated resources after v2t migration is done""" nsxpolicy = p_utils.get_connected_nsxpolicy() - # clean all migrated DFW sections + # Clean all migrated DFW sections sections = nsxpolicy.comm_map.list(policy_constants.DEFAULT_DOMAIN) for section in sections: # Look for the tag marking the migrated sections @@ -53,6 +53,19 @@ def post_v2t_migration_cleanups(resource, event, trigger, **kwargs): section['id']) continue + # Cleanup migrated DVS ports (belong to the edges that are not in use) + segments = nsxpolicy.segment.list() + for seg in segments: + # Skip non-neutron segments + if not p_utils.is_neutron_resource(seg): + continue + ports = nsxpolicy.segment_port.list(seg['id']) + # Find the non-neutron ports and delete them + for port in ports: + if not p_utils.is_neutron_resource(port): + nsxpolicy.segment_port.delete(seg['id'], port['id']) + LOG.error("Deleted migrated non-neutron port %s", port['id']) + @admin_utils.output_header def migration_tier0_redistribute(resource, event, trigger, **kwargs):