diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Server/Core.py | 14 | ||||
-rw-r--r-- | src/lib/Server/Plugin.py | 3 | ||||
-rw-r--r-- | src/lib/Server/Plugins/Statistics.py (renamed from src/lib/Server/Statistics.py) | 18 |
3 files changed, 31 insertions, 4 deletions
diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index 2bbbbc4f4..d7086aa96 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -3,7 +3,6 @@ __revision__ = '$Revision$' from time import time from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError -from Bcfg2.Server.Statistics import Statistics import logging, lxml.etree, os, stat import Bcfg2.Server.Plugins.Metadata @@ -222,8 +221,6 @@ class Core(object): except: self.svn = False - self.stats = Statistics("%s/etc/statistics.xml" % (self.datastore)) - [data.remove('') for data in [structures, generators] if '' in data] @@ -242,6 +239,17 @@ class Core(object): self.metadata = self.plugins["Metadata"] break + plugins = self.plugins.values() + while True: + plugin = plugins.pop() + if isinstance(plugin, Bcfg2.Server.Plugin.StatisticsPlugin): + self.stats = plugin + break + if not plugins: + self.init_plugins("Statistics") + self.stats = self.plugins["Statistics"] + break + for plug_names, plug_tname, plug_type, collection in \ [(structures, 'structure', Bcfg2.Server.Plugin.StructurePlugin, self.structures), diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index 63af1d886..0f9464a47 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -96,6 +96,9 @@ class StatisticsPlugin(Plugin): def StoreStatistics(self, client, xdata): pass + def WriteBack(self): + pass + # the rest of the file contains classes for coherent file caching class FileBacked(object): diff --git a/src/lib/Server/Statistics.py b/src/lib/Server/Plugins/Statistics.py index 7111113aa..bc6e648bf 100644 --- a/src/lib/Server/Statistics.py +++ b/src/lib/Server/Plugins/Statistics.py @@ -6,7 +6,9 @@ from time import asctime, localtime, time, strptime, mktime import logging, lxml.etree, os -class Statistics(object): +import Bcfg2.Server.Plugin + +class StatisticsStore(object): '''Manages the memory and file copy of statistics collected about client runs''' __min_write_delay__ = 0 @@ -102,3 +104,17 @@ class Statistics(object): return (now-utime) > secondsPerDay +class Statistics(Bcfg2.Server.Plugin.StatisticsPlugin): + __name__ = 'Statistics' + __version__ = '$Id$' + + def __init__(self, _, datastore): + fpath = "%s/etc/statistics.xml" % datastore + self.data = StatisticsStore(fpath) + + def StoreStatistics(self, client, xdata): + self.data.updateStats(xdata, client.hostname) + + def WriteBack(self): + self.data.WriteBack() + |