summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugin.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-04-08 16:42:45 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-04-08 16:42:45 +0000
commit48ab43cff593b9020633004c4393e8bf91b5b88b (patch)
tree4d6f2966a784470d84dd9e65839edea66e5d1c18 /src/lib/Server/Plugin.py
parentc3aa4519176032ab496f29e57be19f6b1de56d0f (diff)
downloadbcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.tar.gz
bcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.tar.bz2
bcfg2-48ab43cff593b9020633004c4393e8bf91b5b88b.zip
Switch SGenshi over to using EntrySet classes as well (SGenshi templates can now be client and group specific, and can use properties internally)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4486 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugin.py')
-rw-r--r--src/lib/Server/Plugin.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 10bc4f1fc..4a973ba1c 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -446,6 +446,10 @@ class EntrySet:
pattern += '(G(?P<prio>\d+)_(?P<group>\S+))))?$'
self.specific = re.compile(pattern)
+ def get_matching(self, metadata):
+ return [item for item in self.entries.values() \
+ if item.specific.matches(metadata)]
+
def handle_event(self, event):
'''Handle FAM events for the TemplateSet'''
action = event.code2str()
@@ -547,8 +551,7 @@ class EntrySet:
def bind_entry(self, entry, metadata):
'''Return the appropriate interpreted template from the set of available templates'''
self.bind_info_to_entry(entry, metadata)
- matching = [ent for ent in self.entries.values() if \
- ent.specific.matches(metadata)]
+ matching = self.get_matching(metadata)
hspec = [ent for ent in matching if ent.specific.hostname]
if hspec:
@@ -645,14 +648,12 @@ class GroupSpool(Plugin):
def AddDirectoryMonitor(self, relative):
'''Add new directory to FAM structures'''
- if not relative:
- relative = '/'
- if relative[-1] != '/':
+ if not relative.endswith('/'):
relative += '/'
name = self.data + relative
if relative not in self.handles.values():
if not posixpath.isdir(name):
- print "Genshi: Failed to open directory %s" % (name)
+ print "Failed to open directory %s" % (name)
return
reqid = self.core.fam.AddMonitor(name, self)
self.handles[reqid] = relative