summaryrefslogtreecommitdiffstats
path: root/src/bin/cfgmgr
diff options
context:
space:
mode:
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>2011-04-09 12:41:03 +0200
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>2011-04-09 12:41:03 +0200
commit4578fa114fea13eae53713b5282f5e906a71fbf6 (patch)
tree0fd7339b76fe1a173034a884dcbc43ee1a5736c8 /src/bin/cfgmgr
parent[trac810] Plugin loader (diff)
downloadkea-4578fa114fea13eae53713b5282f5e906a71fbf6.tar.xz
kea-4578fa114fea13eae53713b5282f5e906a71fbf6.zip
[trac810] Call the plugin loader
Diffstat (limited to 'src/bin/cfgmgr')
-rwxr-xr-xsrc/bin/cfgmgr/b10-cfgmgr.py.in4
-rw-r--r--src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in12
2 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/cfgmgr/b10-cfgmgr.py.in b/src/bin/cfgmgr/b10-cfgmgr.py.in
index e3f1ca70cb..dc1852d499 100755
--- a/src/bin/cfgmgr/b10-cfgmgr.py.in
+++ b/src/bin/cfgmgr/b10-cfgmgr.py.in
@@ -41,9 +41,11 @@ if "B10_FROM_SOURCE" in os.environ:
DATA_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
else:
DATA_PATH = os.environ["B10_FROM_SOURCE"]
+ PLUGIN_PATH = [] #FIXME Where should plugins come from? And how to find it?
else:
PREFIX = "@prefix@"
DATA_PATH = "@localstatedir@/@PACKAGE@".replace("${prefix}", PREFIX)
+ PLUGIN_PATHS = ["@prefix@/share/@PACKAGE@/config_plugins"]
DEFAULT_CONFIG_FILE = "b10-config.db"
cm = None
@@ -97,6 +99,8 @@ def main():
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
cm.read_config()
+ for ppath in PLUGIN_PATHS:
+ load_plugins(ppath, cm)
cm.notify_boss()
cm.run()
except SessionError as se:
diff --git a/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in b/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in
index c4a232ce64..37cd0f50c1 100644
--- a/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in
+++ b/src/bin/cfgmgr/tests/b10-cfgmgr_test.py.in
@@ -69,13 +69,24 @@ class TestConfigManagerStartup(unittest.TestCase):
# this also gives us the chance to override the imported
# module ConfigManager in it.
b = __import__("b10-cfgmgr")
+ orig_load = b.load_plugins
+ b.PLUGIN_PATHS = ["/plugin/path"]
+ self.loaded_plugins = False
+ def load_plugins(path, cm):
+ # Check it's called with proper arguments
+ self.assertEqual(path, "/plugin/path")
+ self.assertTrue(isinstance(cm, MyConfigManager))
+ self.loaded_plugins = True
+ b.load_plugins = load_plugins
b.ConfigManager = MyConfigManager
b.main()
+ b.load_plugins = orig_load
self.assertTrue(b.cm.read_config_called)
self.assertTrue(b.cm.notify_boss_called)
self.assertTrue(b.cm.run_called)
+ self.assertTrue(self.loaded_plugins)
# if there are no changes, config is not written
self.assertFalse(b.cm.write_config_called)
@@ -100,6 +111,7 @@ class TestConfigManagerStartup(unittest.TestCase):
os.environ["B10_FROM_SOURCE"] = tmp_env_var
b = __import__("b10-cfgmgr", globals(), locals())
+ b.PLUGIN_PATH = [] # It's enough to test plugins in one test
b.ConfigManager = MyConfigManager
self.assertEqual(tmp_env_var, b.DATA_PATH)