Commit 829ff94f authored by Jerry's avatar Jerry
Browse files

remove duplicate code lines


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac380@3285 e5f2f494-b856-4b98-b285-d166d9295462
parent 74a94b62
......@@ -489,6 +489,15 @@ class TestZonemgr(unittest.TestCase):
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
......
......@@ -391,10 +391,7 @@ class Zonemgr:
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,18 +424,22 @@ class Zonemgr:
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")
if not zone_name:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment