summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-08-26 21:21:52 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-08-26 21:21:52 +0000
commit448dc7da6b40de27d73b20a6db69be716e7527c4 (patch)
treee00d3585edcce5c41ef1e7d77e932b6c3534e67f /src/lib
parent9f50fe6087f4c21f0b6c3b7002b62d98800f938c (diff)
downloadbcfg2-448dc7da6b40de27d73b20a6db69be716e7527c4.tar.gz
bcfg2-448dc7da6b40de27d73b20a6db69be716e7527c4.tar.bz2
bcfg2-448dc7da6b40de27d73b20a6db69be716e7527c4.zip
Implement persistent probe data (so that templates can be debugged in bcfg2-info)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@3647 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/Metadata.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index ea681d13e..7374aadad 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -57,6 +57,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
self.session_cache = {}
self.clientdata = None
self.default = None
+ self.pdirty = False
try:
loc = datastore + "/Probes"
self.probes = Bcfg2.Server.Plugin.DirectoryBacked(loc, core.fam)
@@ -225,6 +226,36 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
datafile.write(lxml.etree.tostring(self.clientdata.getroot()))
datafile.close()
+ def write_probedata(self):
+ '''write probe data out for use with bcfg2-info'''
+ if self.pdirty:
+ top = lxml.etree.Element("Probed")
+ for client, probed in self.probedata.iteritems():
+ cx = lxml.etree.SubElement(top, 'Client', name=client)
+ for probe in probed:
+ lxml.etree.SubElement(cx, 'Probe', name=probe,
+ value=self.probedata[client][probe])
+ data = lxml.etree.tostring(top)
+ try:
+ datafile = open("%s/%s" % (self.data, 'probed.xml'), 'w')
+ except IOError:
+ self.logger.error("Failed to write clients.xml")
+ raise MetadataRuntimeError
+ datafile.write(data)
+ self.pdirty = False
+
+ def load_probedata(self):
+ try:
+ data = lxml.etree.parse(self.data + '/probed.xml').getroot()
+ except:
+ self.logger.error("Failed to read file probed.xml")
+ return
+ self.probedata={}
+ for client in data.getchildren():
+ self.probedata[client.get('name')] = {}
+ for pdata in client:
+ self.probedata[client.get('name')][pdata.get('name')] = pdata.get('value')
+
def find_toolset(self, client):
'''Find the toolset for a given client'''
tgroups = [self.toolsets[group] for group in self.groups[client][1] if self.toolsets.has_key(group)]
@@ -349,7 +380,9 @@ 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'''