V2T migration: Cleanup migrated dfw sections
Change-Id: I1d4ec0005ece29f1b1bba30f6960f624da30cf8a
This commit is contained in:
parent
c9b15c39ce
commit
9aba62a2f9
|
@ -704,6 +704,11 @@ Client Certificate
|
||||||
|
|
||||||
nsxadmin -r certificate -o nsx-list
|
nsxadmin -r certificate -o nsx-list
|
||||||
|
|
||||||
|
- Cleanup redundant migrated objects post V2T migration::
|
||||||
|
|
||||||
|
nsxadmin -r nsx-migrate-v2t -o clean-all
|
||||||
|
|
||||||
|
|
||||||
Steps to create a TVD admin user
|
Steps to create a TVD admin user
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,16 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from neutron_lib.callbacks import registry
|
from neutron_lib.callbacks import registry
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from vmware_nsx.shell.admin.plugins.common import constants
|
from vmware_nsx.shell.admin.plugins.common import constants
|
||||||
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
|
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
|
||||||
|
from vmware_nsx.shell.admin.plugins.nsxp.resources import utils as p_utils
|
||||||
from vmware_nsx.shell.admin.plugins.nsxv3.resources import migration
|
from vmware_nsx.shell.admin.plugins.nsxv3.resources import migration
|
||||||
from vmware_nsx.shell import resources as shell
|
from vmware_nsx.shell import resources as shell
|
||||||
|
from vmware_nsxlib.v3.policy import constants as policy_constants
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@admin_utils.output_header
|
@admin_utils.output_header
|
||||||
|
@ -27,6 +32,26 @@ def cleanup_db_mappings(resource, event, trigger, **kwargs):
|
||||||
resource, event, trigger, **kwargs)
|
resource, event, trigger, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.output_header
|
||||||
|
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
|
||||||
|
sections = nsxpolicy.comm_map.list(policy_constants.DEFAULT_DOMAIN)
|
||||||
|
for section in sections:
|
||||||
|
# Look for the tag marking the migrated sections
|
||||||
|
for tag in section.get('tags', []):
|
||||||
|
if tag['scope'] == 'v_origin':
|
||||||
|
LOG.info("Deleting migrated: %s", tag['tag'])
|
||||||
|
nsxpolicy.comm_map.delete(policy_constants.DEFAULT_DOMAIN,
|
||||||
|
section['id'])
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
registry.subscribe(cleanup_db_mappings,
|
registry.subscribe(cleanup_db_mappings,
|
||||||
constants.NSX_MIGRATE_T_P,
|
constants.NSX_MIGRATE_T_P,
|
||||||
shell.Operations.CLEAN_ALL.value)
|
shell.Operations.CLEAN_ALL.value)
|
||||||
|
|
||||||
|
registry.subscribe(post_v2t_migration_cleanups,
|
||||||
|
constants.NSX_MIGRATE_V_T,
|
||||||
|
shell.Operations.CLEAN_ALL.value)
|
||||||
|
|
|
@ -290,6 +290,8 @@ nsxp_resources = {
|
||||||
[Operations.SET.value]),
|
[Operations.SET.value]),
|
||||||
constants.NSX_MIGRATE_T_P: Resource(constants.NSX_MIGRATE_T_P,
|
constants.NSX_MIGRATE_T_P: Resource(constants.NSX_MIGRATE_T_P,
|
||||||
[Operations.CLEAN_ALL.value]),
|
[Operations.CLEAN_ALL.value]),
|
||||||
|
constants.NSX_MIGRATE_V_T: Resource(constants.NSX_MIGRATE_V_T,
|
||||||
|
[Operations.CLEAN_ALL.value]),
|
||||||
}
|
}
|
||||||
|
|
||||||
nsxv3_resources_names = list(nsxv3_resources.keys())
|
nsxv3_resources_names = list(nsxv3_resources.keys())
|
||||||
|
|
Loading…
Reference in New Issue