Admin utility: define choices and resoucres per plugin type
Have better CLI help Change-Id: I3e5e3f3698be26bd05ab489f2921f31a394bcd5a
This commit is contained in:
parent
44dcc5cad9
commit
0a1e0d9058
@ -47,16 +47,6 @@ requests.packages.urllib3.disable_warnings()
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_plugin():
|
||||
plugin = cfg.CONF.core_plugin
|
||||
plugin_name = ''
|
||||
if plugin == constants.NSXV3_PLUGIN:
|
||||
plugin_name = 'nsxv3'
|
||||
elif plugin == constants.NSXV_PLUGIN:
|
||||
plugin_name = 'nsxv'
|
||||
return plugin_name
|
||||
|
||||
|
||||
def _init_cfg():
|
||||
cfg.CONF.register_cli_opts(resources.cli_opts)
|
||||
|
||||
@ -110,7 +100,7 @@ def _validate_op_choice(choice, nsx_plugin):
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
_init_cfg()
|
||||
nsx_plugin_in_use = _get_plugin()
|
||||
nsx_plugin_in_use = resources.get_plugin()
|
||||
resources.init_resource_plugin(
|
||||
nsx_plugin_in_use,
|
||||
resources.get_plugin_dir(nsx_plugin_in_use))
|
||||
|
@ -127,6 +127,33 @@ def get_resources(plugin_dir):
|
||||
return map(lambda module: os.path.splitext(os.path.basename(module))[0],
|
||||
modules)
|
||||
|
||||
|
||||
def get_plugin():
|
||||
plugin = cfg.CONF.core_plugin
|
||||
plugin_name = ''
|
||||
if plugin == constants.NSXV3_PLUGIN:
|
||||
plugin_name = 'nsxv3'
|
||||
elif plugin == constants.NSXV_PLUGIN:
|
||||
plugin_name = 'nsxv'
|
||||
return plugin_name
|
||||
|
||||
|
||||
def _get_choices():
|
||||
plugin = get_plugin()
|
||||
if plugin == 'nsxv3':
|
||||
return nsxv3_resources_names
|
||||
elif plugin == 'nsxv':
|
||||
return nsxv_resources_names
|
||||
|
||||
|
||||
def _get_resources():
|
||||
plugin = get_plugin()
|
||||
if plugin == 'nsxv3':
|
||||
return 'NSX-V3 resources: %s' % (', '.join(nsxv3_resources_names))
|
||||
elif plugin == 'nsxv':
|
||||
return 'NSX-V resources: %s' % (', '.join(nsxv_resources_names))
|
||||
|
||||
|
||||
cli_opts = [cfg.StrOpt('fmt',
|
||||
short='f',
|
||||
default='psql',
|
||||
@ -134,10 +161,8 @@ cli_opts = [cfg.StrOpt('fmt',
|
||||
help='Supported output formats: json, psql'),
|
||||
cfg.StrOpt('resource',
|
||||
short='r',
|
||||
choices=nsxv_resources_names + nsxv3_resources_names,
|
||||
help='Supported list of resources: NSX-V3: %s '
|
||||
'NSX-V: %s' % (', '.join(nsxv3_resources_names),
|
||||
', '.join(nsxv_resources_names))),
|
||||
choices=_get_choices(),
|
||||
help=_get_resources()),
|
||||
cfg.StrOpt('operation',
|
||||
short='o',
|
||||
help='Supported list of operations: {}'
|
||||
|
Loading…
Reference in New Issue
Block a user