BIND 10 trac810, updated. 95689208a5f10f7f839abc57d7db9d73e0eca200 [trac810] README about plugins

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Apr 18 08:50:27 UTC 2011


The branch, trac810 has been updated
       via  95689208a5f10f7f839abc57d7db9d73e0eca200 (commit)
       via  9303e9a05b5a48f80ea32531ae493724b04aa2be (commit)
       via  8ac28e2101ab399e885c178294635cacfe6573e1 (commit)
      from  def088d4e8387e8d04fc0fc0e56a9db39e3ccefa (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 95689208a5f10f7f839abc57d7db9d73e0eca200
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Apr 18 10:35:43 2011 +0200

    [trac810] README about plugins

commit 9303e9a05b5a48f80ea32531ae493724b04aa2be
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Apr 18 10:14:18 2011 +0200

    [trac810] Find the plugins from build

commit 8ac28e2101ab399e885c178294635cacfe6573e1
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Apr 18 10:10:50 2011 +0200

    [trac810] Fix Makefile

-----------------------------------------------------------------------

Summary of changes:
 src/bin/cfgmgr/b10-cfgmgr.py.in  |    2 +-
 src/bin/cfgmgr/plugins/README    |   34 ++++++++++++++++++++++++++++++++++
 src/bin/cfgmgr/tests/Makefile.am |    2 +-
 3 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 src/bin/cfgmgr/plugins/README

-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in
index dc1852d..607a6dc 100755
--- a/src/bin/cfgmgr/b10-cfgmgr.py.in
+++ b/src/bin/cfgmgr/b10-cfgmgr.py.in
@@ -41,7 +41,7 @@ if "B10_FROM_SOURCE" in os.environ:
         DATA_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
     else:
         DATA_PATH = os.environ["B10_FROM_SOURCE"]
-    PLUGIN_PATH = [] #FIXME Where should plugins come from? And how to find it?
+    PLUGIN_PATH = [DATA_PATH + '/src/bin/cfgmgr/plugins']
 else:
     PREFIX = "@prefix@"
     DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
diff --git a/src/bin/cfgmgr/plugins/README b/src/bin/cfgmgr/plugins/README
new file mode 100644
index 0000000..27fb0c0
--- /dev/null
+++ b/src/bin/cfgmgr/plugins/README
@@ -0,0 +1,34 @@
+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)
diff --git a/src/bin/cfgmgr/tests/Makefile.am b/src/bin/cfgmgr/tests/Makefile.am
index d88576b..68666e6 100644
--- a/src/bin/cfgmgr/tests/Makefile.am
+++ b/src/bin/cfgmgr/tests/Makefile.am
@@ -1,7 +1,7 @@
 PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
 PYTESTS = b10-cfgmgr_test.py
 
-EXTRA_DIST = $(PYTESTS)
+EXTRA_DIST = $(PYTESTS) testdata/plugins/testplugin.py
 
 # test using command-line arguments, so use check-local target instead of TESTS
 check-local:




More information about the bind10-changes mailing list