From 867b093e26069de43268e424dc673d1242f6380d Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 1 Aug 2007 14:22:32 +0000 Subject: Fix binary config file stats upload git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3589 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-admin | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/sbin/bcfg2-admin') diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin index 95aa2b68a..b913db6f8 100755 --- a/src/sbin/bcfg2-admin +++ b/src/sbin/bcfg2-admin @@ -306,6 +306,8 @@ def do_pull(cfile, repopath, client, etype, ename): sentries = sdata.xpath(sxpath) print "Found %d entries for %s:%s:%s" % \ (len(sentries), client, etype, ename) + if not len(sentries): + raise SystemExit, 1 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 \ @@ -315,19 +317,20 @@ def do_pull(cfile, repopath, client, etype, ename): err_exit("Could not find state data for entry; rerun bcfg2 on client system") cfentry = entry[-1] - mode = 'diff' if 'current_bdiff' in cfentry.attrib: + data = False diff = binascii.a2b_base64(cfentry.get('current_bdiff')) elif 'current_diff' in cfentry.attrib: + data = False diff = cfentry.get('current_diff') elif 'current_bfile' in cfentry.attrib: - mode = 'full' data = binascii.a2b_base64(cfentry.get('current_bfile')) + diff = False - if mode == 'diff': + if diff: print "Located diff:\n %s" % diff else: - print "Found full file data:\n", data + print "Found full (binary) file data" try: bcore = Bcfg2.Server.Core.Core({}, cfile) @@ -345,10 +348,10 @@ def do_pull(cfile, repopath, client, etype, ename): err_exit("Got wrong numbers of matching generators for entry:" \ + "%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(cfentry)) + if not diff and not data: + err_exit("Failed to locate diff or full data\nStatistics entry was:\n%s" % lxml.etree.tostring(cfentry)) try: - plugin.AcceptEntry(m, 'ConfigFile', ename, diff) + plugin.AcceptEntry(m, 'ConfigFile', ename, diff, data) except Bcfg2.Server.Plugin.PluginExecutionError: err_exit("Configuration upload not supported by plugin %s" \ % (plugin.__name__)) -- cgit v1.2.3-1-g7c22