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, exists a proper driver to connect to those external sources and provides 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 unmutable values, this protects applications and services to have options from external sources mutaded when they reload configuration files.
oslo_config.sources.
ConfigurationSourceDriver
¶A backend driver option for oslo.config.
For each group name listed in config_source on 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.
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. |
---|
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: |
|
---|---|
Returns: | an instance of a subclass of ConfigurationSource |
oslo_config.sources.
ConfigurationSource
¶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.
get
(group_name, option_name, opt)¶Return the value of the option from the group.
Parameters: |
|
---|---|
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. |
The remote_file backend driver is the first driver implemented by oslo.config. It extends the previous limit of only accessing local files to a new scenario where it is possible to access configuration data over the network. The remote_file driver is based on the requests module and is capable of accessing remote files through HTTP or HTTPS.
To definition of a remote_file configuration data source can be as minimal as:
[DEFAULT]
config_source = external_config_group
[external_config_group]
driver = remote_file
uri = http://mydomain.com/path/to/config/data.conf
Or as complete as:
[DEFAULT]
config_source = external_config_group
[external_config_group]
driver = remote_file
uri = https://mydomain.com/path/to/config/data.conf
ca_path = /path/to/server/ca.pem
client_key = /path/to/my/key.pem
client_cert = /path/to/my/cert.pem
On the following sessions, you can find more information about this driver’s classes and its options.
oslo_config.sources._uri.
URIConfigurationSourceDriver
¶A backend driver for remote files served through http[s].
oslo_config.sources._uri.
URIConfigurationSource
(uri, ca_path=None, client_cert=None, client_key=None)¶A configuration source for remote files served through http[s].
Parameters: |
|
---|
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.