oslo_config.sources package

oslo_config.sources package

Module contents

Oslo.config’s primary source of configuration data are plaintext, INI-like style, configuration files. With the addition of backend drivers support, it is possible to store configuration data in different places and with different formats, as long as there exists a proper driver to connect to those external sources and provide a way to fetch configuration values from them.

A backend driver implementation is divided in two main classes, a driver class of type ConfigurationSourceDriver and a configuration source class of type ConfigurationSource.

IMPORTANT: At this point, all backend drivers are only able to provide immutable values. This protects applications and services from having options in external sources mutated when they reload configuration files.

class oslo_config.sources.ConfigurationSource

Bases: object

A configuration source option for oslo.config.

A configuration source is able to fetch configuration values based on a (group, option) key from an external source that supports key-value mapping such as INI files, key-value stores, secret stores, and so on.

abstract get(group_name, option_name, opt)

Return the value of the option from the group.

Parameters
  • group_name (str) – Name of the group.

  • option_name (str) – Name of the option.

  • opt (Opt) – The option definition.

Returns

A tuple (value, location) where value is the option value or oslo_config.sources._NoValue if the (group, option) is not present in the source, and location is a LocationInfo.

class oslo_config.sources.ConfigurationSourceDriver

Bases: object

A backend driver option for oslo.config.

For each group name listed in config_source in the DEFAULT group, a ConfigurationSourceDriver is responsible for creating one new instance of a ConfigurationSource. The proper driver class to be used is selected based on the driver option inside each one of the groups listed in config_source and loaded through entry points managed by stevedore using the namespace oslo.config.driver:

[DEFAULT]
config_source = source1
config_source = source2
...

[source1]
driver = remote_file
...

[source2]
driver = castellan
...

Each specific driver knows all the available options to properly instatiate a ConfigurationSource using the values comming from the given group in the open_source_from_opt_group() method and is able to generate sample config through the list_options_for_discovery() method.

abstract list_options_for_discovery()

Return the list of options available to configure a new source.

Drivers should advertise all supported options in this method for the purpose of sample generation by oslo-config-generator.

For an example on how to implement this method you can check the remote_file driver at oslo_config.sources._uri.URIConfigurationSourceDriver.

Returns

a list of supported options of a ConfigurationSource.

abstract open_source_from_opt_group(conf, group_name)

Return an open configuration source.

Uses group_name to find the configuration settings for the new source and then open the configuration source and return it.

If a source cannot be open, raises an appropriate exception.

Parameters
  • conf (ConfigOpts) – The active configuration option handler from which to seek configuration values.

  • group_name (str) – The configuration option group name where the options for the source are stored.

Returns

an instance of a subclass of ConfigurationSource

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.