NSX-TVD migration admin util
Adding admin utility to map projects to a plugin. when starting to use the TVD plugin, you should use this utility for all the old projects/tenants. New projects/tenants will later be added to the nsx-t plugin as default usage: nsxadmin -r projects -o import --property plugin=nsx-v --property project=<> to automatically add all existing projects, run this command as an admin user: for project in `openstack project list | grep -v Name | awk '{print $2}'`; do nsxadmin -r projects -o import --property plugin=nsx-v --property project=$project; done Change-Id: I15e0cbe731628829af436ed265fbaa85f1c4d439
This commit is contained in:
parent
792a6a0103
commit
4dea5d93b0
@ -454,7 +454,7 @@ BGP GW edges
|
|||||||
|
|
||||||
|
|
||||||
LBaaS
|
LBaaS
|
||||||
~~~~~~~~~~~~
|
~~~~~
|
||||||
- List NSX LB services::
|
- List NSX LB services::
|
||||||
|
|
||||||
nsxadmin -r lb-services -o list
|
nsxadmin -r lb-services -o list
|
||||||
@ -472,6 +472,12 @@ LBaaS
|
|||||||
nsxadmin -r lb-monitors -o list
|
nsxadmin -r lb-monitors -o list
|
||||||
|
|
||||||
|
|
||||||
|
NSXtvd
|
||||||
|
------
|
||||||
|
|
||||||
|
- Add mapping between projects and plugin before starting to use the tvd plugin:
|
||||||
|
nsxadmin -r projects -o import --property plugin=nsx-v --property project=<>
|
||||||
|
|
||||||
Config
|
Config
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@ NSX_INI = '/etc/neutron/plugins/vmware/nsx.ini'
|
|||||||
# NSX Plugin Constants
|
# NSX Plugin Constants
|
||||||
NSXV3_PLUGIN = 'vmware_nsx.plugin.NsxV3Plugin'
|
NSXV3_PLUGIN = 'vmware_nsx.plugin.NsxV3Plugin'
|
||||||
NSXV_PLUGIN = 'vmware_nsx.plugin.NsxVPlugin'
|
NSXV_PLUGIN = 'vmware_nsx.plugin.NsxVPlugin'
|
||||||
|
NSXTVD_PLUGIN = 'vmware_nsx.plugin.NsxTVDPlugin'
|
||||||
VMWARE_NSXV = 'vmware_nsxv'
|
VMWARE_NSXV = 'vmware_nsxv'
|
||||||
VMWARE_NSXV3 = 'vmware_nsxv3'
|
VMWARE_NSXV3 = 'vmware_nsxv3'
|
||||||
|
VMWARE_NSXTVD = 'vmware_nsxtvd'
|
||||||
|
|
||||||
# Common Resource Constants
|
# Common Resource Constants
|
||||||
NETWORKS = 'networks'
|
NETWORKS = 'networks'
|
||||||
@ -57,3 +59,6 @@ LBAAS = 'lbaas'
|
|||||||
BGP_GW_EDGE = 'bgp-gw-edge'
|
BGP_GW_EDGE = 'bgp-gw-edge'
|
||||||
ROUTING_REDIS_RULE = 'routing-redistribution-rule'
|
ROUTING_REDIS_RULE = 'routing-redistribution-rule'
|
||||||
BGP_NEIGHBOUR = 'bgp-neighbour'
|
BGP_NEIGHBOUR = 'bgp-neighbour'
|
||||||
|
|
||||||
|
# NSXTV only Resource Constants
|
||||||
|
PROJECTS = 'projects'
|
||||||
|
0
vmware_nsx/shell/admin/plugins/nsxtvd/__init__.py
Normal file
0
vmware_nsx/shell/admin/plugins/nsxtvd/__init__.py
Normal file
56
vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py
Normal file
56
vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
# Copyright 2017 VMware, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
from neutron_lib.callbacks import registry
|
||||||
|
from neutron_lib import context
|
||||||
|
|
||||||
|
from vmware_nsx.db import db
|
||||||
|
from vmware_nsx.extensions import projectpluginmap
|
||||||
|
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 import resources as shell
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@admin_utils.output_header
|
||||||
|
def migrate_projects(resource, event, trigger, **kwargs):
|
||||||
|
"""Import existing openstack projects to the current plugin"""
|
||||||
|
# TODO(asarfaty): get the projects list from keystone
|
||||||
|
|
||||||
|
# get the plugin name from the user
|
||||||
|
if not kwargs.get('property'):
|
||||||
|
LOG.error("Need to specify plugin and project parameters")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
|
||||||
|
plugin = properties.get('plugin')
|
||||||
|
project = properties.get('project')
|
||||||
|
if not plugin or not project:
|
||||||
|
LOG.error("Need to specify plugin and project parameters")
|
||||||
|
return
|
||||||
|
if plugin not in projectpluginmap.VALID_TYPES:
|
||||||
|
LOG.error("The supported plugins are %s", projectpluginmap.VALID_TYPES)
|
||||||
|
return
|
||||||
|
|
||||||
|
ctx = context.get_admin_context()
|
||||||
|
if not db.get_project_plugin_mapping(ctx.session, project):
|
||||||
|
db.add_project_plugin_mapping(ctx.session, project, plugin)
|
||||||
|
|
||||||
|
|
||||||
|
registry.subscribe(migrate_projects,
|
||||||
|
constants.PROJECTS,
|
||||||
|
shell.Operations.IMPORT.value)
|
@ -78,6 +78,10 @@ def _validate_resource_choice(resource, nsx_plugin):
|
|||||||
LOG.error('Supported list of NSX-V3 resources: %s',
|
LOG.error('Supported list of NSX-V3 resources: %s',
|
||||||
resources.nsxv3_resources_names)
|
resources.nsxv3_resources_names)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
elif nsx_plugin == 'nsxtvd'and resource not in resources.nsxtvd_resources:
|
||||||
|
LOG.error('Supported list of NSX-TVD resources: %s',
|
||||||
|
resources.nsxtvd_resources_names)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _validate_op_choice(choice, nsx_plugin):
|
def _validate_op_choice(choice, nsx_plugin):
|
||||||
@ -97,6 +101,14 @@ def _validate_op_choice(choice, nsx_plugin):
|
|||||||
'resource %s', supported_resource_ops)
|
'resource %s', supported_resource_ops)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
elif nsx_plugin == 'nsxtvd':
|
||||||
|
supported_resource_ops = \
|
||||||
|
resources.nsxtvd_resources[cfg.CONF.resource].supported_ops
|
||||||
|
if choice not in supported_resource_ops:
|
||||||
|
LOG.error('Supported list of operations for the NSX-TVD '
|
||||||
|
'resource %s', supported_resource_ops)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main(argv=sys.argv[1:]):
|
def main(argv=sys.argv[1:]):
|
||||||
_init_cfg()
|
_init_cfg()
|
||||||
|
@ -207,8 +207,17 @@ nsxv_resources = {
|
|||||||
Operations.DELETE.value])
|
Operations.DELETE.value])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Add supported NSX-TVD resources in this dictionary
|
||||||
|
# TODO(asarfaty): add v+v3 resources here too
|
||||||
|
nsxtvd_resources = {
|
||||||
|
constants.PROJECTS: Resource(constants.PROJECTS,
|
||||||
|
[Operations.IMPORT.value]),
|
||||||
|
}
|
||||||
|
|
||||||
nsxv3_resources_names = list(nsxv3_resources.keys())
|
nsxv3_resources_names = list(nsxv3_resources.keys())
|
||||||
nsxv_resources_names = list(nsxv_resources.keys())
|
nsxv_resources_names = list(nsxv_resources.keys())
|
||||||
|
nsxtvd_resources_names = list(nsxtvd_resources.keys())
|
||||||
|
|
||||||
|
|
||||||
def get_resources(plugin_dir):
|
def get_resources(plugin_dir):
|
||||||
@ -224,6 +233,8 @@ def get_plugin():
|
|||||||
plugin_name = 'nsxv3'
|
plugin_name = 'nsxv3'
|
||||||
elif plugin in (constants.NSXV_PLUGIN, constants.VMWARE_NSXV):
|
elif plugin in (constants.NSXV_PLUGIN, constants.VMWARE_NSXV):
|
||||||
plugin_name = 'nsxv'
|
plugin_name = 'nsxv'
|
||||||
|
elif plugin in (constants.NSXTVD_PLUGIN, constants.VMWARE_NSXTVD):
|
||||||
|
plugin_name = 'nsxtvd'
|
||||||
return plugin_name
|
return plugin_name
|
||||||
|
|
||||||
|
|
||||||
@ -233,6 +244,8 @@ def _get_choices():
|
|||||||
return nsxv3_resources_names
|
return nsxv3_resources_names
|
||||||
elif plugin == 'nsxv':
|
elif plugin == 'nsxv':
|
||||||
return nsxv_resources_names
|
return nsxv_resources_names
|
||||||
|
elif plugin == 'nsxtvd':
|
||||||
|
return nsxtvd_resources_names
|
||||||
|
|
||||||
|
|
||||||
def _get_resources():
|
def _get_resources():
|
||||||
@ -241,6 +254,8 @@ def _get_resources():
|
|||||||
return 'NSX-V3 resources: %s' % (', '.join(nsxv3_resources_names))
|
return 'NSX-V3 resources: %s' % (', '.join(nsxv3_resources_names))
|
||||||
elif plugin == 'nsxv':
|
elif plugin == 'nsxv':
|
||||||
return 'NSX-V resources: %s' % (', '.join(nsxv_resources_names))
|
return 'NSX-V resources: %s' % (', '.join(nsxv_resources_names))
|
||||||
|
elif plugin == 'nsxtvd':
|
||||||
|
return 'NSX-TVD resources: %s' % (', '.join(nsxtvd_resources_names))
|
||||||
|
|
||||||
|
|
||||||
cli_opts = [cfg.StrOpt('fmt',
|
cli_opts = [cfg.StrOpt('fmt',
|
||||||
|
@ -286,3 +286,12 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils,
|
|||||||
# Run all utilities with backend objects
|
# Run all utilities with backend objects
|
||||||
self._test_resources_with_args(
|
self._test_resources_with_args(
|
||||||
resources.nsxv3_resources, args)
|
resources.nsxv3_resources, args)
|
||||||
|
|
||||||
|
|
||||||
|
class TestNsxtvdAdminUtils(AbstractTestAdminUtils):
|
||||||
|
|
||||||
|
def _get_plugin_name(self):
|
||||||
|
return 'nsxtvd'
|
||||||
|
|
||||||
|
def test_nsxtv_resources(self):
|
||||||
|
self._test_resources(resources.nsxtvd_resources)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user