Helper Functions

Helper Functions

oslo_config.cfg.find_config_files(project=None, prog=None, extension='.conf')

Return a list of default configuration files.

Parameters
  • project – an optional project name

  • prog – the program name, defaulting to the basename of sys.argv[0], without extension .py

  • extension – the type of the config file

We default to two config files: [${project}.conf, ${prog}.conf]

And we look for those config files in the following directories:

~/.${project}/
~/
/etc/${project}/
/etc/
${SNAP_COMMON}/etc/${project}
${SNAP}/etc/${project}

We return an absolute path for (at most) one of each the default config files, for the topmost directory it exists in.

For example, if project=foo, prog=bar and /etc/foo/foo.conf, /etc/bar.conf and ~/.foo/bar.conf all exist, then we return [‘/etc/foo/foo.conf’, ‘~/.foo/bar.conf’]

If no project name is supplied, we only look for ${prog}.conf.

oslo_config.cfg.set_defaults(opts, **kwargs)

Showing detailed locations for configuration settings

oslo.config can track the location in application and library code where an option is defined, defaults are set, or values are overridden. This feature is disabled by default because it is expensive and incurs a significant performance penalty, but it can be useful for developers tracing down issues with configuration option definitions.

To turn on detailed location tracking, set the environment variable OSLO_CONFIG_SHOW_CODE_LOCATIONS to any non-empty value (for example, "1" or "yes, please") before starting the application, test suite, or script. Then use ConfigOpts.get_location() to access the location data for the option.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.