[openstack-dev] [oslo.cfg] Dynamically load in options/groups values from the configuration files

Denis Makogon dmakogon at mirantis.com
Thu Jul 24 07:00:35 UTC 2014


On Thu, Jul 24, 2014 at 6:10 AM, Baohua Yang <yangbaohua at gmail.com> wrote:

> Hi, all
>      The current oslo.cfg module provides an easy way to load name known
> options/groups from he configuration files.
>       I am wondering if there's a possible solution to dynamically load
> them?
>
>       For example, I do not know the group names (section name in the
> configuration file), but we read the configuration file and detect the
> definitions inside it.
>
> #Configuration file:
> [group1]
> key1 = value1
> key2 = value2
>
>        Then I want to automatically load the group1. key1 and group2.
> key2, without knowing the name of group1 first.
>
>
That's actually good question. But it seems to be a bit complicated. You
have to tell to option loader about type of given configuration item.
I also was thinking about this type of feature, and that's what came into
my mind.

I found very useful JSON or YAML format for describing options. Here's
simple example how to describe configuration file that would describe
dynamic configuration.

options.yaml

- groups:
  - DEFAULT
  - NOT_DEFAULT
  - ANOTHER_ONE

- list:
  - option_a:
    - group: DEFAULT
    - value: [a, b ,c]
    - description: description

- dict:
  - option_b:
    - group: DEFAULT
    - value: { a:b, c:d}
    - description: description

and so on ...

Explanation:

` - groups` attribute defines which groups oslo.config should register.
`-  list` - option type
`- option_b` - option descriptor, each descriptor is a dict (string: list)
where key is an option name, and attributes inside it describes to which
group it belongs, its value, and description.

oslo.config would need just parse YAML file and register all options and in
the end you'll receive a set of registered options per their groups.

It's the best variant of dynamic option loading, but i'm open for
discussion.


Best regards,
Denis Makogon

>         Thanks a lot!
>
> --
> Best wishes!
> Baohua
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140724/6551075e/attachment.html>


More information about the OpenStack-dev mailing list