summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-07-31 14:49:25 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-07-31 14:49:25 +0000
commit188f7957bf837cbf566f36d168274b8f3b66932d (patch)
treeaaa3939c5102a98b6079e80b5923d8e7b6165338 /src/lib/Server
parentcc6389445421c330532bfb536e6d727ff4cc8988 (diff)
downloadbcfg2-188f7957bf837cbf566f36d168274b8f3b66932d.tar.gz
bcfg2-188f7957bf837cbf566f36d168274b8f3b66932d.tar.bz2
bcfg2-188f7957bf837cbf566f36d168274b8f3b66932d.zip
Implement part 1 of (optional) probe result caching
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3585 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Plugins/Metadata.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index f382ec3d9..ea681d13e 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -58,11 +58,13 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
self.clientdata = None
self.default = None
try:
- self.probes = Bcfg2.Server.Plugin.DirectoryBacked(datastore + "/Probes",
- core.fam)
+ loc = datastore + "/Probes"
+ self.probes = Bcfg2.Server.Plugin.DirectoryBacked(loc, core.fam)
except:
self.probes = False
self.probedata = {}
+ self.ptimes = {}
+ self.pctime = 0
self.extra = {'groups.xml':[], 'clients.xml':[]}
self.password = core.cfile.get('communication', 'password')
@@ -304,10 +306,12 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
return ClientMetadata(client, newgroups, newbundles, toolset, newcategories,
probed, uuid, password)
- def GetProbes(self, _):
+ def GetProbes(self, meta, force=False):
'''Return a set of probes for execution on client'''
ret = []
- if self.probes:
+ ctime = time.time() - self.ptimes.get(meta.hostname, 0)
+ diff = ctime > self.pctime
+ if self.probes and (diff or force):
bangline = re.compile('^#!(?P<interpreter>(/\w+)+)$')
for name, entry in [(name, entry) for name, entry in \
self.probes.entries.iteritems() if entry.data]:
@@ -345,6 +349,7 @@ 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.ptimes[client.hostname] = time.time()
def AuthenticateConnection(self, user, password, address):
'''This function checks user and password'''