summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugin.py12
-rw-r--r--src/lib/Server/Plugins/Cfg.py22
2 files changed, 25 insertions, 9 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 3c32dcad7..5f08934e8 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -276,12 +276,13 @@ class XMLSrc(XMLFileBacked):
'''XMLSrc files contain a LNode hierarchy that returns matching entries'''
__node__ = INode
- def __init__(self, filename):
+ def __init__(self, filename, noprio='False'):
XMLFileBacked.__init__(self, filename)
self.items = {}
self.cache = None
self.pnode = None
self.priority = -1
+ self.noprio = noprio
def HandleEvent(self, _=None):
'''Read file upon update'''
@@ -298,10 +299,11 @@ class XMLSrc(XMLFileBacked):
return
self.pnode = self.__node__(xdata, self.items)
self.cache = None
- try:
- self.priority = int(xdata.get('priority'))
- except (ValueError, TypeError):
- logger.error("Got bogus priority %s for file %s" % (xdata.get('priority'), self.name))
+ if not self.noprio:
+ try:
+ self.priority = int(xdata.get('priority'))
+ except (ValueError, TypeError):
+ logger.error("Got bogus priority %s for file %s" % (xdata.get('priority'), self.name))
del xdata, data
def Cache(self, metadata):
diff --git a/src/lib/Server/Plugins/Cfg.py b/src/lib/Server/Plugins/Cfg.py
index aed17382c..afda27cde 100644
--- a/src/lib/Server/Plugins/Cfg.py
+++ b/src/lib/Server/Plugins/Cfg.py
@@ -120,12 +120,17 @@ class ConfigFileEntry(object):
'''add new file additions for a single cf file'''
basename = name.split('/')[-1]
rbasename = self.repopath.split('/')[-1]
- if not ((basename in [':info', 'info']) or
+ if not ((basename in [':info', 'info', ':info.xml', 'info.xml']) or
(basename[:len(rbasename)] == rbasename)):
logger.error("Confused about file %s; ignoring" % (name))
return
if basename in [':info', 'info']:
return self.read_info(basename)
+ elif basename in ['info.xml', ':info.xml']:
+ print "here"
+ fpath = self.repopath + '/' + basename
+ self.infoxml = Bcfg2.Server.Plugin.XMLSrc(fpath, True)
+ return
try:
self.fragments.append(FileEntry(self.path, name))
@@ -140,6 +145,8 @@ class ConfigFileEntry(object):
if event.filename in [':info', 'info']:
if action in ['changed', 'exists', 'created']:
return self.read_info(event.filename)
+ elif event.filename in [':info.xml', 'info.xml']:
+ return self.infoxml.HandleEvent(event)
if event.filename != self.path.split('/')[-1]:
if not specific.match('/' + event.filename):
logger.info('Suppressing event for bogus file %s' % event.filename)
@@ -217,8 +224,15 @@ class ConfigFileEntry(object):
filedata = output
else:
logger.error("Unknown delta type %s" % (delta.op))
-
- [entry.attrib.__setitem__(key, value) for (key, value) in self.metadata.iteritems()]
+
+ if hasattr(self, 'infoxml'):
+ mdata = {}
+ self.infoxml.pnode.Match(metadata, mdata)
+ mdata = mdata['Info'][None]
+ else:
+ mdata = self.metadata
+ [entry.attrib.__setitem__(key, value) \
+ for (key, value) in mdata.iteritems()]
if self.interpolate:
if metadata.hostname in probeData:
for name, value in probeData[metadata.hostname].iteritems():
@@ -228,7 +242,7 @@ class ConfigFileEntry(object):
logger.warning("Cannot interpolate data for client: %s for config file: %s"% (metadata.hostname, basefile.name))
if self.paranoid:
entry.attrib['paranoid'] = 'true'
- if entry.attrib['encoding'] == 'base64':
+ if entry.get('encoding', 'ascii') == 'base64':
entry.text = binascii.b2a_base64(filedata)
return
if filedata == '':