summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Lint/InfoXML.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2011-04-25 10:45:41 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2011-04-25 10:45:41 -0400
commit17b8ceb17e0ee775a667d2f92b2b192e567b2df6 (patch)
tree103ade296f16fa1457abcb7f97fd5d158b435385 /src/lib/Server/Lint/InfoXML.py
parent66642f84fd71e9230245b11718bf9a7e96ba0c7f (diff)
downloadbcfg2-17b8ceb17e0ee775a667d2f92b2b192e567b2df6.tar.gz
bcfg2-17b8ceb17e0ee775a667d2f92b2b192e567b2df6.tar.bz2
bcfg2-17b8ceb17e0ee775a667d2f92b2b192e567b2df6.zip
Various bcfg2-lint fixes:
* check for all plugins before referencing them, since in --stdin mode even plugins like Bundler may not be instantiated * formatting fixes * made Bundles plugin work with or without genshi installed * fixed name of plugin in example bcfg2-lint.conf
Diffstat (limited to 'src/lib/Server/Lint/InfoXML.py')
-rw-r--r--src/lib/Server/Lint/InfoXML.py61
1 files changed, 31 insertions, 30 deletions
diff --git a/src/lib/Server/Lint/InfoXML.py b/src/lib/Server/Lint/InfoXML.py
index 798d8c208..25f609902 100644
--- a/src/lib/Server/Lint/InfoXML.py
+++ b/src/lib/Server/Lint/InfoXML.py
@@ -7,36 +7,37 @@ class InfoXML(Bcfg2.Server.Lint.ServerPlugin):
@Bcfg2.Server.Lint.returnErrors
def Run(self):
- 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):
- xdata = entryset.infoxml.pnode.data
- for info in xdata.getroottree().findall("//Info"):
- required = []
- if "required_attrs" in self.config:
- required = self.config["required_attrs"].split(",")
+ if 'Cfg' in self.core.plugins:
+ 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(entryset.infoxml.pnode.data)
+ elif ("require" in self.config and
+ self.config["require"].lower != "false"):
+ self.LintError("No info.xml found for %s" % filename)
- missing = [attr for attr in required
- if info.get(attr) is None]
- if missing:
- self.LintError("Required attribute(s) %s not found in %s:%s" %
- (",".join(missing), infoxml_fname,
- self.RenderXML(info)))
+ def check_infoxml(self, xdata):
+ for info in xdata.getroottree().findall("//Info"):
+ required = []
+ if "required_attrs" in self.config:
+ required = self.config["required_attrs"].split(",")
- if ("require_paranoid" in self.config and
- self.config["require_paranoid"].lower() == "true" and
- (Bcfg2.Options.MDATA_PARANOID.value and
- info.get("paranoid") is not None and
- info.get("paranoid").lower() == "false") or
- (not Bcfg2.Options.MDATA_PARANOID.value and
- (info.get("paranoid") is None or
- info.get("paranoid").lower() != "true"))):
- self.LintError("Paranoid must be true in %s:%s" %
- (infoxml_fname,
- self.RenderXML(info)))
- elif ("require" in self.config and
- self.config["require"].lower != "false"):
- self.LintError("No info.xml found for %s" % filename)
+ missing = [attr for attr in required if info.get(attr) is None]
+ if missing:
+ self.LintError("Required attribute(s) %s not found in %s:%s" %
+ (",".join(missing), infoxml_fname,
+ self.RenderXML(info)))
+
+ if ("require_paranoid" in self.config and
+ self.config["require_paranoid"].lower() == "true" and
+ (Bcfg2.Options.MDATA_PARANOID.value and
+ info.get("paranoid") is not None and
+ info.get("paranoid").lower() == "false") or
+ (not Bcfg2.Options.MDATA_PARANOID.value and
+ (info.get("paranoid") is None or
+ info.get("paranoid").lower() != "true"))):
+ self.LintError("Paranoid must be true in %s:%s" %
+ (infoxml_fname, self.RenderXML(info)))