Michal 'vorner' Vaner e93f78639d [2113] Check the configuration by creating the list 12 years ago
..
tests e93f78639d [2113] Check the configuration by creating the list 12 years ago
Makefile.am cbb514313e [1976] Fix distcheck 12 years ago
README 95689208a5 [trac810] README about plugins 14 years ago
b10logging.py 251a32a1fd [trac1004] add tests and additional fixes 14 years ago
datasrc.spec.pre.in eabb375e7d [1976] Provide default configuration for static data source 13 years ago
datasrc_config_plugin.py e93f78639d [2113] Check the configuration by creating the list 12 years ago
logging.spec 07d2c46d78 [1405] Make default "flush" option for logging "true" 13 years ago
tsig_keys.py d3da4f1f4f [trac875] Comments & descriptions 14 years ago
tsig_keys.spec d3da4f1f4f [trac875] Comments & descriptions 14 years ago

README

How to write a configuration plugin
===================================

The plugins are used to describe configuration modules that have no hosting
process. Therefore there's no process to provide their specification and to
check them for correctness. So the plugin takes this responsibility.

Each plugin is a python file installed into the
`@prefix@/share/@PACKAGE@/config_plugins` directory (usually
`/usr/share/bind10/config_plugins`). It is loaded automatically at startup.

The entrypoint of a plugin is function called `load()`. It should return a
tuple, first value should be the module specification (usually instance of
`isc.config.module_spec.ModuleSpec`, loaded by `module_spec_from_file()`).

The second value is a callable object. It will be called whenever the
configuration of module needs to be checked. The only parameter will be the new
config (as python dictionary). To accept the new configuration, return None. If
you return a string, it is taken as an error message. If you raise an
exception, the config is rejected as well, however it is not considered a
graceful rejection, but a failure of the module.

So, this is how a plugin could look like:

from isc.config.module_spec import module_spec_from_file

def check(config):
if config['bogosity'] > 1:
return "Too bogus to live with"
else:
return None

def load():
return (module_spec_from_file('module_spec.spec'), check)