summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-11 15:34:51 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-07-11 15:34:51 -0400
commitfd1ed3e79497c2968831f8e396236ac89bcf58fc (patch)
tree32b48746c63636131f486b6c94cdd42dd87043f6 /src
parente4c5c6aa3602335488936b6fd7c033245dd1ffb9 (diff)
downloadbcfg2-fd1ed3e79497c2968831f8e396236ac89bcf58fc.tar.gz
bcfg2-fd1ed3e79497c2968831f8e396236ac89bcf58fc.tar.bz2
bcfg2-fd1ed3e79497c2968831f8e396236ac89bcf58fc.zip
bcfg2-lint bug fixes
Diffstat (limited to 'src')
-rwxr-xr-xsrc/lib/Bcfg2/Server/Lint/Genshi.py1
-rw-r--r--src/lib/Bcfg2/Server/Lint/RequiredAttrs.py28
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Bundler.py4
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py7
-rwxr-xr-xsrc/sbin/bcfg2-lint9
5 files changed, 30 insertions, 19 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Genshi.py b/src/lib/Bcfg2/Server/Lint/Genshi.py
index b6007161e..74142b446 100755
--- a/src/lib/Bcfg2/Server/Lint/Genshi.py
+++ b/src/lib/Bcfg2/Server/Lint/Genshi.py
@@ -1,3 +1,4 @@
+import sys
import genshi.template
import Bcfg2.Server.Lint
diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
index 0a369c841..0976ed9dd 100644
--- a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
+++ b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
@@ -5,6 +5,9 @@ import Bcfg2.Server.Lint
import Bcfg2.Client.Tools.POSIX
import Bcfg2.Client.Tools.VCS
from Bcfg2.Server.Plugins.Packages import Apt, Yum
+from Bcfg2.Server.Plugins.Bundler import have_genshi
+if have_genshi:
+ from Bcfg2.Server.Plugins.SGenshi import SGenshiTemplateFile
# format verifying functions
def is_filename(val):
@@ -89,17 +92,13 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
)
def Run(self):
- print "checking packages\n"
self.check_packages()
if "Defaults" in self.core.plugins:
self.logger.info("Defaults plugin enabled; skipping required "
"attribute checks")
else:
- print "checking rules\n"
self.check_rules()
- print "checking bundles\n"
self.check_bundles()
- print 'done running RequiredAttrs'
@classmethod
def Errors(cls):
@@ -149,14 +148,17 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
""" check bundles for BoundPath entries with missing attrs """
if 'Bundler' in self.core.plugins:
for bundle in self.core.plugins['Bundler'].entries.values():
- print "checking bundle %s" % bundle.name
- try:
- xdata = lxml.etree.XML(bundle.data)
- except (lxml.etree.XMLSyntaxError, AttributeError):
- xdata = lxml.etree.parse(bundle.template.filepath).getroot()
-
- for path in xdata.xpath("//*[substring(name(), 1, 5) = 'Bound']"):
- self.check_entry(path, bundle.name)
+ if (self.HandlesFile(bundle.name) and
+ (not have_genshi or
+ not isinstance(bundle, SGenshiTemplateFile))):
+ try:
+ xdata = lxml.etree.XML(bundle.data)
+ except (lxml.etree.XMLSyntaxError, AttributeError):
+ xdata = \
+ lxml.etree.parse(bundle.template.filepath).getroot()
+
+ for path in xdata.xpath("//*[substring(name(), 1, 5) = 'Bound']"):
+ self.check_entry(path, bundle.name)
def check_entry(self, entry, filename):
""" generic entry check """
@@ -206,7 +208,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
(tag, name, filename,
", ".join([attr
for attr in
- required_attrs.difference(attrs)]),
+ set(required_attrs.keys()).difference(attrs)]),
self.RenderXML(entry)))
for attr, fmt in required_attrs.items():
diff --git a/src/lib/Bcfg2/Server/Plugins/Bundler.py b/src/lib/Bcfg2/Server/Plugins/Bundler.py
index a7b5dccde..26fe1d822 100644
--- a/src/lib/Bcfg2/Server/Plugins/Bundler.py
+++ b/src/lib/Bcfg2/Server/Plugins/Bundler.py
@@ -92,6 +92,7 @@ class Bundler(Bcfg2.Server.Plugin.Plugin,
bundlename, exc_info=1)
return bundleset
+
class BundlerLint(Bcfg2.Server.Lint.ServerPlugin):
""" Perform various bundle checks """
def Run(self):
@@ -99,7 +100,8 @@ class BundlerLint(Bcfg2.Server.Lint.ServerPlugin):
self.missing_bundles()
for bundle in self.core.plugins['Bundler'].entries.values():
if (self.HandlesFile(bundle.name) and
- (not have_genshi or type(bundle) is not SGenshiTemplateFile)):
+ (not have_genshi or
+ not isinstance(bundle, SGenshiTemplateFile))):
self.bundle_names(bundle)
@classmethod
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index 5293d7c94..081a68639 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -416,9 +416,12 @@ class Cfg(Bcfg2.Server.Plugin.GroupSpool,
log)
class CfgLint(Bcfg2.Server.Lint.ServerPlugin):
+ """ warn about usage of .cat and .diff files """
+
def Run(self):
- # about usage of .cat and .diff files
- self.check_deltas()
+ for basename, entry in list(self.core.plugins['Cfg'].entries.items()):
+ self.check_entry(basename, entry)
+
@classmethod
def Errors(cls):
diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint
index 423c63ba3..c06b87d76 100755
--- a/src/sbin/bcfg2-lint
+++ b/src/sbin/bcfg2-lint
@@ -123,15 +123,18 @@ if __name__ == '__main__':
# load plugins specified in the config first
allplugins = dict()
for plugin in plugin_list:
- allplugins[plugin] = load_plugin("Bcfg2.Server.Lint." + plugin)
+ try:
+ allplugins[plugin] = load_plugin("Bcfg2.Server.Lint." + plugin)
+ except ImportError:
+ pass
# load lint plugins bundled with bcfg2-server plugins
for plugin in setup['plugins']:
try:
allplugins[plugin] = load_plugin("Bcfg2.Server.Plugins." + plugin,
obj_name=plugin + "Lint")
- except AttributeError:
- pass
+ except (ImportError, AttributeError):
+ pass
serverplugins = dict()
serverlessplugins = dict()