diff --git a/vmware_nsx/shell/nsxadmin.py b/vmware_nsx/shell/nsxadmin.py index 806bd2b500..cd72ce3bf8 100644 --- a/vmware_nsx/shell/nsxadmin.py +++ b/vmware_nsx/shell/nsxadmin.py @@ -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)) diff --git a/vmware_nsx/shell/resources.py b/vmware_nsx/shell/resources.py index 01c97e254b..fe868c7d84 100644 --- a/vmware_nsx/shell/resources.py +++ b/vmware_nsx/shell/resources.py @@ -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: {}'