summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-01 13:58:34 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-08-01 13:58:34 -0400
commit7e6a3015cd61fb794fe299df9783099a4a792ec8 (patch)
tree5e135b9ebc7e438f6fd33e58ba9441239206b7f5
parent9898c4c672d061867a1b8957fb4ae8fdf0d829c0 (diff)
downloadbcfg2-7e6a3015cd61fb794fe299df9783099a4a792ec8.tar.gz
bcfg2-7e6a3015cd61fb794fe299df9783099a4a792ec8.tar.bz2
bcfg2-7e6a3015cd61fb794fe299df9783099a4a792ec8.zip
split up XMLSrc parsers used for Rules and info.xml
-rw-r--r--src/lib/Server/Plugin.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index a79fac0e1..0f45f53f1 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -600,12 +600,10 @@ class INode:
group intersection.
"""
raw = {'Client': "lambda m, e:'%(name)s' == m.hostname and predicate(m, e)",
- 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)",
- 'Path': "lambda m, e:('%(name)s' == e.get('name') or '%(name)s' == e.get('realname')) and predicate(m, e)"}
+ 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)"}
nraw = {'Client': "lambda m, e:'%(name)s' != m.hostname and predicate(m, e)",
- 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)",
- 'Path': "lambda m, e:('%(name)s' != e.get('name') and '%(name)s' != e.get('realname')) and predicate(m, e)"}
- containers = ['Group', 'Client', 'Path']
+ 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)"}
+ containers = ['Group', 'Client']
ignore = []
def __init__(self, data, idict, parent=None):
@@ -657,6 +655,17 @@ class INode:
child.Match(metadata, data, entry=entry)
+class InfoNode (INode):
+ """ INode implementation that includes <Path> tags """
+ raw = {'Client': "lambda m, e:'%(name)s' == m.hostname and predicate(m, e)",
+ 'Group': "lambda m, e:'%(name)s' in m.groups and predicate(m, e)",
+ 'Path': "lambda m, e:('%(name)s' == e.get('name') or '%(name)s' == e.get('realname')) and predicate(m, e)"}
+ nraw = {'Client': "lambda m, e:'%(name)s' != m.hostname and predicate(m, e)",
+ 'Group': "lambda m, e:'%(name)s' not in m.groups and predicate(m, e)",
+ 'Path': "lambda m, e:('%(name)s' != e.get('name') and '%(name)s' != e.get('realname')) and predicate(m, e)"}
+ containers = ['Group', 'Client', 'Path']
+
+
class XMLSrc(XMLFileBacked):
"""XMLSrc files contain a LNode hierarchy that returns matching entries."""
__node__ = INode
@@ -704,6 +713,10 @@ class XMLSrc(XMLFileBacked):
self.cache = cache
+class InfoXML (XMLSrc):
+ __node__ = InfoNode
+
+
class XMLDirectoryBacked(DirectoryBacked):
"""Directorybacked for *.xml."""
patterns = re.compile('.*\.xml')