diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2008-03-22 18:20:28 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2008-03-22 18:20:28 +0000 |
commit | f3d2582759edff694b51109f4673154038236479 (patch) | |
tree | 6925058a91aa3cbf883558a85fe19f771f06a20e /src | |
parent | ef5ed530fe317a8c3074c91991436ae74c1b1978 (diff) | |
download | bcfg2-f3d2582759edff694b51109f4673154038236479.tar.gz bcfg2-f3d2582759edff694b51109f4673154038236479.tar.bz2 bcfg2-f3d2582759edff694b51109f4673154038236479.zip |
Clean up stable probe data and dynamic groups properly (Reported by SolJ)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4437 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/Metadata.py | 20 | ||||
-rwxr-xr-x | src/sbin/bcfg2-server | 20 |
2 files changed, 25 insertions, 15 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py index 8f899f09f..9aff24d9d 100644 --- a/src/lib/Server/Plugins/Metadata.py +++ b/src/lib/Server/Plugins/Metadata.py @@ -1,7 +1,7 @@ '''This file stores persistent metadata for the BCFG Configuration Repository''' __revision__ = '$Revision$' -import lxml.etree, re, socket, time, sys +import lxml.etree, re, socket, time import Bcfg2.Server.Plugin class MetadataConsistencyError(Exception): @@ -247,7 +247,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): except: self.logger.error("Failed to read file probed.xml") return - self.probedata={} + self.probedata = {} for client in data.getchildren(): self.probedata[client.get('name')] = {} for pdata in client: @@ -332,7 +332,16 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): ret.append(probe) return ret - def ReceiveData(self, client, data): + def ReceiveData(self, client, datalist): + self.cgroups[client.hostname] = [] + self.probedata[client.hostname] = {} + for data in datalist: + self.ReceiveDataItem(client, data) + self.pdirty = True + self.ptimes[client.hostname] = time.time() + self.write_probedata() + + def ReceiveDataItem(self, client, data): '''Receive probe results pertaining to client''' if not self.cgroups.has_key(client.hostname): self.cgroups[client.hostname] = [] @@ -354,9 +363,6 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): self.probedata[client.hostname].update({ data.get('name'):dtext }) except KeyError: self.probedata[client.hostname] = { data.get('name'):dtext } - self.pdirty = True - self.ptimes[client.hostname] = time.time() - self.write_probedata() def AuthenticateConnection(self, user, password, address): '''This function checks user and password''' @@ -420,5 +426,5 @@ class Metadata(Bcfg2.Server.Plugin.Plugin): def GetClientByProfile(self, profile): '''Return a list of clients that are members of a given profile''' - return [client for client in self.clients \ + return [client for client in self.clients \ if self.clients[client] == profile] diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index cb27e9c89..09d2ce619 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -128,14 +128,18 @@ class Bcfg2Serv(Bcfg2.Component.Component): self.logger.error("Failed to parse probe data from client %s" % (address[0])) return False - for data in xpdata: - if self.Core.plugins.has_key(data.get('source')): - try: - self.Core.plugins[data.get('source')].ReceiveData(meta, data) - except: - self.logger.error("Failed to process probe data from client %s" % (address[0]), exc_info=1) - else: - self.logger.warning("Failed to locate plugin %s" % (data.get('source'))) + sources = [] + [sources.append(data.get('source')) for data in xpdata + if data.get('source') not in sources] + for source in sources: + if source not in self.Core.plugins: + self.logger.warning("Failed to locate plugin %s" % (source)) + continue + dl = [data for data in xpdata if data.get('source') == source] + try: + self.Core.plugins[source].ReceiveData(meta, dl) + except: + self.logger.error("Failed to process probe data from client %s" % (address[0]), exc_info=1) return True def Bcfg2AssertProfile(self, address, profile): |