Change-Id: I3f3b1dca78e2e9b2515231ccc6600b64f31039fb Signed-off-by: Moisés Guimarães de Medeiros <moguimar@redhat.com>
2.6 KiB
Loading Configuration Files
The config manager has two CLI options defined by default,
--config-file
and --config-dir
:
class ConfigOpts:
def __call__(self, ...):
= [
opts 'config-file',
MultiStrOpt(
...),'config-dir',
StrOpt(
...),
]
self.register_cli_opts(opts)
Option values are parsed from any supplied config files using oslo_config.iniparser. If none are specified, a default set is used for example glance-api.conf and glance-common.conf:
glance-api.conf:
[DEFAULT]
bind_port = 9292
glance-common.conf:
[DEFAULT]
bind_host = 0.0.0.0
Lines in a configuration file should not start with whitespace. A configuration file also supports comments, which must start with '#' or ';'. Option values in config files and those on the command line are parsed in order. The same option (includes deprecated option name and current option name) can appear many times, in config files or on the command line. Later values always override earlier ones.
The order of configuration files inside the same configuration directory is defined by the alphabetic sorting order of their file names. Files in a configuration directory are parsed after any individual configuration files, so values that appear in both a configuration file and configuration directory will use the value from the directory.
The parsing of CLI args and config files is initiated by invoking the config manager for example:
= cfg.ConfigOpts()
conf 'verbose', ...))
conf.register_opt(cfg.BoolOpt(1:])
conf(sys.argv[if conf.verbose:
...
Option Value Interpolation
Option values may reference other values using PEP 292 string substitution:
= [
opts 'state_path',
cfg.StrOpt(=os.path.join(os.path.dirname(__file__), '../'),
defaulthelp='Top-level directory for maintaining nova state.'),
'sqlite_db',
cfg.StrOpt(='nova.sqlite',
defaulthelp='File name for SQLite.'),
'sql_connection',
cfg.StrOpt(='sqlite:///$state_path/$sqlite_db',
defaulthelp='Connection string for SQL database.'),
]
Note
Interpolation can be avoided by using $$.
Note
You can use . to delimit option from other groups, e.g. ${mygroup.myoption}.