Commit cf5b24f1 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner

[trac670] The config handler

parent 5a7c1928
......@@ -530,7 +530,8 @@ class TestZonemgr(unittest.TestCase):
"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)
......
......@@ -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)
self._config_data_check(complete)
if self._zone_refresh is not None:
self._zone_refresh.update_config_data(self._config_data)
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
......
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