From e95a48a1c28b634adbb8f1aae0f3b586146086f0 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 9 Sep 2013 16:58:46 -0400 Subject: bcfg2-lint: Added Cfg check for multiple global handlers for one entry set --- src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') 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'] -- cgit v1.2.3-1-g7c22