[svn] commit: r3285 - in /branches/trac380/src/bin/zonemgr: tests/zonemgr_test.py zonemgr.py.in
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 20 02:19:30 UTC 2010
Author: chenzhengzhang
Date: Wed Oct 20 02:19:29 2010
New Revision: 3285
Log:
remove duplicate code lines
Modified:
branches/trac380/src/bin/zonemgr/tests/zonemgr_test.py
branches/trac380/src/bin/zonemgr/zonemgr.py.in
Modified: branches/trac380/src/bin/zonemgr/tests/zonemgr_test.py
==============================================================================
--- branches/trac380/src/bin/zonemgr/tests/zonemgr_test.py (original)
+++ branches/trac380/src/bin/zonemgr/tests/zonemgr_test.py Wed Oct 20 02:19:29 2010
@@ -489,6 +489,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: branches/trac380/src/bin/zonemgr/zonemgr.py.in
==============================================================================
--- branches/trac380/src/bin/zonemgr/zonemgr.py.in (original)
+++ branches/trac380/src/bin/zonemgr/zonemgr.py.in Wed Oct 20 02:19:29 2010
@@ -391,10 +391,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):
@@ -427,17 +424,21 @@
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 should not be bigger than 0.5.")
def _parse_cmd_params(self, args, command):
zone_name = args.get("zone_name")
More information about the bind10-changes
mailing list