Support custom config files in admin utilities

The admin utilities usually run with the default config files:
/etc/neutron/neutron.conf and /etc/neutron/plugins/vmware/nsx.ini

In order to run it with custom files you can use:
nsxadmin --config-file <neutron conf path> --config-file <nsx conf path>

Change-Id: I0c75f0a616d8016a840611edab1e3b3edb53c4ad
This commit is contained in:
asarfaty 2020-06-18 13:28:27 +02:00
parent f741e10ba4
commit ed6bd1f4e9
2 changed files with 17 additions and 7 deletions

View File

@ -1,9 +1,12 @@
Admin Utility
=============
NSX-V and NSX-T support the nsxadmin utility. This enables and administrator to determine and rectify inconsistencies between the Neutron DB and NSX.
The VMWare NSX plugins support the nsxadmin utility. This enables and administrator to determine and rectify inconsistencies between the Neutron DB and NSX, in addition to performing different configuration changes and migrations.
usage: nsxadmin -r <resources> -o <operation>
In order to specify config files:
usage: nsxadmin --config-file <neutron config path> --config-file <nsx config path > -r <resources> -o <operation>
NSX-V Plugin
------------

View File

@ -56,16 +56,23 @@ def _init_cfg():
# register must come after above unregister to avoid duplicates
cfg.CONF.register_cli_opts(resources.cli_opts)
# Init the neutron config
neutron_config.init(args=['--config-file', constants.NEUTRON_CONF,
'--config-file', constants.NSX_INI])
# Make sure the default config files are used if not specified in args
default_config_files = [constants.NEUTRON_CONF,
constants.NSX_INI]
config_args = sys.argv[1:]
if '--config-file' not in config_args:
# Add default config files
config_args = []
for file in default_config_files:
config_args.extend(['--config-file', file])
cfg.CONF(args=sys.argv[1:], project='NSX',
# Init the CONF and neutron config (Used by the core plugin)
neutron_config.init(args=config_args)
cfg.CONF(args=config_args, project='NSX',
prog='Admin Utility',
version=version.__version__,
usage='nsxadmin -r <resources> -o <operation>',
default_config_files=[constants.NEUTRON_CONF,
constants.NSX_INI])
default_config_files=default_config_files)
def _validate_resource_choice(resource, nsx_plugin):