BIND 10 trac670, updated. af0d35e501aab417b9b032069ae1cb8841debab4 [trac670] Fix the spec file

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Mar 18 09:50:11 UTC 2011


The branch, trac670 has been updated
       via  af0d35e501aab417b9b032069ae1cb8841debab4 (commit)
       via  cf5b24f110a927685226e8ef41378a847b002357 (commit)
       via  5a7c1928eb5b70c2a9739650961bd4e32b6b26ed (commit)
      from  f9a697ab99914d58e7e135ca069b3d5a06c00511 (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 af0d35e501aab417b9b032069ae1cb8841debab4
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 18 10:49:02 2011 +0100

    [trac670] Fix the spec file

commit cf5b24f110a927685226e8ef41378a847b002357
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 18 10:30:29 2011 +0100

    [trac670] The config handler

commit 5a7c1928eb5b70c2a9739650961bd4e32b6b26ed
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Mar 18 10:16:31 2011 +0100

    [trac670] Test config handler

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

Summary of changes:
 src/bin/zonemgr/tests/zonemgr_test.py |   28 ++++++++++++++++++++--------
 src/bin/zonemgr/zonemgr.py.in         |   23 ++++++++++++++++-------
 src/bin/zonemgr/zonemgr.spec.pre.in   |    2 +-
 3 files changed, 37 insertions(+), 16 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/zonemgr/tests/zonemgr_test.py b/src/bin/zonemgr/tests/zonemgr_test.py
index 3ad0ce6..54aafaa 100644
--- a/src/bin/zonemgr/tests/zonemgr_test.py
+++ b/src/bin/zonemgr/tests/zonemgr_test.py
@@ -507,10 +507,11 @@ class MyZonemgr(Zonemgr):
         self._cc = MySession()
         self._module_cc = MyCCSession()
         self._config_data = {
-                    "lowerbound_refresh" : 10, 
-                    "lowerbound_retry" : 5, 
+                    "lowerbound_refresh" : 10,
+                    "lowerbound_retry" : 5,
                     "max_transfer_timeout" : 14400,
-                    "jitter_scope" : 0.1
+                    "jitter_scope" : 0.1,
+                    "secondary_zones": []
                     }
 
     def _start_zone_refresh_timer(self):
@@ -523,12 +524,14 @@ class TestZonemgr(unittest.TestCase):
 
     def test_config_handler(self):
         config_data1 = {
-                    "lowerbound_refresh" : 60, 
-                    "lowerbound_retry" : 30, 
+                    "lowerbound_refresh" : 60,
+                    "lowerbound_retry" : 30,
                     "max_transfer_timeout" : 14400,
-                    "jitter_scope" : 0.1
+                    "jitter_scope" : 0.1,
+                    "secondary_zones": []
                     }
-        self.zonemgr.config_handler(config_data1)
+        self.assertEqual(self.zonemgr.config_handler(config_data1),
+                         {"result": [0]})
         self.assertEqual(config_data1, self.zonemgr._config_data)
         config_data2 = {"zone_name" : "sd.cn.", "port" : "53", "master" : "192.168.1.1"}
         self.zonemgr.config_handler(config_data2)
@@ -537,10 +540,19 @@ class TestZonemgr(unittest.TestCase):
         config_data3 = {"jitter_scope" : 0.7}
         self.zonemgr.config_handler(config_data3)
         self.assertEqual(0.5, self.zonemgr._config_data.get("jitter_scope"))
+        # The zone doesn't exist in database, it should be rejected
+        self.zonemgr._zone_refresh = ZonemgrRefresh(None, "initdb.file", None,
+                                                    config_data1)
+        config_data1["secondary_zones"] = [{"name": "nonexistent.example",
+                                            "class": "IN"}]
+        self.assertNotEqual(self.zonemgr.config_handler(config_data1),
+                            {"result": [0]})
+        # As it is rejected, the old value should be kept
+        self.assertEqual(0.5, self.zonemgr._config_data.get("jitter_scope"))
 
     def test_get_db_file(self):
         self.assertEqual("initdb.file", self.zonemgr.get_db_file())
-    
+
     def test_parse_cmd_params(self):
         params1 = {"zone_name" : "org.cn", "zone_class" : "CH", "master" : "127.0.0.1"}
         answer1 = (("org.cn", "CH"), "127.0.0.1")
diff --git a/src/bin/zonemgr/zonemgr.py.in b/src/bin/zonemgr/zonemgr.py.in
index 68fc594..dccf1c6 100755
--- a/src/bin/zonemgr/zonemgr.py.in
+++ b/src/bin/zonemgr/zonemgr.py.in
@@ -102,8 +102,8 @@ class ZonemgrRefresh:
         self._cc = cc
         self._check_sock = slave_socket
         self._db_file = db_file
-        self.update_config_data(config_data)
         self._zonemgr_refresh_info = {}
+        self.update_config_data(config_data)
         self._build_zonemgr_refresh_info()
         self._running = False
 
@@ -490,15 +490,24 @@ class Zonemgr:
     def config_handler(self, new_config):
         """ Update config data. """
         answer = create_answer(0)
+        ok = True
+        complete = copy.copy(self._config_data)
         for key in new_config:
-            if key not in self._config_data:
+            if key not in complete:
                 answer = create_answer(1, "Unknown config data: " + str(key))
+                ok = False
                 continue
-            self._config_data[key] = new_config[key]
+            complete[key] = new_config[key]
 
-        self._config_data_check(self._config_data)
-        if (self._zone_refresh):
-            self._zone_refresh.update_config_data(self._config_data)
+        self._config_data_check(complete)
+        if self._zone_refresh is not None:
+            try:
+                self._zone_refresh.update_config_data(complete)
+            except Exception as e:
+                answer = create_answer(1, str(e))
+                ok = False
+        if ok:
+            self._config_data = complete
 
         return answer
 
@@ -510,7 +519,7 @@ class Zonemgr:
         if config_data.get('jitter_scope') > 0.5:
             config_data['jitter_scope'] = 0.5
             log_msg("[b10-zonemgr] jitter_scope is too big, its value will "
-                      "be set to 0.5") 
+                      "be set to 0.5")
 
 
     def _parse_cmd_params(self, args, command):
diff --git a/src/bin/zonemgr/zonemgr.spec.pre.in b/src/bin/zonemgr/zonemgr.spec.pre.in
index f2f48c2..9df01f2 100644
--- a/src/bin/zonemgr/zonemgr.spec.pre.in
+++ b/src/bin/zonemgr/zonemgr.spec.pre.in
@@ -47,7 +47,7 @@
                "item_name": "name",
                "item_type": "string",
                "item_optional": false,
-               "item_type": ""
+               "item_default": ""
              }
            ]
          }




More information about the bind10-changes mailing list