Go to file
Alexis Lee 713217322f Hooks around mutate_config_files
This patch adds register_mutate_hook to ConfigOpts. When
mutate_config_files is otherwise finished, it calls all the registered
hooks. Each hook is passed the complete, mutated conf object, plus a
dict of just the mutated keys with old and new values.

Currently there's no way to change or remove a hook once registered.
There's no obvious usecase for this (to me at least) and the direct
implementation where we accept a unique slug alongside each hook has a
good back-compat story (generate slugs if one is not provided) so I've
plumped for the absolute simplest system.

Hooks are called in a non-deterministic order. This is intentional, it
makes it easy to avoid duplicates in the collection of hooks and
enforces independence of hook functions. It also means we don't need a
complex API for inspecting and reordering this collection.

Initially we wanted to avoid hooks in oslo.config entirely. This leads
to two problems. One, Nova delegates calling mutate_config_files to
oslo.service. How is oslo.service to know which other oslo libs Nova
uses and hence which need to be notified? We could solve this by
passing a list of hooks to oslo.service from Nova. Ugly but workable.
However, then if Nova is using oslo.foo and oslo.foo adds support for
mutable config, this leads to problem two. We must patch Nova to pass
the new hook to oslo.service. With 30+ OpenStack applications, this
would be tedious.

The collection is held on the ConfigOpts object because some projects
use multiple configs. I could offer a decorator which takes the conf
to register with as an argument but this would only be useful to
projects which use a global conf and generally seems like extra code
for minimal benefit.

Doug suggested offering a hook per option or group. The former is
inefficient when multiple options relate to a single resource. The
latter falls down on the default group, which multiple things need to
be notified about changes to.

Change-Id: Ied006631a6edbeeffae485d28eff700b13a626c1
2016-02-19 14:48:43 +00:00
2013-03-14 12:04:19 -07:00
2013-05-03 17:26:07 -04:00
2013-02-17 09:25:32 +00:00
2015-09-17 12:15:55 +00:00
2016-02-08 13:00:57 -05:00

Oslo Configuration Library

Latest Version

Downloads

The Oslo configuration API supports parsing command line arguments and .ini style configuration files.

Description
OpenStack library for config
Readme 12 MiB
Languages
Python 99.8%
Shell 0.2%