diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Bcfg2/Server/Lint/Comments.py | 32 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Lint/InfoXML.py | 13 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Cfg/CfgGenshiGenerator.py | 1 |
3 files changed, 26 insertions, 20 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Comments.py b/src/lib/Bcfg2/Server/Lint/Comments.py index 3b9370c3b..f5d0e265f 100644 --- a/src/lib/Bcfg2/Server/Lint/Comments.py +++ b/src/lib/Bcfg2/Server/Lint/Comments.py @@ -1,6 +1,10 @@ import os.path import lxml.etree import Bcfg2.Server.Lint +from Bcfg2.Server.Plugins.Cfg.CfgPlaintextGenerator import CfgPlaintextGenerator +from Bcfg2.Server.Plugins.Cfg.CfgGenshiGenerator import CfgGenshiGenerator +from Bcfg2.Server.Plugins.Cfg.CfgCheetahGenerator import CfgCheetahGenerator +from Bcfg2.Server.Plugins.Cfg.CfgInfoXML import CfgInfoXML class Comments(Bcfg2.Server.Lint.ServerPlugin): """ check files for various required headers """ @@ -13,7 +17,6 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin): self.check_properties() self.check_metadata() self.check_cfg() - self.check_infoxml() self.check_probes() @classmethod @@ -90,25 +93,24 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin): "metadata") def check_cfg(self): - """ check Cfg files for required headers """ + """ check Cfg files and info.xml files for required headers """ if 'Cfg' in self.core.plugins: for entryset in self.core.plugins['Cfg'].entries.values(): for entry in entryset.entries.values(): - if entry.name.endswith(".genshi"): + rtype = None + if isinstance(entry, CfgGenshiGenerator): rtype = "tgenshi" - else: + elif isinstance(entry, CfgPlaintextGenerator): rtype = "cfg" - self.check_plaintext(entry.name, entry.data, rtype) - - def check_infoxml(self): - """ check info.xml files for required headers """ - if 'Cfg' in self.core.plugins: - for entryset in self.core.plugins['Cfg'].entries.items(): - if (hasattr(entryset, "infoxml") and - entryset.infoxml is not None): - self.check_xml(entryset.infoxml.name, - entryset.infoxml.pnode.data, - "infoxml") + elif isinstance(entry, CfgCheetahGenerator): + rtype = "tcheetah" + elif isinstance(entry, CfgInfoXML): + self.check_xml(entry.infoxml.name, + entry.infoxml.pnode.data, + "infoxml") + continue + if rtype: + self.check_plaintext(entry.name, entry.data, rtype) def check_probes(self): """ check probes for required headers """ diff --git a/src/lib/Bcfg2/Server/Lint/InfoXML.py b/src/lib/Bcfg2/Server/Lint/InfoXML.py index 7b89e86b2..db6aeea73 100644 --- a/src/lib/Bcfg2/Server/Lint/InfoXML.py +++ b/src/lib/Bcfg2/Server/Lint/InfoXML.py @@ -1,6 +1,7 @@ import os.path import Bcfg2.Options import Bcfg2.Server.Lint +from Bcfg2.Server.Plugins.Cfg.CfgInfoXML import CfgInfoXML class InfoXML(Bcfg2.Server.Lint.ServerPlugin): """ ensure that all config files have an info.xml file""" @@ -9,11 +10,13 @@ class InfoXML(Bcfg2.Server.Lint.ServerPlugin): for filename, entryset in self.core.plugins['Cfg'].entries.items(): infoxml_fname = os.path.join(entryset.path, "info.xml") if self.HandlesFile(infoxml_fname): - if (hasattr(entryset, "infoxml") and - entryset.infoxml is not None): - self.check_infoxml(infoxml_fname, - entryset.infoxml.pnode.data) - else: + found = False + for entry in entryset.entries.values(): + if isinstance(entry, CfgInfoXML): + self.check_infoxml(infoxml_fname, + entry.infoxml.pnode.data) + found = True + if not found: self.LintError("no-infoxml", "No info.xml found for %s" % filename) diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgGenshiGenerator.py b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgGenshiGenerator.py index 70a519969..6c4e6ad51 100644 --- a/src/lib/Bcfg2/Server/Plugins/Cfg/CfgGenshiGenerator.py +++ b/src/lib/Bcfg2/Server/Plugins/Cfg/CfgGenshiGenerator.py @@ -52,6 +52,7 @@ class CfgGenshiGenerator(CfgGenerator): def handle_event(self, event): if event.code2str() == 'deleted': return + CfgGenerator.handle_event(self, event) try: self.template = self.loader.load(self.name, cls=NewTextTemplate, encoding=self.encoding) |