diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-08-07 20:16:29 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-08-07 20:16:29 +0000 |
commit | e3e0d8d72e21f58c23ddf51d5af9d9200ee5037a (patch) | |
tree | 41808e40ef91e21ae2f61bc8e5748a43e2bd7088 /src/lib/Server/Plugins/Statistics.py | |
parent | c548d3ff9ef0bc01c00a3e5068413aca4cce8a46 (diff) | |
download | bcfg2-e3e0d8d72e21f58c23ddf51d5af9d9200ee5037a.tar.gz bcfg2-e3e0d8d72e21f58c23ddf51d5af9d9200ee5037a.tar.bz2 bcfg2-e3e0d8d72e21f58c23ddf51d5af9d9200ee5037a.zip |
Implement GetCurrentEntry api for Statistics and DBStats (prereq for portable bcfg2-admin pull)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4869 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugins/Statistics.py')
-rw-r--r-- | src/lib/Server/Plugins/Statistics.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/Server/Plugins/Statistics.py b/src/lib/Server/Plugins/Statistics.py index b7dc61179..b47ee4410 100644 --- a/src/lib/Server/Plugins/Statistics.py +++ b/src/lib/Server/Plugins/Statistics.py @@ -4,7 +4,7 @@ __revision__ = '$Revision$' from lxml.etree import XML, SubElement, Element, XMLSyntaxError from time import asctime, localtime, time, strptime, mktime -import logging, lxml.etree, os +import binascii, logging, lxml.etree, os import Bcfg2.Server.Plugin @@ -125,3 +125,21 @@ class Statistics(Bcfg2.Server.Plugin.StatisticsPlugin): def GetExtra(self, client): return [(entry.tag, entry.get('name')) for entry in self.FindCurrent(client).xpath('.//Extra/*')] + + def GetCurrentEntry(self, client, e_type, e_name): + curr = self.FindCurrent(client) + entry = curr.xpath('.//Bad/%s[@name="%s"]' % (e_type, e_name)) + cfentry = entry[-1] + + owner = cfentry.get('current_owner', cfentry.get('owner')) + group = cfentry.get('current_group', cfentry.get('group')) + perms = cfentry.get('current_perms', cfentry.get('perms')) + if 'current_bfile' in cfentry.attrib: + contents = binascii.a2b_base64(cfentry.get('current_bfile')) + elif 'current_bdiff' in cfentry.attrib: + diff = binascii.a2b_base64(cfentry.get('current_bdiff')) + contents = '\n'.join(difflib.restore(diff.split('\n'), 1)) + else: + contents = None + + return (owner, group, perms, contents) |