summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/DBStats.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-01-05 03:24:50 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-01-05 03:24:50 +0000
commita9388f7859586d5d98e815efdcf8d6a85b973bef (patch)
tree8adaf09fbd9cc5d4e3cd0dbf69ebcaade4577f76 /src/lib/Server/Plugins/DBStats.py
parentd3f79b55f57787a75773459dbc70a5504c7ddcf3 (diff)
downloadbcfg2-a9388f7859586d5d98e815efdcf8d6a85b973bef.tar.gz
bcfg2-a9388f7859586d5d98e815efdcf8d6a85b973bef.tar.bz2
bcfg2-a9388f7859586d5d98e815efdcf8d6a85b973bef.zip
This patch is stage 1 of the plugin capabilities rework
- define new plugin base classes - switch Plugin.__name__ => Plugin.name git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5004 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/DBStats.py')
-rw-r--r--src/lib/Server/Plugins/DBStats.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/Server/Plugins/DBStats.py b/src/lib/Server/Plugins/DBStats.py
index eb5e89282..24a030b64 100644
--- a/src/lib/Server/Plugins/DBStats.py
+++ b/src/lib/Server/Plugins/DBStats.py
@@ -1,19 +1,23 @@
import Bcfg2.Server.Plugin
import Bcfg2.Server.Reports.importscript
-from Bcfg2.Server.Reports.reports.models import Client, Entries
-import difflib, lxml.etree, time, logging, datetime
+from Bcfg2.Server.Reports.reports.models import Client
+import difflib, lxml.etree, time, logging
import Bcfg2.Server.Reports.settings
from Bcfg2.Server.Reports.updatefix import update_database
-import traceback
# for debugging output only
logger = logging.getLogger('Bcfg2.Plugins.DBStats')
-class DBStats(Bcfg2.Server.Plugin.StatisticsPlugin):
- __name__ = 'DBStats'
+class DBStats(Bcfg2.Server.Plugin.Plugin,
+ Bcfg2.Server.Plugin.Statistics,
+ Bcfg2.Server.Plugin.PullSource):
+ name = 'DBStats'
__version__ = '$Id$'
def __init__(self, core, datastore):
+ Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
+ Bcfg2.Server.Plugin.Statistics.__init__(self)
+ Bcfg2.Server.Plugin.PullSource.__init__(self)
self.cpath = "%s/Metadata/clients.xml" % datastore
self.core = core
logger.debug("Searching for new models to add to the statistics database")
@@ -34,17 +38,19 @@ class DBStats(Bcfg2.Server.Plugin.StatisticsPlugin):
# FIXME need to build a metadata interface to expose a list of clients
# FIXME Server processing the request should be mentionned here
start = time.time()
- for i in [1,2,3]:
+ for i in [1, 2, 3]:
try:
Bcfg2.Server.Reports.importscript.load_stats(
self.core.metadata.clientdata, container, 0, True)
break
except:
- logger.error("DBStats: Failed to write data to database due to lock; retrying", exc_info=1)
+ logger.error("DBStats: Failed to write to db (lock); retrying",
+ exc_info=1)
if i == 3:
logger.error("DBStats: Retry limit failed; aborting operation")
return
- logger.info("Imported data in the reason fast path in %s second" % (time.time() - start))
+ logger.info("Imported data in the reason fast path in %s second" \
+ % (time.time() - start))
def GetExtra(self, client):
c_inst = Client.objects.filter(name=client)[0]