diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-07-24 11:32:56 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-07-24 11:33:10 -0400 |
commit | dcf8fddddfa98f39549b57c89c5f79275b0c6b1c (patch) | |
tree | c46152862cb1cf0666c7bd531e0f008829cf04ea /src/lib/Bcfg2/Server/Plugin.py | |
parent | 73ac82182e4cdf2d6371f24455ff7bda71afae81 (diff) | |
download | bcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.tar.gz bcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.tar.bz2 bcfg2-dcf8fddddfa98f39549b57c89c5f79275b0c6b1c.zip |
allow xinclude files to be missing if xi:fallback is provided
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugin.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugin.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py index d035b83d4..6b4276444 100644 --- a/src/lib/Bcfg2/Server/Plugin.py +++ b/src/lib/Bcfg2/Server/Plugin.py @@ -607,16 +607,24 @@ class XMLFileBacked(FileBacked): xdata = self.xdata.getroottree() else: xdata = lxml.etree.parse(fname) - included = [ent.get('href') - for ent in xdata.findall('//{http://www.w3.org/2001/XInclude}include')] - for name in included: + included = [el for el in xdata.findall('//%sinclude' % + Bcfg2.Server.XI_NAMESPACE)] + for el in included: + name = el.get("href") if name not in self.extras: if name.startswith("/"): fpath = name else: fpath = os.path.join(os.path.dirname(self.name), name) - self._follow_xincludes(fname=fpath) - self.add_monitor(fpath, name) + if os.path.exists(fpath): + self._follow_xincludes(fname=fpath) + self.add_monitor(fpath, name) + else: + msg = "%s: %s does not exist, skipping" % (self.name, name) + if el.findall('./%sfallback' % Bcfg2.Server.XI_NAMESPACE): + self.logger.debug(msg) + else: + self.logger.warning(msg) def Index(self): """Build local data structures.""" |