README 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. How to write a configuration plugin
  2. ===================================
  3. The plugins are used to describe configuration modules that have no hosting
  4. process. Therefore there's no process to provide their specification and to
  5. check them for correctness. So the plugin takes this responsibility.
  6. Each plugin is a python file installed into the
  7. `@prefix@/share/@PACKAGE@/config_plugins` directory (usually
  8. `/usr/share/bind10/config_plugins`). It is loaded automatically at startup.
  9. The entrypoint of a plugin is function called `load()`. It should return a
  10. tuple, first value should be the module specification (usually instance of
  11. `isc.config.module_spec.ModuleSpec`, loaded by `module_spec_from_file()`).
  12. The second value is a callable object. It will be called whenever the
  13. configuration of module needs to be checked. The only parameter will be the new
  14. config (as python dictionary). To accept the new configuration, return None. If
  15. you return a string, it is taken as an error message. If you raise an
  16. exception, the config is rejected as well, however it is not considered a
  17. graceful rejection, but a failure of the module.
  18. So, this is how a plugin could look like:
  19. from isc.config.module_spec import module_spec_from_file
  20. def check(config):
  21. if config['bogosity'] > 1:
  22. return "Too bogus to live with"
  23. else:
  24. return None
  25. def load():
  26. return (module_spec_from_file('module_spec.spec'), check)