summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-07-31 14:50:10 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-07-31 14:50:10 +0000
commitae3dc099f25c067ea414e675e24b97848f3bd81a (patch)
tree920e6fe6536bf8ce13c40ac169edff131189d917 /src/sbin
parent188f7957bf837cbf566f36d168274b8f3b66932d (diff)
downloadbcfg2-ae3dc099f25c067ea414e675e24b97848f3bd81a.tar.gz
bcfg2-ae3dc099f25c067ea414e675e24b97848f3bd81a.tar.bz2
bcfg2-ae3dc099f25c067ea414e675e24b97848f3bd81a.zip
Improve statistics location routines for bcfg2-admin pull
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3586 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-admin19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin
index e4a2ccfb3..5264bacf4 100755
--- a/src/sbin/bcfg2-admin
+++ b/src/sbin/bcfg2-admin
@@ -3,7 +3,7 @@
import getopt, difflib, logging, lxml.etree, os, popen2, re, socket, sys, ConfigParser
import Bcfg2.Server.Core, Bcfg2.Logging, Bcfg2.tlslite.api
-import xml.sax.saxutils, binascii
+import xml.sax.saxutils, binascii, time
log = logging.getLogger('bcfg-admin')
@@ -308,15 +308,22 @@ def do_pull(cfile, repopath, client, etype, ename):
else:
state = 'clean'
# need to pull entry out of statistics
- entry = sdata.xpath('.//Statistics[@state="%s"]/Bad/%s[@name="%s"]' % \
- (state, etype, ename))
+ sxpath = ".//Statistics[@state='%s']/Bad/ConfigFile[@name='%s']/../.." % (state, ename)
+ sentries = sdata.xpath(sxpath)
+ print "Found %d entries for %s:%s:%s" % \
+ (len(sentries), client, etype, ename)
+ maxtime = max([time.strptime(stat.get('time')) for stat in sentries])
+ print "Found entry from", time.strftime("%c", maxtime)
+ statblock = [stat for stat in sentries \
+ if time.strptime(stat.get('time')) == maxtime]
+ entry = statblock[0].xpath('.//Bad/ConfigFile[@name="%s"]' % ename)
if not entry:
err_exit("Could not find state data for entry; rerun bcfg2 on client system")
if 'current_bdiff' in entry[0].attrib:
- diff = binascii.a2b_base64(entry[0].get('current_bdiff'))
+ diff = binascii.a2b_base64(entry[-1].get('current_bdiff'))
else:
- diff = entry[0].get('current_diff')
+ diff = entry[-1].get('current_diff')
try:
bcore = Bcfg2.Server.Core.Core({}, cfile)
@@ -335,7 +342,7 @@ def do_pull(cfile, repopath, client, etype, ename):
+ "%s" % ([g.__name__ for g in glist]))
plugin = glist[0]
if diff == None:
- err_exit("Failed to locate diff\nStatistics entry was:\n%s" % lxml.etree.tostring(entry[0]))
+ err_exit("Failed to locate diff\nStatistics entry was:\n%s" % lxml.etree.tostring(entry[-1]))
try:
plugin.AcceptEntry(m, 'ConfigFile', ename, diff)
except Bcfg2.Server.Plugin.PluginExecutionError: