[svn] commit: r3302 - in /trunk: ./ src/bin/zonemgr/tests/zonemgr_test.py src/bin/zonemgr/zonemgr.py.in

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Oct 21 06:53:50 UTC 2010


Author: chenzhengzhang
Date: Thu Oct 21 06:53:50 2010
New Revision: 3302

Log:
merge #380, Remove duplicate code from _setup_session and config_handler
skip changelog entry

Modified:
    trunk/   (props changed)
    trunk/src/bin/zonemgr/tests/zonemgr_test.py
    trunk/src/bin/zonemgr/zonemgr.py.in

Modified: trunk/src/bin/zonemgr/tests/zonemgr_test.py
==============================================================================
--- trunk/src/bin/zonemgr/tests/zonemgr_test.py (original)
+++ trunk/src/bin/zonemgr/tests/zonemgr_test.py Thu Oct 21 06:53:50 2010
@@ -506,6 +506,15 @@
         params1 = {"zone_class" : "CH"}
         self.assertRaises(ZonemgrException, self.zonemgr._parse_cmd_params, params2, ZONE_NOTIFY_COMMAND)
 
+    def test_config_data_check(self):
+        # jitter should not be bigger than half of the original value
+        config_data2 = {"jitter_scope" : 0.2}
+        config_data3 = {"jitter_scope" : 0.6}
+        self.zonemgr._config_data_check(config_data2)
+        self.assertEqual(0.2, config_data2.get("jitter_scope"))
+        self.zonemgr._config_data_check(config_data3)
+        self.assertEqual(0.5, config_data3.get("jitter_scope"))
+
     def tearDown(self):
         pass
 

Modified: trunk/src/bin/zonemgr/zonemgr.py.in
==============================================================================
--- trunk/src/bin/zonemgr/zonemgr.py.in (original)
+++ trunk/src/bin/zonemgr/zonemgr.py.in Thu Oct 21 06:53:50 2010
@@ -435,10 +435,7 @@
                                                   self.command_handler)
         self._module_cc.add_remote_config(AUTH_SPECFILE_LOCATION)
         self._config_data = self._module_cc.get_full_config()
-        # jitter should not be bigger than half of the original value
-        if self._config_data.get('jitter_scope') > 0.5:
-            self._config_data['jitter_scope'] = 0.5
-            log_msg("[b10-zonemgr] jitter_scope should not be bigger than 0.5.") 
+        self._config_data_check(self._config_data)
         self._module_cc.start()
 
     def get_db_file(self):
@@ -468,17 +465,22 @@
             if key not in self._config_data:
                 answer = create_answer(1, "Unknown config data: " + str(key))
                 continue
-            # jitter should not be bigger than half of the original value
-            if key == 'jitter_scope':
-                if new_config.get(key) > 0.5:
-                    new_config[key] = 0.5
-                    log_msg("[b10-zonemgr] jitter_scope should not be bigger than 0.5.") 
             self._config_data[key] = new_config[key]
 
+        self._config_data_check(self._config_data)
         if (self._zone_refresh):
             self._zone_refresh.update_config_data(self._config_data)
 
         return answer
+
+    def _config_data_check(self, config_data):
+        """Check whether the new config data is valid or 
+        not. """ 
+        # jitter should not be bigger than half of the original value
+        if config_data.get('jitter_scope') > 0.5:
+            config_data['jitter_scope'] = 0.5
+            log_msg("[b10-zonemgr] jitter_scope is too bigger, its value will "
+                      "be set to 0.5") 
 
     def _parse_cmd_params(self, args, command):
         zone_name = args.get("zone_name")




More information about the bind10-changes mailing list