BIND 10 trac2113, updated. b4dc5098233236ad352d9d01694b917e620ed9c0 [2113] Avoid a warning

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Aug 1 10:36:44 UTC 2012


The branch, trac2113 has been updated
       via  b4dc5098233236ad352d9d01694b917e620ed9c0 (commit)
      from  940753065730e77c7fad72d005f62713f2cfb82c (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 b4dc5098233236ad352d9d01694b917e620ed9c0
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Aug 1 12:35:13 2012 +0200

    [2113] Avoid a warning
    
    The warning would be provoked by checking a MasterFiles type data
    source. The client list skips it, because cache is disabled, and it
    complains it won't be able to serve. That is not a problem while
    checking configuration, so the zones are stolen from it.

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

Summary of changes:
 src/bin/cfgmgr/plugins/datasrc_config_plugin.py |   20 +++++++++++++++-----
 src/bin/cfgmgr/plugins/tests/datasrc_test.py    |   11 ++++++++++-
 2 files changed, 25 insertions(+), 6 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
index fe87725..12710d5 100644
--- a/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
+++ b/src/bin/cfgmgr/plugins/datasrc_config_plugin.py
@@ -20,6 +20,7 @@ import isc.dns
 import isc.datasrc
 import json
 import os.path
+import copy
 
 spec = module_spec_from_file(path_search('datasrc.spec', PLUGIN_PATHS))
 
@@ -44,11 +45,10 @@ def check(config):
             return "The class '" + rr_class_str + "' is invalid"
 
         dlist = isc.datasrc.ConfigurableClientList(rr_class)
-        client_config = classes.get(rr_class_str)
-        try:
-            dlist.configure(json.dumps(client_config), False)
-        except isc.datasrc.Error as dse:
-            return str(dse)
+        # We get a copy here, as we are going to mangle the configuration.
+        # But we don't want our changes to propagate outside, to the real
+        # configuration.
+        client_config = copy.deepcopy(classes.get(rr_class_str))
 
         for client in client_config:
             if client['type'] == 'MasterFiles':
@@ -64,6 +64,16 @@ def check(config):
                         return str(e)
                     if not os.path.exists(params[name]):
                         return "Master file " + params[name] + " does not exist"
+                # We remove the list of zones locally. We already checked them,
+                # and the client list would have skipped them anyway, as we
+                # forbid cache. But it would produce a warning and we don't
+                # want that here.
+                client['params'] = {}
+
+        try:
+            dlist.configure(json.dumps(client_config), False)
+        except isc.datasrc.Error as dse:
+            return str(dse)
     return None
 
 def load():
diff --git a/src/bin/cfgmgr/plugins/tests/datasrc_test.py b/src/bin/cfgmgr/plugins/tests/datasrc_test.py
index 26d5fe7..f4381b4 100644
--- a/src/bin/cfgmgr/plugins/tests/datasrc_test.py
+++ b/src/bin/cfgmgr/plugins/tests/datasrc_test.py
@@ -16,26 +16,35 @@
 # Make sure we can load the module, put it into path
 import sys
 import os
+import unittest
+import json
 sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
 import isc.log
 
 import datasrc_config_plugin
-import unittest
 
 class DatasrcTest(unittest.TestCase):
     def reject(self, config):
         """
         Just a shortcut to check the config is rejected.
         """
+        old = json.dumps(config)
         self.assertIsNotNone(datasrc_config_plugin.check({"classes":
                                                          config}))
+        # There's some data mangling inside the plugin. Check it does
+        # not propagate out, as it could change the real configuration.
+        self.assertEqual(old, json.dumps(config))
 
     def accept(self, config):
         """
         Just a shortcut to check the config is accepted.
         """
+        old = json.dumps(config)
         self.assertIsNone(datasrc_config_plugin.check({"classes":
                                                       config}))
+        # There's some data mangling inside the plugin. Check it does
+        # not propagate out, as it could change the real configuration.
+        self.assertEqual(old, json.dumps(config))
 
     def test_load(self):
         """



More information about the bind10-changes mailing list