From 215d21dc04b0b9c7238d5d632c6823a78965bb1e Mon Sep 17 00:00:00 2001 From: Akash Gangil Date: Sat, 5 Dec 2015 03:28:25 -0800 Subject: [PATCH] Fix custom conf files referencing The cli args neutron-conf/nsx-conf we had until this point to conf files not in the default locations didn't work. This is because of the below code section, https://github.com/openstack/oslo.config/blob/master/oslo_config/cfg.py#L2580 the above states reloading the conf options only from the ones passed as --config-file. So that's the only way to pass new config files to oslo.config. So if someone wants to pass a custom neutron.conf/nsx.ini to admin utility, they can do: nsxadmin --config-file custom_path/neutron.conf --config-file custom_path/nsx.ini -r -o This patch removes neutron_conf and nsx_conf options from the cli and users should use --config-file option to specify any config files. Change-Id: Ia5048875fd465d46aa6f85cd02278d778eb6017e --- .../admin/plugins/common/constants.py | 4 ++++ tools/python_nsxadmin/admin/shell.py | 13 +++---------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/python_nsxadmin/admin/plugins/common/constants.py b/tools/python_nsxadmin/admin/plugins/common/constants.py index d85b443226..9f1def07b1 100644 --- a/tools/python_nsxadmin/admin/plugins/common/constants.py +++ b/tools/python_nsxadmin/admin/plugins/common/constants.py @@ -12,6 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +# Default conf file locations +NEUTRON_CONF = '/etc/neutron/neutron.conf' +NSX_INI = '/etc/neutron/plugins/vmware/nsx.ini' + # NSX Plugin Constants NSXV3_PLUGIN = 'vmware_nsx.plugin.NsxV3Plugin' NSXV_PLUGIN = 'vmware_nsx.plugin.NsxVPlugin' diff --git a/tools/python_nsxadmin/admin/shell.py b/tools/python_nsxadmin/admin/shell.py index 88726fba0e..fc76d82c9e 100644 --- a/tools/python_nsxadmin/admin/shell.py +++ b/tools/python_nsxadmin/admin/shell.py @@ -114,13 +114,7 @@ def _get_resources(): modules) -cli_opts = [cfg.StrOpt('neutron-conf', - default='/etc/neutron/neutron.conf', - help='Neutron configuration file'), - cfg.StrOpt('nsx-conf', - default='/etc/neutron/plugins/vmware/nsx.ini', - help='NSX configuration file'), - cfg.StrOpt('fmt', +cli_opts = [cfg.StrOpt('fmt', short='f', default='psql', choices=['psql', 'json'], @@ -169,8 +163,8 @@ def _init_cfg(): prog='Admin Utility', version=version.__version__, usage='nsxadmin -r -o ', - default_config_files=[cfg.CONF.neutron_conf, - cfg.CONF.nsx_conf]) + default_config_files=[constants.NEUTRON_CONF, + constants.NSX_INI]) def _validate_resource_choice(resource, nsx_plugin): @@ -205,7 +199,6 @@ def _validate_op_choice(choice, nsx_plugin): def main(argv=sys.argv[1:]): _init_cfg() _init_resource_plugin() - nsx_plugin_in_use = _get_plugin() LOG.info(_LI('NSX Plugin in use: %s'), nsx_plugin_in_use)