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-10-09 10:06:03 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-10-09 10:06:03 -0400
commit4ef4e4f417d05ccdc3b3584d5e8f49f98126e912 (patch)
tree9dc208297e691ff728d21097ec2c8b1d4c3782de /src/lib/Bcfg2/Server/Plugins/Reporting.py
parent623a06c4b9a1fa7040146ff27364fc64a5a6a57e (diff)
downloadbcfg2-4ef4e4f417d05ccdc3b3584d5e8f49f98126e912.tar.gz
bcfg2-4ef4e4f417d05ccdc3b3584d5e8f49f98126e912.tar.bz2
bcfg2-4ef4e4f417d05ccdc3b3584d5e8f49f98126e912.zip
Reporting: move pickling from base transport to LocalFilesystem transport
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Reporting.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Reporting.py31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Reporting.py b/src/lib/Bcfg2/Server/Plugins/Reporting.py
index 1ea6637a8..843f8768c 100644
--- a/src/lib/Bcfg2/Server/Plugins/Reporting.py
+++ b/src/lib/Bcfg2/Server/Plugins/Reporting.py
@@ -3,10 +3,9 @@
import time
import platform
import traceback
-from lxml import etree
+import lxml.etree
from Bcfg2.Reporting.Transport import load_transport_from_config, \
TransportError
-from Bcfg2.Compat import cPickle
from Bcfg2.Options import REPORTING_COMMON_OPTIONS
from Bcfg2.Server.Plugin import Statistics, PullSource, PluginInitError, \
PluginExecutionError
@@ -36,7 +35,7 @@ class Reporting(Statistics, PullSource): # pylint: disable=W0223
""" Unified statistics and reporting plugin """
__rmi__ = ['Ping', 'GetExtra', 'GetCurrentEntry']
- CLIENT_METADATA_FILEDS = ('profile', 'bundles', 'aliases', 'addresses',
+ CLIENT_METADATA_FIELDS = ('profile', 'bundles', 'aliases', 'addresses',
'groups', 'categories', 'uuid', 'version')
def __init__(self, core, datastore):
@@ -59,16 +58,17 @@ class Reporting(Statistics, PullSource): # pylint: disable=W0223
try:
self.transport = load_transport_from_config(core.setup)
except TransportError:
- self.logger.error("%s: Failed to load transport: %s" %
- (self.name, traceback.format_exc().splitlines()[-1]))
- raise PluginInitError
+ msg = "%s: Failed to load transport: %s" % \
+ (self.name, traceback.format_exc().splitlines()[-1])
+ self.logger.error(msg)
+ raise PluginInitError(msg)
def process_statistics(self, client, xdata):
stats = xdata.find("Statistics")
stats.set('time', time.asctime(time.localtime()))
cdata = {'server': self.whoami}
- for field in self.CLIENT_METADATA_FILEDS:
+ for field in self.CLIENT_METADATA_FIELDS:
try:
value = getattr(client, field)
except AttributeError:
@@ -78,22 +78,13 @@ class Reporting(Statistics, PullSource): # pylint: disable=W0223
value = [v for v in value]
cdata[field] = value
- try:
- interaction_data = cPickle.dumps(dict(
- hostname=client.hostname,
- metadata=cdata,
- stats=etree.tostring(
- stats,
- xml_declaration=False).decode('UTF-8')))
- except: # pylint: disable=W0702
- self.logger.error("%s: Failed to build interaction object: %s" %
- (self.__class__.__name__,
- traceback.format_exc().splitlines()[-1]))
-
# try 3 times to store the data
for i in [1, 2, 3]:
try:
- self.transport.store(client.hostname, interaction_data)
+ self.transport.store(client.hostname, cdata,
+ lxml.etree.tostring(
+ stats,
+ xml_declaration=False).decode('UTF-8'))
self.logger.debug("%s: Queued statistics data for %s" %
(self.__class__.__name__, client.hostname))
return