From 1d953e4512c8d4cc9ce536da3522a59d812d58b9 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 16 Nov 2012 09:28:37 -0500 Subject: added set_debug RMI for plugins and core, set_fam_debug RMI --- src/lib/Bcfg2/Server/Core.py | 10 ++++++++++ src/lib/Bcfg2/Server/FileMonitor/__init__.py | 2 +- src/lib/Bcfg2/Server/Plugin/base.py | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src/lib') diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py index 7d980e58a..c23d3cf24 100644 --- a/src/lib/Bcfg2/Server/Core.py +++ b/src/lib/Bcfg2/Server/Core.py @@ -1079,3 +1079,13 @@ class BaseCore(object): @exposed def toggle_fam_debug(self, _): return self.fam.toggle_debug() + + @exposed + def set_debug(self, address, debug): + for plugin in self.plugins.values(): + plugin.set_debug(debug) + return self.set_fam_debug(address, debug) + + @exposed + def set_fam_debug(self, _, debug): + return self.fam.set_debug(debug) diff --git a/src/lib/Bcfg2/Server/FileMonitor/__init__.py b/src/lib/Bcfg2/Server/FileMonitor/__init__.py index dad0db44e..42ad4c041 100644 --- a/src/lib/Bcfg2/Server/FileMonitor/__init__.py +++ b/src/lib/Bcfg2/Server/FileMonitor/__init__.py @@ -129,7 +129,7 @@ class FileMonitor(Debuggable): .. ----- .. autoattribute:: __priority__ """ - Debuggable.__init__(self, name="FileMonitor") + Debuggable.__init__(self) self.debug_flag = debug #: A dict that records which objects handle which events. diff --git a/src/lib/Bcfg2/Server/Plugin/base.py b/src/lib/Bcfg2/Server/Plugin/base.py index 8d288f835..e74909ee9 100644 --- a/src/lib/Bcfg2/Server/Plugin/base.py +++ b/src/lib/Bcfg2/Server/Plugin/base.py @@ -9,7 +9,7 @@ class Debuggable(object): via XML-RPC on :class:`Bcfg2.Server.Plugin.base.Plugin` objects """ #: List of names of methods to be exposed as XML-RPC functions - __rmi__ = ['toggle_debug'] + __rmi__ = ['toggle_debug', 'set_debug'] def __init__(self, name=None): """ @@ -26,17 +26,25 @@ class Debuggable(object): self.debug_flag = False self.logger = logging.getLogger(name) - def toggle_debug(self): - """ Turn debugging output on or off. This method is exposed + def set_debug(self, debug): + """ Explicitly enable or disable debugging. This method is exposed via XML-RPC. :returns: bool - The new value of the debug flag """ - self.debug_flag = not self.debug_flag + self.debug_flag = debug self.debug_log("%s: debug_flag = %s" % (self.__class__.__name__, self.debug_flag), flag=True) - return self.debug_flag + return debug + + def toggle_debug(self): + """ Turn debugging output on or off. This method is exposed + via XML-RPC. + + :returns: bool - The new value of the debug flag + """ + return self.set_debug(not self.debug_flag) def debug_log(self, message, flag=None): """ Log a message at the debug level. -- cgit v1.2.3-1-g7c22