From 960af8f858bf54a1ebfb57b836dfb61c661fe3f1 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 16 Mar 2009 01:33:13 +0000 Subject: Server: Implement config checksum support for slow links git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5121 ce84e21b-d406-0410-9b95-82705330c041 --- src/sbin/bcfg2-server | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/sbin/bcfg2-server') diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index c80655528..282d3fde9 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -9,7 +9,7 @@ from Bcfg2.Server.Core import Core, CoreInitError from xmlrpclib import Fault from lxml.etree import XML, Element, tostring -import logging, select, socket, sys, time +import logging, md5, select, socket, sys, time import Bcfg2.Logger, Bcfg2.Options, Bcfg2.Component, Bcfg2.Daemon logger = logging.getLogger('bcfg2-server') @@ -164,12 +164,19 @@ class Bcfg2Serv(Bcfg2.Component.Component): raise Fault, (6, warning) return True - def Bcfg2GetConfig(self, address, _=False, profile=False): + def Bcfg2GetConfig(self, address, checksum=False): '''Build config for a client''' try: client = self.Core.metadata.resolve_client(address) - return tostring(self.Core.BuildConfiguration(client), - encoding='UTF-8', xml_declaration=True) + config = self.Core.BuildConfiguration(client) + print checksum + if checksum: + for cfile in config.findall('.//ConfigFile'): + if cfile.text != None: + csum = md5.md5(cfile.text) + cfile.set('checksum', csum.hexdigest()) + cfile.text = None + return tostring(config, encoding='UTF-8', xml_declaration=True) except Bcfg2.Server.Plugins.Metadata.MetadataConsistencyError: self.logger.warning("Metadata consistency failure for %s" % (address)) raise Fault, (6, "Metadata consistency failure") -- cgit v1.2.3-1-g7c22