summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-admin
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-08-01 13:45:59 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-08-01 13:45:59 +0000
commit2361aaca291b381bde937af2e575ef053eba6418 (patch)
treef70bad4862e8abc7a878c8d6ac30222b2cb33ff5 /src/sbin/bcfg2-admin
parentae3dc099f25c067ea414e675e24b97848f3bd81a (diff)
downloadbcfg2-2361aaca291b381bde937af2e575ef053eba6418.tar.gz
bcfg2-2361aaca291b381bde937af2e575ef053eba6418.tar.bz2
bcfg2-2361aaca291b381bde937af2e575ef053eba6418.zip
Client side of improved support for binary files in statistics
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3587 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-admin')
-rwxr-xr-xsrc/sbin/bcfg2-admin28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin
index 5264bacf4..95aa2b68a 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, time
+import binascii, time
log = logging.getLogger('bcfg-admin')
@@ -155,12 +155,6 @@ def initialize_repo(cfile):
open("%s/Metadata/clients.xml"%repo, "w").write(clients%socket.getfqdn())
print "Repository created successfuly in %s" % (repo)
-def update_file(path, diff):
- '''Update file at path using diff'''
- newdata = '\n'.join(difflib.restore(xml.sax.saxutils.unescape(diff).split('\n'), 1))
- print "writing file, %s" % path
- open(path, 'w').write(newdata)
-
def get_repo_path(cfile='/etc/bcfg2.conf'):
'''return repository path'''
cfp = ConfigParser.ConfigParser()
@@ -319,11 +313,21 @@ def do_pull(cfile, repopath, client, etype, ename):
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[-1].get('current_bdiff'))
+ cfentry = entry[-1]
+
+ mode = 'diff'
+ if 'current_bdiff' in cfentry.attrib:
+ diff = binascii.a2b_base64(cfentry.get('current_bdiff'))
+ elif 'current_diff' in cfentry.attrib:
+ diff = cfentry.get('current_diff')
+ elif 'current_bfile' in cfentry.attrib:
+ mode = 'full'
+ data = binascii.a2b_base64(cfentry.get('current_bfile'))
+
+ if mode == 'diff':
+ print "Located diff:\n %s" % diff
else:
- diff = entry[-1].get('current_diff')
+ print "Found full file data:\n", data
try:
bcore = Bcfg2.Server.Core.Core({}, cfile)
@@ -342,7 +346,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[-1]))
+ err_exit("Failed to locate diff\nStatistics entry was:\n%s" % lxml.etree.tostring(cfentry))
try:
plugin.AcceptEntry(m, 'ConfigFile', ename, diff)
except Bcfg2.Server.Plugin.PluginExecutionError: