Commit b4dc5098 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2113] Avoid a warning

The warning would be provoked by checking a MasterFiles type data
source. The client list skips it, because cache is disabled, and it
complains it won't be able to serve. That is not a problem while
checking configuration, so the zones are stolen from it.
parent 94075306
......@@ -20,6 +20,7 @@ import isc.dns
import isc.datasrc
import json
import os.path
import copy
spec = module_spec_from_file(path_search('datasrc.spec', PLUGIN_PATHS))
......@@ -44,11 +45,10 @@ def check(config):
return "The class '" + rr_class_str + "' is invalid"
dlist = isc.datasrc.ConfigurableClientList(rr_class)
client_config = classes.get(rr_class_str)
try:
dlist.configure(json.dumps(client_config), False)
except isc.datasrc.Error as dse:
return str(dse)
# We get a copy here, as we are going to mangle the configuration.
# But we don't want our changes to propagate outside, to the real
# configuration.
client_config = copy.deepcopy(classes.get(rr_class_str))
for client in client_config:
if client['type'] == 'MasterFiles':
......@@ -64,6 +64,16 @@ def check(config):
return str(e)
if not os.path.exists(params[name]):
return "Master file " + params[name] + " does not exist"
# We remove the list of zones locally. We already checked them,
# and the client list would have skipped them anyway, as we
# forbid cache. But it would produce a warning and we don't
# want that here.
client['params'] = {}
try:
dlist.configure(json.dumps(client_config), False)
except isc.datasrc.Error as dse:
return str(dse)
return None
def load():
......
......@@ -16,26 +16,35 @@
# Make sure we can load the module, put it into path
import sys
import os
import unittest
import json
sys.path.extend(os.environ["B10_TEST_PLUGIN_DIR"].split(':'))
import isc.log
import datasrc_config_plugin
import unittest
class DatasrcTest(unittest.TestCase):
def reject(self, config):
"""
Just a shortcut to check the config is rejected.
"""
old = json.dumps(config)
self.assertIsNotNone(datasrc_config_plugin.check({"classes":
config}))
# There's some data mangling inside the plugin. Check it does
# not propagate out, as it could change the real configuration.
self.assertEqual(old, json.dumps(config))
def accept(self, config):
"""
Just a shortcut to check the config is accepted.
"""
old = json.dumps(config)
self.assertIsNone(datasrc_config_plugin.check({"classes":
config}))
# There's some data mangling inside the plugin. Check it does
# not propagate out, as it could change the real configuration.
self.assertEqual(old, json.dumps(config))
def test_load(self):
"""
......
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