From cecf9f6c60a048f4f7c947a969f1610695d1d3be Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 10 Oct 2014 15:52:01 -0400 Subject: Do not overwrite default plugin options Change the admin plugin to not overwrite the plugin default options, and only use the sanctioned pluginObject interfaces to read/write config values. Signed-off-by: Simo Sorce Reviewed-by: Patrick Uiterwijk --- ipsilon/util/plugin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'ipsilon/util') diff --git a/ipsilon/util/plugin.py b/ipsilon/util/plugin.py index 903f548..48edf0e 100755 --- a/ipsilon/util/plugin.py +++ b/ipsilon/util/plugin.py @@ -115,7 +115,7 @@ class PluginObject(Log): self._options = None self._data = AdminStore() - def get_config_desc(self): + def get_config_desc(self, name=None): """ The configuration description is a dictionary that provides A description of the supported configuration options, as well as the default configuration option values. @@ -124,7 +124,13 @@ class PluginObject(Log): - option type - default value """ - return self._options + if name is None: + return self._options + + opt = self._options.get(name, None) + if opt is None: + return '' + return opt[0] def set_config(self, config): self._config = config @@ -152,6 +158,10 @@ class PluginObject(Log): def get_plugin_config(self, facility): return self._data.load_options(facility, self.name) + def refresh_plugin_config(self, facility): + config = self.get_plugin_config(facility) + self.set_config(config) + def save_plugin_config(self, facility, config=None): if config is None: config = self._config -- cgit