From 92122665e534978a1bdb499e6b8cf48e54b041d3 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 27 Nov 2012 12:09:18 -0500 Subject: made Reporting plugin and transports debuggable, respond to set_debug/toggle_debug RMI --- src/lib/Bcfg2/Server/Plugins/Reporting.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/lib/Bcfg2/Server/Plugins/Reporting.py') diff --git a/src/lib/Bcfg2/Server/Plugins/Reporting.py b/src/lib/Bcfg2/Server/Plugins/Reporting.py index b9d397590..60f5b1e09 100644 --- a/src/lib/Bcfg2/Server/Plugins/Reporting.py +++ b/src/lib/Bcfg2/Server/Plugins/Reporting.py @@ -8,7 +8,7 @@ from Bcfg2.Reporting.Transport import load_transport_from_config, \ TransportError from Bcfg2.Options import REPORTING_COMMON_OPTIONS from Bcfg2.Server.Plugin import Statistics, PullSource, Threaded, \ - PluginInitError, PluginExecutionError + Debuggable, PluginInitError, PluginExecutionError # required for reporting try: @@ -31,9 +31,10 @@ def _rpc_call(method): return _real_rpc_call -class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 +# pylint: disable=W0223 +class Reporting(Statistics, Threaded, PullSource, Debuggable): """ Unified statistics and reporting plugin """ - __rmi__ = ['Ping', 'GetExtra', 'GetCurrentEntry'] + __rmi__ = Debuggable.__rmi__ + ['Ping', 'GetExtra', 'GetCurrentEntry'] CLIENT_METADATA_FIELDS = ('profile', 'bundles', 'aliases', 'addresses', 'groups', 'categories', 'uuid', 'version') @@ -42,7 +43,7 @@ class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 Statistics.__init__(self, core, datastore) PullSource.__init__(self) Threaded.__init__(self) - self.core = core + Debuggable.__init__(self) self.whoami = platform.node() self.transport = None @@ -55,8 +56,6 @@ class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 self.logger.error(msg) raise PluginInitError(msg) - self.transport = None - def start_threads(self): try: self.transport = load_transport_from_config(self.core.setup) @@ -66,6 +65,11 @@ class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 self.logger.error(msg) raise PluginInitError(msg) + def set_debug(self, debug): + rv = Debuggable.set_debug(self, debug) + self.transport.set_debug(debug) + return rv + def process_statistics(self, client, xdata): stats = xdata.find("Statistics") stats.set('time', time.asctime(time.localtime())) @@ -88,8 +92,8 @@ class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 lxml.etree.tostring( stats, xml_declaration=False).decode('UTF-8')) - self.logger.debug("%s: Queued statistics data for %s" % - (self.__class__.__name__, client.hostname)) + self.debug_log("%s: Queued statistics data for %s" % + (self.__class__.__name__, client.hostname)) return except TransportError: continue @@ -98,7 +102,7 @@ class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223 % (self.__class__.__name__, i, traceback.format_exc().splitlines()[-1])) self.logger.error("%s: Retry limit reached for %s" % - (self.__class__.__name__, client.hostname)) + (self.__class__.__name__, client.hostname)) def shutdown(self): super(Reporting, self).shutdown() -- cgit v1.2.3-1-g7c22