Merge "TVD|AdminUtils: Add all nsxv/v3 utils to tvd"

This commit is contained in:
Zuul 2018-01-18 08:24:31 +00:00 committed by Gerrit Code Review
commit ea075df213
3 changed files with 37 additions and 5 deletions

View File

@ -485,7 +485,12 @@ nsxadmin -r rate-limit -o nsx-update --property value=<>
NSXtvd
------
- All the nsx-v/v3 utilities can be used by calling
nsxadmin --plugin nsxv/v3 -r <> -o <>
- 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

View File

@ -110,16 +110,41 @@ def _validate_op_choice(choice, nsx_plugin):
sys.exit(1)
def _validate_plugin_choice(selected_plugin, nsx_plugin):
if nsx_plugin == 'nsxtvd':
if selected_plugin:
if selected_plugin != 'nsxv' and selected_plugin != 'nsxv3':
LOG.error('Illegal plugin %s. please select nsxv or nsxv3',
selected_plugin)
sys.exit(1)
# use nsxv or nsxv3 plugins
return selected_plugin
else:
# use the TVD pluging
return nsx_plugin
else:
if selected_plugin:
LOG.error('Cannot select plugin. The current plugin is %s',
nsx_plugin)
sys.exit(1)
return nsx_plugin
def main(argv=sys.argv[1:]):
_init_cfg()
nsx_plugin_in_use = resources.get_plugin()
resources.init_resource_plugin(
nsx_plugin_in_use,
resources.get_plugin_dir(nsx_plugin_in_use))
LOG.info('NSX Plugin in use: %s', nsx_plugin_in_use)
_validate_resource_choice(cfg.CONF.resource, nsx_plugin_in_use)
_validate_op_choice(cfg.CONF.operation, nsx_plugin_in_use)
# the user can select the specific plugin
selected_plugin = _validate_plugin_choice(cfg.CONF.plugin,
nsx_plugin_in_use)
resources.init_resource_plugin(
selected_plugin,
resources.get_plugin_dir(selected_plugin))
_validate_resource_choice(cfg.CONF.resource, selected_plugin)
_validate_op_choice(cfg.CONF.operation, selected_plugin)
registry.notify(cfg.CONF.resource, cfg.CONF.operation, 'nsxadmin',
force=cfg.CONF.force, property=cfg.CONF.property,

View File

@ -274,6 +274,8 @@ cli_opts = [cfg.StrOpt('fmt',
short='o',
help='Supported list of operations: {}'
.format(', '.join(ops))),
cfg.StrOpt('plugin',
help='nsxv or nsxv3 if the tvd plugin is used'),
cfg.BoolOpt('force',
default=False,
help='Enables \'force\' mode. No confirmations will '