Fix up find_config_file() to accept an app_name arg. Update all documentation referencing config files.

This commit is contained in:
jaypipes@gmail.com 2011-05-09 14:55:46 -04:00
parent efa78881eb
commit 1359d6e2cc
8 changed files with 40 additions and 16 deletions

View File

@ -57,7 +57,7 @@ if __name__ == '__main__':
(options, args) = config.parse_options(oparser)
try:
conf, app = config.load_paste_app('api', options, args)
conf, app = config.load_paste_app('glance-api', options, args)
server = wsgi.Server()
server.start(app, int(conf['bind_port']), conf['bind_host'])

View File

@ -133,7 +133,7 @@ def do_start(server, options, args):
pid_file = '/var/run/glance/%s.pid' % server
else:
pid_file = os.path.abspath(options['pid_file'])
conf_file = config.find_config_file(options, args)
conf_file = config.find_config_file(server, options, args)
if not conf_file:
sys.exit("Could not find any configuration file to use!")
launch_args = [(conf_file, pid_file)]

View File

@ -17,10 +17,34 @@
Configuring Glance
==================
Glance has a number of options that you can use to configure the Glance API
server, the Glance Registry server, and the various storage backends that
Glance can use to store images.
Most configuration is done via configuration files, with the Glance API
server and Glance Registry server using separate configuration files.
When starting up a Glance server, you can specify the configuration file to
use (see `the documentation on controller Glance servers <controllingservers>`_).
If you do **not** specify a configuration file, Glance will look in the following
directories for a configuration file, in order:
* ``$CWD``
* ``~/.glance``
* ``~/``
* ``/etc/glance``
* ``/etc``
The Glance API server configuration file should be named ``glance-api.conf``.
Similarly, the Glance Registry server configuration file should be named
``glance-registry.conf``. If you installed Glance via your operating system's
package management system, it is likely that you will have sample
configuration files installed in ``/etc/glance``.
In addition to this documentation page, you can check the
``etc/glance.conf.sample`` sample configuration file distributed with Glance
for an example configuration file with detailed comments on what each options
does.
``etc/glance-api.conf`` and ``etc/glance-registry.conf`` sample configuration
files distributed with Glance for example configuration files for each server
application with detailed comments on what each options does.
Common Configuration Options in Glance
--------------------------------------
@ -67,7 +91,7 @@ Configuring Logging in Glance
There are a number of configuration options in Glance that control how Glance
servers log messages. The configuration options can be specified both on the
command line and in the ``glance.conf`` config file.
command line and in config files.
* ``--log-config=PATH``
@ -113,7 +137,7 @@ Configuring Glance Storage Backends
There are a number of configuration options in Glance that control how Glance
stores disk images. These configuration options are specified in the
``glance.conf`` config file `in the section [app:glance-api]`.
``glance-api.conf`` config file in the section ``[DEFAULT]``.
* ``default_store=STORE``
@ -199,7 +223,7 @@ Configuring the Glance Registry
Glance ships with a default, reference implementation registry server. There
are a number of configuration options in Glance that control how this registry
server operates. These configuration options are specified in the
``glance.conf`` config file `in the section [app:glance-registry]`.
``glance-registry.conf`` config file in the section ``[DEFAULT]``.
* ``sql_connection=CONNECTION_STRING`` (``--sql-connection`` when specified
on command line)

View File

@ -51,7 +51,7 @@ swift_store_container = glance
# Do we create the container if it does not exist?
swift_store_create_container_on_put = False
[composite:api]
[composite:glance-api]
use = egg:Paste#urlmap
/: versions
/v1.0: api_1_0

View File

@ -175,14 +175,14 @@ def setup_logging(options, conf):
root_logger.addHandler(handler)
def find_config_file(options, args):
def find_config_file(app_name, options, args):
"""
Return the first config file found.
Return the first config file found for an application.
We search for the paste config file in the following order:
* If --config-file option is used, use that
* If args[0] is a file, use that
* Search for glance.conf in standard directories:
* Search for $app.conf in standard directories:
* .
* ~.glance/
* ~
@ -208,7 +208,7 @@ def find_config_file(options, args):
'/etc']
for cfg_dir in config_file_dirs:
cfg_file = os.path.join(cfg_dir, 'glance.conf')
cfg_file = os.path.join(cfg_dir, '%s.conf' % app_name)
if os.path.exists(cfg_file):
return cfg_file
@ -238,7 +238,7 @@ def load_paste_config(app_name, options, args):
:raises RuntimeError when config file cannot be located or there was a
problem loading the configuration file.
"""
conf_file = find_config_file(options, args)
conf_file = find_config_file(app_name, options, args)
if not conf_file:
raise RuntimeError("Unable to locate any configuration file. "
"Cannot load application %s" % app_name)

View File

@ -148,7 +148,7 @@ registry_host = 0.0.0.0
registry_port = %(registry_port)s
log_file = %(log_file)s
[composite:api]
[composite:glance-api]
use = egg:Paste#urlmap
/: versions
/v1.0: api_1_0

View File

@ -45,7 +45,7 @@ class TestLogging(functional.FunctionalTest):
api_log_out = open(self.api_server.log_file, 'r').read()
self.assertTrue('DEBUG [api]' in api_log_out)
self.assertTrue('DEBUG [glance-api]' in api_log_out)
self.assertTrue(os.path.exists(self.registry_server.log_file))