Hardcoded Paths in Common Python Files

Bug #1057848 reported by Koaps
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Invalid
Undecided
Unassigned

Bug Description

I was trying to use an alternative path for keystone, glance, and nova and I kept running into an issue were some of the tools didn't know where to find the configs.

The services themselves seem to have a --config-dir option but there are some things that don't.

Right now the two I keep hitting are the openstack-db script and the cfg.py that's in openstack/common dir in the various python site-package dirs for the services.

## cfg.py
/usr/lib/python2.6/site-packages/keystone-2013.1-py2.6.egg/keystone/openstack/common/cfg.py
/usr/lib/python2.6/site-packages/glance-2013.1-py2.6.egg/glance/openstack/common/cfg.py
/usr/lib/python2.6/site-packages/nova-2012.2-py2.6.egg/nova/openstack/common/cfg.py

lines:
    395 os.path.join('/etc', project) if project else None,
    396 '/etc'

## openstack-db
/usr/bin/openstack-db

lines:
    116 APP_CONFIG="/etc/glance/glance-registry.conf"
    117 else
    118 APP_CONFIG="/etc/$APP/$APP.conf"

In both cases I'm adding openstack so that the final paths are /etc/openstack/keystone, /etc/openstack/glance, and /etc/openstack/nova

It would be nice if there was a --config-dir option for openstack-db and maybe have cfg.py check for that.

Revision history for this message
Koaps (koaps) wrote :

I found another one:

/usr/lib/python2.6/site-packages/quantum-2013.1-py2.6.egg/quantum/common/utils.py

It's not honoring the config-dir option and instead using a set of hardcoded paths.

     95 fix_path(os.path.join('~', '.local',
     96 'etc', 'quantum')),
     97 '/usr/etc/quantum',
     98 '/usr/local/etc/quantum',
     99 '/etc/quantum/',
    100 '/etc']

This was preventing the quantum-server from locating the policy.json file:

2012-10-01 14:01:45 ERROR [quantum.api.v2.resource] create failed
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/quantum-2013.1-py2.6.egg/quantum/api/v2/resource.py", line 95, in resource
    result = method(request=request, **args)
  File "/usr/lib/python2.6/site-packages/quantum-2013.1-py2.6.egg/quantum/api/v2/base.py", line 290, in create
    plugin=self._plugin)
  File "/usr/lib/python2.6/site-packages/quantum-2013.1-py2.6.egg/quantum/policy.py", line 191, in enforce
    init()
  File "/usr/lib/python2.6/site-packages/quantum-2013.1-py2.6.egg/quantum/policy.py", line 50, in init
    raise exceptions.PolicyNotFound(path=cfg.CONF.policy_file)
PolicyNotFound: Policy configuration policy.json could not be found

By adding my path /etc/openstack/quantum, I was able to successfully create a new network with net-create.

I do start quantum-server with the --config-dir option.

/usr/bin/quantum-server --config-dir /etc/openstack/quantum --log-file /var/log/openstack/quantum-server.log

summary: - Configuration Directory Hardcoded Paths
+ Hardcoded Paths in Common Python Files
Revision history for this message
Gary Kotton (garyk) wrote :

Hi, Can you please do the following:
/usr/bin/quantum-server --config-file /etc/openstack/quantum/quantum.conf --config-file /etc/openstack/quantum/plugins/openvswith/openvswitch.ini --log-file /var/log/openstack/quantum-server.log
That is, state the quamtu, conf and plugin specific file.
Thanks
Gary

Revision history for this message
Koaps (koaps) wrote :

Hi Gary,

Looks like when I pulled the code down yesterday for the l3_agent fix, it updated the quantum-server also, so now I get an error telling me I have to use --config-file.

But even when specifying that, I get the same error.

# This Fails
sudo -u quantum sudo quantum-server --config-dir /etc/openstack/quantum --log-file /var/log/openstack/quantum-server.log

ERROR: Unable to find configuration file via the default search paths (~/.quantum/, ~/, /etc/quantum/, /etc/) and the '--config-file' option!

# This runs
sudo -u quantum sudo quantum-server --config-dir /etc/openstack/quantum --config-file /etc/openstack/quantum/quantum.conf --log-file /var/log/openstack/quantum-server.log

But when I try to run net-create I get:

quantum net-create net1
which: no gedit in (/root/bin:/root/apache-maven-3.0.4/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)
which: no kate in (/root/bin:/root/apache-maven-3.0.4/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin)
Policy configuration policy.json could not be found

Monty Taylor (mordred)
affects: openstack-ci → oslo
Revision history for this message
Mark McLoughlin (markmc) wrote :

--config-dir isn't what you want here, instead use --config-file to point to your config files if they are not in the standard paths

Changed in oslo:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.