summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Reporting.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 11:49:47 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-27 12:12:34 -0500
commitc19e7da20ca6b67956338f9808a80673e06b1e94 (patch)
tree5d62c7c7aaf71e062f8bf22cbce987b8555ad78b /src/lib/Bcfg2/Server/Plugins/Reporting.py
parentfbecb8553136649eaf563d4f7ec21553500e5f16 (diff)
downloadbcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.tar.gz
bcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.tar.bz2
bcfg2-c19e7da20ca6b67956338f9808a80673e06b1e94.zip
Threaded plugin fixes:
* Added "Threaded" plugin interface for any plugin that uses threads * Start plugin threads after daemonization * Update existing plugins that use threads (Reporting, Snapshots, ThreadedStatistics interface) * Update unit tests
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Reporting.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Reporting.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Reporting.py b/src/lib/Bcfg2/Server/Plugins/Reporting.py
index 1a8c3d941..b9d397590 100644
--- a/src/lib/Bcfg2/Server/Plugins/Reporting.py
+++ b/src/lib/Bcfg2/Server/Plugins/Reporting.py
@@ -7,8 +7,8 @@ import lxml.etree
from Bcfg2.Reporting.Transport import load_transport_from_config, \
TransportError
from Bcfg2.Options import REPORTING_COMMON_OPTIONS
-from Bcfg2.Server.Plugin import Statistics, PullSource, PluginInitError, \
- PluginExecutionError
+from Bcfg2.Server.Plugin import Statistics, PullSource, Threaded, \
+ PluginInitError, PluginExecutionError
# required for reporting
try:
@@ -31,7 +31,7 @@ def _rpc_call(method):
return _real_rpc_call
-class Reporting(Statistics, PullSource): # pylint: disable=W0223
+class Reporting(Statistics, Threaded, PullSource): # pylint: disable=W0223
""" Unified statistics and reporting plugin """
__rmi__ = ['Ping', 'GetExtra', 'GetCurrentEntry']
@@ -41,6 +41,7 @@ class Reporting(Statistics, PullSource): # pylint: disable=W0223
def __init__(self, core, datastore):
Statistics.__init__(self, core, datastore)
PullSource.__init__(self)
+ Threaded.__init__(self)
self.core = core
self.whoami = platform.node()
@@ -54,8 +55,11 @@ class Reporting(Statistics, 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(core.setup)
+ self.transport = load_transport_from_config(self.core.setup)
except TransportError:
msg = "%s: Failed to load transport: %s" % \
(self.name, traceback.format_exc().splitlines()[-1])