summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Lint
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-24 11:32:56 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-20 17:30:39 -0400
commit4e75773f31bd5dd1cbad30296b2a32c38e552ead (patch)
tree5ebacb2ae0a3d09ea0628edf49015c495c81b3fb /src/lib/Server/Lint
parent6cc1ede5cba4a27871ece2cbdab4ebc93c00fb4c (diff)
downloadbcfg2-4e75773f31bd5dd1cbad30296b2a32c38e552ead.tar.gz
bcfg2-4e75773f31bd5dd1cbad30296b2a32c38e552ead.tar.bz2
bcfg2-4e75773f31bd5dd1cbad30296b2a32c38e552ead.zip
allow xinclude files to be missing if xi:fallback is provided
Conflicts: src/lib/Server/Lint/Comments.py src/lib/Server/Plugin.py
Diffstat (limited to 'src/lib/Server/Lint')
-rw-r--r--src/lib/Server/Lint/Comments.py5
-rw-r--r--src/lib/Server/Lint/Duplicates.py5
-rw-r--r--src/lib/Server/Lint/Validate.py24
3 files changed, 21 insertions, 13 deletions
diff --git a/src/lib/Server/Lint/Comments.py b/src/lib/Server/Lint/Comments.py
index 19fae1b08..10eb8da51 100644
--- a/src/lib/Server/Lint/Comments.py
+++ b/src/lib/Server/Lint/Comments.py
@@ -1,6 +1,7 @@
-import os.path
+import os
import lxml.etree
import Bcfg2.Server.Lint
+from Bcfg2.Server import XI, XI_NAMESPACE
class Comments(Bcfg2.Server.Lint.ServerPlugin):
""" check files for various required headers """
@@ -177,7 +178,7 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
path = os.path.join(self.metadata.data, mfile)
if path in self.files:
xdata = lxml.etree.parse(path)
- for el in xdata.findall('./{http://www.w3.org/2001/XInclude}include'):
+ for el in xdata.findall('./%sinclude' % XI_NAMESPACE):
if not self.has_all_xincludes(el.get('href')):
self.LintError("broken-xinclude-chain",
"Broken XInclude chain: could not include %s" % path)
diff --git a/src/lib/Server/Lint/Duplicates.py b/src/lib/Server/Lint/Duplicates.py
index 75f620603..b8fbefd9a 100644
--- a/src/lib/Server/Lint/Duplicates.py
+++ b/src/lib/Server/Lint/Duplicates.py
@@ -1,6 +1,7 @@
-import os.path
+import os
import lxml.etree
import Bcfg2.Server.Lint
+from Bcfg2.Server import XI, XI_NAMESPACE
class Duplicates(Bcfg2.Server.Lint.ServerPlugin):
""" Find duplicate clients, groups, etc. """
@@ -72,7 +73,7 @@ class Duplicates(Bcfg2.Server.Lint.ServerPlugin):
path = os.path.join(self.metadata.data, mfile)
if path in self.files:
xdata = lxml.etree.parse(path)
- for el in xdata.findall('./{http://www.w3.org/2001/XInclude}include'):
+ for el in xdata.findall('./%sinclude' % XI_NAMESPACE):
if not self.has_all_xincludes(el.get('href')):
self.LintError("broken-xinclude-chain",
"Broken XInclude chain: could not include %s" % path)
diff --git a/src/lib/Server/Lint/Validate.py b/src/lib/Server/Lint/Validate.py
index 952a65365..a95161dce 100644
--- a/src/lib/Server/Lint/Validate.py
+++ b/src/lib/Server/Lint/Validate.py
@@ -1,10 +1,10 @@
-import fnmatch
+import os
+import sys
import glob
+import fnmatch
import lxml.etree
-import os
from subprocess import Popen, PIPE, STDOUT
-import sys
-
+from Bcfg2.Server import XI, XI_NAMESPACE
import Bcfg2.Server.Lint
class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
@@ -177,23 +177,29 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
def follow_xinclude(self, xfile):
""" follow xincludes in the given file """
xdata = lxml.etree.parse(xfile)
- included = set([ent.get('href') for ent in
- xdata.findall('./{http://www.w3.org/2001/XInclude}include')])
+ included = set([el
+ for el in xdata.findall('./%sinclude' % XI_NAMESPACE)])
rv = []
while included:
try:
- filename = included.pop()
+ el = included.pop()
except KeyError:
continue
+ filename = el.get("href")
path = os.path.join(os.path.dirname(xfile), filename)
- if self.HandlesFile(path):
+ if not os.path.exists(path):
+ if not el.findall('./%sfallback' % XI_NAMESPACE):
+ self.LintError("broken-xinclude-chain",
+ "XInclude %s does not exist in %s: %s" %
+ (filename, xfile, self.RenderXML(el)))
+ elif self.HandlesFile(path):
rv.append(path)
groupdata = lxml.etree.parse(path)
[included.add(el.get('href'))
for el in
- groupdata.findall('./{http://www.w3.org/2001/XInclude}include')]
+ groupdata.findall('./%sinclude' % XI_NAMESPACE)]
included.discard(filename)
return rv