summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Cfg
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-09-09 16:58:46 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-09-09 16:58:46 -0400
commite95a48a1c28b634adbb8f1aae0f3b586146086f0 (patch)
tree9b96142c59e29e71cd92a4c6657f6309eff4a0ca /src/lib/Bcfg2/Server/Plugins/Cfg
parent8fd0dad3e99f4452a6cd3f27e5c97efd9fc308e7 (diff)
downloadbcfg2-e95a48a1c28b634adbb8f1aae0f3b586146086f0.tar.gz
bcfg2-e95a48a1c28b634adbb8f1aae0f3b586146086f0.tar.bz2
bcfg2-e95a48a1c28b634adbb8f1aae0f3b586146086f0.zip
bcfg2-lint: Added Cfg check for multiple global handlers for one entry set
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Cfg')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index 89db45e2c..c6e2d0acb 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -901,6 +901,7 @@ class CfgLint(Bcfg2.Server.Lint.ServerPlugin):
self.check_delta(basename, entry)
self.check_pubkey(basename, entry)
self.check_missing_files()
+ self.check_conflicting_handlers()
@classmethod
def Errors(cls):
@@ -908,7 +909,8 @@ class CfgLint(Bcfg2.Server.Lint.ServerPlugin):
"diff-file-used": "warning",
"no-pubkey-xml": "warning",
"unknown-cfg-files": "error",
- "extra-cfg-files": "error"}
+ "extra-cfg-files": "error",
+ "multiple-global-handlers": "error"}
def check_delta(self, basename, entry):
""" check that no .cat or .diff files are in use """
@@ -955,6 +957,20 @@ class CfgLint(Bcfg2.Server.Lint.ServerPlugin):
remaining, component = os.path.split(remaining)
return rv
+ def check_conflicting_handlers(self):
+ """ Check that a single entryset doesn't have multiple
+ non-specific (i.e., 'all') handlers. """
+ cfg = self.core.plugins['Cfg']
+ for eset in cfg.entries.values():
+ alls = [e for e in eset.entries.values()
+ if (e.specific.all and
+ issubclass(e.__class__, CfgGenerator))]
+ if len(alls) > 1:
+ self.LintError("multiple-global-handlers",
+ "%s has multiple global handlers: %s" %
+ (eset.path, ", ".join(os.path.basename(e.name)
+ for e in alls)))
+
def check_missing_files(self):
""" check that all files on the filesystem are known to Cfg """
cfg = self.core.plugins['Cfg']