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

The user of the TVD plugin can use the admin utilities of the nsxv/nsxv3 plugins
by calling:
nsxadmin --plugin nsxv -r <> -o <>
or:
nsxadmin --plugin nsxv3 -r <> -o <>

A separate patch will make sure that only the relevant neutron objects are being
retrived when using those utilities.

Change-Id: I813f69bf2e08f3845f0135fdb00666746f5d20c6
This commit is contained in:
Adit Sarfaty 2018-01-16 15:13:35 +02:00
parent 108a706d92
commit 09151b77e9
3 changed files with 37 additions and 5 deletions

View File

@ -475,7 +475,12 @@ LBaaS
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

@ -271,6 +271,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 '