summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-05-22 20:46:15 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-05-22 20:46:15 +0000
commitcd04606f10242676ce67d8628d14e27bd43a9976 (patch)
tree1fc7f47e0ccfe93b3f649a9f910fd70885419c98
parent04c812ea4532f4e174b97532117b31b8135c346b (diff)
downloadbcfg2-cd04606f10242676ce67d8628d14e27bd43a9976.tar.gz
bcfg2-cd04606f10242676ce67d8628d14e27bd43a9976.tar.bz2
bcfg2-cd04606f10242676ce67d8628d14e27bd43a9976.zip
Fix specific probe handling. Now clients only get one (most-specific) instance of each probe. all probe results how up at the probe basename
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4627 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugins/Metadata.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 15e4177e8..9caa7e7ae 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -12,6 +12,8 @@ class MetadataRuntimeError(Exception):
'''This error is raised when the metadata engine is called prior to reading enough data'''
pass
+probe_matcher = re.compile("(?P<basename>\S+).(?P<mode>[GH])_\S+")
+
class ClientMetadata(object):
'''This object contains client metadata'''
def __init__(self, client, groups, bundles, categories, probed, uuid,
@@ -43,9 +45,24 @@ class ProbeSet(Bcfg2.Server.Plugin.EntrySet):
def get_probe_data(self, metadata):
ret = []
- for entry in self.get_matching(metadata):
+ candidates = self.get_matching(metadata)
+ temp = {}
+ for cand in candidates:
+ if cand.specific.all:
+ if cand.name not in temp:
+ temp[cand.name] = (cand, 0)
+ continue
+ mdata = probe_matcher.match(cand.name).groupdict()
+ if mdata['basename'] in temp:
+ if mdata['mode'] > temp[mdata['basename']][1]:
+ temp[mdata['basename']] = (cand, mdata['mode'])
+ else:
+ temp[mdata['basename']] = (cand, mdata['mode'])
+
+ for (name, data) in temp.iteritems():
+ entry, prio = data
probe = lxml.etree.Element('probe')
- probe.set('name', entry.name.split('/')[-1])
+ probe.set('name', name.split('/')[-1])
probe.set('source', "Metadata")
probe.text = entry.data
match = self.bangline.match(entry.data.split('\n')[0])