summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-14 09:43:11 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-01-14 09:43:11 -0500
commit6ce9af36f6f0e7796d986b29ce3f4d8a52c55d2b (patch)
tree7bd887500ae6c0d5f786c8cd8c08cfaea4dd29a5 /src
parent74c2b977ea41c379d38b0880cc61b7bdc709a552 (diff)
downloadbcfg2-6ce9af36f6f0e7796d986b29ce3f4d8a52c55d2b.tar.gz
bcfg2-6ce9af36f6f0e7796d986b29ce3f4d8a52c55d2b.tar.bz2
bcfg2-6ce9af36f6f0e7796d986b29ce3f4d8a52c55d2b.zip
better validation of required attrs for Package and Service tags
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Lint/RequiredAttrs.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
index 3c130731b..9ed8be2e4 100644
--- a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
+++ b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
@@ -78,12 +78,8 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
hasattr(Bcfg2.Client.Tools.VCS,
"Install%s" % v)),
revision=None, sourceurl=None)),
- Service={
- "chkconfig": dict(name=None),
- "deb": dict(name=None),
- "rc-update": dict(name=None),
- "smf": dict(name=None, FMRI=None),
- "upstart": dict(name=None)},
+ Service={"__any__": dict(name=None),
+ "smf": dict(name=None, FMRI=None)},
Action={None: dict(name=None,
timing=lambda v: v in ['pre', 'post', 'both'],
when=lambda v: v in ['modified', 'always'],
@@ -98,7 +94,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
v)),
mask=dict(perms=lambda v: re.match('^([0-7]|[rwx\-]{0,3}',
v))),
- Package={None: dict(name=None)},
+ Package={"__any__": dict(name=None)},
SEBoolean={None: dict(name=None,
value=lambda v: v in ['on', 'off'])},
SEModule={None: dict(name=None, __text__=None)},
@@ -212,17 +208,16 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
(tag, self.RenderXML(entry)))
return
- if isinstance(self.required_attrs[tag], dict):
- etype = entry.get('type')
- if etype in self.required_attrs[tag]:
- required_attrs = self.required_attrs[tag][etype]
- else:
- self.LintError("unknown-entry-type",
- "Unknown %s type %s: %s" %
- (tag, etype, self.RenderXML(entry)))
- return
+ etype = entry.get('type')
+ if etype in self.required_attrs[tag]:
+ required_attrs = self.required_attrs[tag][etype]
+ elif '__any__' in self.required_attrs[tag]:
+ required_attrs = self.required_attrs[tag]['__any__']
else:
- required_attrs = self.required_attrs[tag]
+ self.LintError("unknown-entry-type",
+ "Unknown %s type %s: %s" %
+ (tag, etype, self.RenderXML(entry)))
+ return
attrs = set(entry.attrib.keys())
if 'dev_type' in required_attrs: