Merge "V2T migration: remove non-neutron ports after migration" into stable/ussuri

This commit is contained in:
Zuul 2021-03-16 14:57:00 +00:00 committed by Gerrit Code Review
commit 44077705ab
1 changed files with 14 additions and 1 deletions

View File

@ -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):