Use ConfigOpts.find_file() to find paste config

Use cfg's new helper method to find the paste deploy config file. The
basic behavior is "look alongside the config file" with a fall back to
the standard default config paths.

Change-Id: If7a9ac1d456f372e3f5f6c78e237a7b099d1a30e
This commit is contained in:
Mark McLoughlin
2012-05-04 10:46:06 +01:00
parent e00e45be42
commit 16c5dbf156
3 changed files with 10 additions and 24 deletions

View File

@@ -43,3 +43,4 @@ FLAGS.set_default('flat_network_bridge', 'br100')
FLAGS.set_default('sqlite_synchronous', False)
flags.DECLARE('policy_file', 'nova.policy')
flags.DECLARE('compute_scheduler_driver', 'nova.scheduler.multi')
FLAGS.set_default('api_paste_config', '$state_path/etc/nova/api-paste.ini')

View File

@@ -71,29 +71,6 @@ FLAGS.register_opt(
help='Whether to disable inter-process locks'))
def find_config(config_path):
"""Find a configuration file using the given hint.
:param config_path: Full or relative path to the config.
:returns: Full path of the config, if it exists.
:raises: `nova.exception.ConfigNotFound`
"""
possible_locations = [
config_path,
os.path.join(FLAGS.state_path, "etc", "nova", config_path),
os.path.join(FLAGS.state_path, "etc", config_path),
os.path.join(FLAGS.state_path, config_path),
"/etc/nova/%s" % config_path,
]
for path in possible_locations:
if os.path.exists(path):
return os.path.abspath(path)
raise exception.ConfigNotFound(path=os.path.abspath(config_path))
def vpn_ping(address, port, timeout=0.05, session_id=None):
"""Sends a vpn negotiation packet and returns the server session.

View File

@@ -19,6 +19,7 @@
"""Utility methods for working with WSGI servers."""
import os.path
import sys
import eventlet
@@ -357,7 +358,12 @@ class Loader(object):
"""
config_path = config_path or FLAGS.api_paste_config
self.config_path = utils.find_config(config_path)
if os.path.exists(config_path):
self.config_path = config_path
else:
self.config_path = FLAGS.find_file(config_path)
if not self.config_path:
raise exception.ConfigNotFound(path=config_path)
def load_app(self, name):
"""Return the paste URLMap wrapped WSGI application.
@@ -368,6 +374,8 @@ class Loader(object):
"""
try:
LOG.debug(_("Loading app %(name)s from %(path)s") %
{'name': name, 'path': self.config_path})
return deploy.loadapp("config:%s" % self.config_path, name=name)
except LookupError as err:
LOG.error(err)