diff options
-rw-r--r-- | doc/man/bcfg2-lint.txt | 40 | ||||
-rw-r--r-- | examples/bcfg2-lint.conf | 4 | ||||
-rw-r--r-- | man/bcfg2-admin.8 | 2 | ||||
-rw-r--r-- | man/bcfg2-build-reports.8 | 2 | ||||
-rw-r--r-- | man/bcfg2-crypt.8 | 2 | ||||
-rw-r--r-- | man/bcfg2-info.8 | 2 | ||||
-rw-r--r-- | man/bcfg2-lint.8 | 42 | ||||
-rw-r--r-- | man/bcfg2-lint.conf.5 | 2 | ||||
-rw-r--r-- | man/bcfg2-reports.8 | 2 | ||||
-rw-r--r-- | man/bcfg2-server.8 | 2 | ||||
-rw-r--r-- | man/bcfg2.1 | 2 | ||||
-rw-r--r-- | man/bcfg2.conf.5 | 2 | ||||
-rw-r--r-- | schemas/types.xsd | 5 | ||||
-rw-r--r-- | src/lib/Bcfg2/Options.py | 5 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Lint/RequiredAttrs.py | 31 | ||||
-rwxr-xr-x | src/sbin/bcfg2-lint | 13 |
16 files changed, 75 insertions, 83 deletions
diff --git a/doc/man/bcfg2-lint.txt b/doc/man/bcfg2-lint.txt index b7206bd31..c15d62459 100644 --- a/doc/man/bcfg2-lint.txt +++ b/doc/man/bcfg2-lint.txt @@ -57,15 +57,10 @@ Options Plugins ------- -See :manpage:`bcfg2-lint.conf(5)` for more information on the -configuration of the plugins listed below. - -Bundles - Check the specification for several issues with Bundler: bundles - referenced in metadata but not found in *Bundler/*; bundles whose - *name* attribute does not match the filename; and Genshi template - bundles that use the *<Group>* tag (which is not processed in - templated bundles). +In addition to the plugins listed below, Bcfg2 server plugins may have +their own *bcfg2-lint* functionality, which is enabled automatically +when the server plugin is enabled. See :manpage:`bcfg2-lint.conf(5)` +for more information on lint plugin configuration. Comments Check the specification for VCS keywords and any comments that are @@ -77,9 +72,12 @@ Comments In XML files, only comments are checked for the keywords and comments required. -Duplicates - Check for several types of duplicates in the Metadata: duplicate - groups; duplicate clients; and multiple default groups. +Genshi + Ensure that all Genshi templates are valid and compile properly. + +GroupNames + Ensure that all groups called by name in Metadata, Rules, Bundler, + GroupPatterns, and Cfg are valid. InfoXML Check that certain attributes are specified in *info.xml* files. By @@ -91,14 +89,10 @@ MergeFiles Suggest that similar probes and config files be merged into single probes or TGenshi templates. -Pkgmgr - Check for duplicate packages specified in Pkgmgr. - RequiredAttrs - Check that all *Path* and *BoundPath* tags have the attributes that - are required by their type (e.g., a path of type symlink must have - name and to specified to be valid). This sort of validation is - beyond the scope of an XML schema. + Check that all entries have the appropriate required attributes, + and that the attributes are in a valid format. This goes above + and beyond the validation offered by an XML schema. Validate Validate the Bcfg2 specification against the XML schemas. @@ -113,10 +107,10 @@ Validate Bugs ---- -:program:`bcfg2-lint` may not handle some older plugins as well as it -handles newer ones. For instance, there may be some places where it -expects all of your configuration files to be handled by Cfg rather than -by a mix of Cfg and TGenshi or TCheetah. +:program:`bcfg2-lint` may not handle some deprecated plugins as well +as it handles newer ones. For instance, there may be some places where +it expects all of your configuration files to be handled by Cfg rather +than by a mix of Cfg and TGenshi or TCheetah. See Also -------- diff --git a/examples/bcfg2-lint.conf b/examples/bcfg2-lint.conf index 0fe99f967..5f49ab057 100644 --- a/examples/bcfg2-lint.conf +++ b/examples/bcfg2-lint.conf @@ -1,5 +1,5 @@ [lint] -plugins=Duplicates,InfoXML,Bundles,Comments,RequiredAttrs,Validate,MergeFiles +plugins=InfoXML,Comments,RequiredAttrs,Validate,MergeFiles [errors] no-infoxml=error @@ -18,7 +18,7 @@ genshibundler_comments = Properties,Probes,Description properties_comments = Template,Format genshi_comments = Maintainer,Properties,Probes,Description cheetah_comments = Maintainer,Properties,Probes,Description -cfg_comments = +cfg_comments = cfg_keywords = probe_comments = Maintainer,Purpose,Groups,Other Output diff --git a/man/bcfg2-admin.8 b/man/bcfg2-admin.8 index 008f56fa2..279ee7e0b 100644 --- a/man/bcfg2-admin.8 +++ b/man/bcfg2-admin.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-ADMIN" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-ADMIN" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-admin \- Perform repository administration tasks . diff --git a/man/bcfg2-build-reports.8 b/man/bcfg2-build-reports.8 index 1639adc74..8d3d58ebb 100644 --- a/man/bcfg2-build-reports.8 +++ b/man/bcfg2-build-reports.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-BUILD-REPORTS" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-BUILD-REPORTS" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-build-reports \- Generate state reports for Bcfg2 clients . diff --git a/man/bcfg2-crypt.8 b/man/bcfg2-crypt.8 index ab428c266..7c11eb66c 100644 --- a/man/bcfg2-crypt.8 +++ b/man/bcfg2-crypt.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-CRYPT" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-CRYPT" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-crypt \- Bcfg2 encryption and decryption utility . diff --git a/man/bcfg2-info.8 b/man/bcfg2-info.8 index 57c9e012c..ee650b5da 100644 --- a/man/bcfg2-info.8 +++ b/man/bcfg2-info.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-INFO" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-INFO" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-info \- Creates a local version of the Bcfg2 server core for state observation . diff --git a/man/bcfg2-lint.8 b/man/bcfg2-lint.8 index 01ba87a51..c81c305f1 100644 --- a/man/bcfg2-lint.8 +++ b/man/bcfg2-lint.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-LINT" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-LINT" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-lint \- Check Bcfg2 specification for validity, common mistakes, and style . @@ -85,17 +85,12 @@ included on stdin. .UNINDENT .SH PLUGINS .sp -See \fIbcfg2\-lint.conf(5)\fP for more information on the -configuration of the plugins listed below. +In addition to the plugins listed below, Bcfg2 server plugins may have +their own \fIbcfg2\-lint\fP functionality, which is enabled automatically +when the server plugin is enabled. See \fIbcfg2\-lint.conf(5)\fP +for more information on lint plugin configuration. .INDENT 0.0 .TP -.B Bundles -Check the specification for several issues with Bundler: bundles -referenced in metadata but not found in \fIBundler/\fP; bundles whose -\fIname\fP attribute does not match the filename; and Genshi template -bundles that use the \fI<Group>\fP tag (which is not processed in -templated bundles). -.TP .B Comments Check the specification for VCS keywords and any comments that are required. By default, this only checks that the \fI$Id$\fP keyword is @@ -106,9 +101,12 @@ you might require that every file have a "Maintainer" comment.) In XML files, only comments are checked for the keywords and comments required. .TP -.B Duplicates -Check for several types of duplicates in the Metadata: duplicate -groups; duplicate clients; and multiple default groups. +.B Genshi +Ensure that all Genshi templates are valid and compile properly. +.TP +.B GroupNames +Ensure that all groups called by name in Metadata, Rules, Bundler, +GroupPatterns, and Cfg are valid. .TP .B InfoXML Check that certain attributes are specified in \fIinfo.xml\fP files. By @@ -120,14 +118,10 @@ that paranoid mode be enabled for all files. Suggest that similar probes and config files be merged into single probes or TGenshi templates. .TP -.B Pkgmgr -Check for duplicate packages specified in Pkgmgr. -.TP .B RequiredAttrs -Check that all \fIPath\fP and \fIBoundPath\fP tags have the attributes that -are required by their type (e.g., a path of type symlink must have -name and to specified to be valid). This sort of validation is -beyond the scope of an XML schema. +Check that all entries have the appropriate required attributes, +and that the attributes are in a valid format. This goes above +and beyond the validation offered by an XML schema. .TP .B Validate Validate the Bcfg2 specification against the XML schemas. @@ -140,10 +134,10 @@ in \fIntp.xsd\fP schema validation will be performed on \fIntp.xml\fP. .UNINDENT .SH BUGS .sp -\fBbcfg2\-lint\fP may not handle some older plugins as well as it -handles newer ones. For instance, there may be some places where it -expects all of your configuration files to be handled by Cfg rather than -by a mix of Cfg and TGenshi or TCheetah. +\fBbcfg2\-lint\fP may not handle some deprecated plugins as well +as it handles newer ones. For instance, there may be some places where +it expects all of your configuration files to be handled by Cfg rather +than by a mix of Cfg and TGenshi or TCheetah. .SH SEE ALSO .sp \fIbcfg2(1)\fP, \fIbcfg2\-server(8)\fP, diff --git a/man/bcfg2-lint.conf.5 b/man/bcfg2-lint.conf.5 index d02b4e380..d6d299616 100644 --- a/man/bcfg2-lint.conf.5 +++ b/man/bcfg2-lint.conf.5 @@ -1,4 +1,4 @@ -.TH "BCFG2-LINT.CONF" "5" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-LINT.CONF" "5" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-lint.conf \- Configuration parameters for bcfg2-lint . diff --git a/man/bcfg2-reports.8 b/man/bcfg2-reports.8 index 3b9e549e7..7b1622a5e 100644 --- a/man/bcfg2-reports.8 +++ b/man/bcfg2-reports.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-REPORTS" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-REPORTS" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-reports \- Query reporting system for client status . diff --git a/man/bcfg2-server.8 b/man/bcfg2-server.8 index 1fbbb0ec7..8df8ebfd5 100644 --- a/man/bcfg2-server.8 +++ b/man/bcfg2-server.8 @@ -1,4 +1,4 @@ -.TH "BCFG2-SERVER" "8" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2-SERVER" "8" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2-server \- Server for client configuration specifications . diff --git a/man/bcfg2.1 b/man/bcfg2.1 index 6ee34831f..1e0f526c8 100644 --- a/man/bcfg2.1 +++ b/man/bcfg2.1 @@ -1,4 +1,4 @@ -.TH "BCFG2" "1" "November 14, 2012" "1.3" "Bcfg2" +.TH "BCFG2" "1" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2 \- Bcfg2 client tool . diff --git a/man/bcfg2.conf.5 b/man/bcfg2.conf.5 index dfcb42a24..0a982b8f0 100644 --- a/man/bcfg2.conf.5 +++ b/man/bcfg2.conf.5 @@ -1,4 +1,4 @@ -.TH "BCFG2.CONF" "5" "November 26, 2012" "1.3" "Bcfg2" +.TH "BCFG2.CONF" "5" "January 14, 2013" "1.3" "Bcfg2" .SH NAME bcfg2.conf \- Configuration parameters for Bcfg2 . diff --git a/schemas/types.xsd b/schemas/types.xsd index 6262d9bb6..a6070279a 100644 --- a/schemas/types.xsd +++ b/schemas/types.xsd @@ -14,6 +14,11 @@ <xsd:simpleType name='PackageTypeEnum'> <xsd:restriction base='xsd:string'> + <xsd:enumeration value='apk' /> + <xsd:enumeration value='ips' /> + <xsd:enumeration value='macport' /> + <xsd:enumeration value='opencsw' /> + <xsd:enumeration value='pacman' /> <xsd:enumeration value='deb' /> <xsd:enumeration value='rpm' /> <xsd:enumeration value='blast' /> diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index aff8c0733..c0a274e23 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -827,6 +827,11 @@ LINT_CONFIG = \ cmd='--lint-config', odesc='<conffile>', long_arg=True) +LINT_PLUGINS = \ + Option('bcfg2-lint plugin list', + default=None, # default is Bcfg2.Server.Lint.__all__ + cf=('lint', 'plugins'), + cook=list_split) LINT_SHOW_ERRORS = \ Option('Show error handling', default=False, diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py index 3c130731b..61b737a82 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: @@ -236,6 +231,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin): required_attrs[entry.get('scope')] = is_username if '__text__' in required_attrs: + fmt = required_attrs['__text__'] del required_attrs['__text__'] if (not entry.text and not entry.get('empty', 'false').lower() == 'true'): @@ -243,7 +239,6 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin): "Text missing for %s %s in %s: %s" % (tag, name, filename, self.RenderXML(entry))) - fmt = required_attrs['__text__'] if fmt is not None and not fmt(entry.text): self.LintError( "required-attr-format", diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint index a6efd0ccb..959a2d8ed 100755 --- a/src/sbin/bcfg2-lint +++ b/src/sbin/bcfg2-lint @@ -9,7 +9,6 @@ import Bcfg2.Logger import Bcfg2.Options import Bcfg2.Server.Core import Bcfg2.Server.Lint -from Bcfg2.Compat import ConfigParser LOGGER = logging.getLogger('bcfg2-lint') @@ -88,12 +87,11 @@ def load_plugins(setup): if setup['args']: plugin_list = setup['args'] elif "bcfg2-repo-validate" in sys.argv[0]: - plugin_list = 'Duplicates,RequiredAttrs,Validate'.split(',') + plugin_list = 'RequiredAttrs,Validate'.split(',') + elif setup['lint_plugins']: + plugin_list = setup['lint_plugins'] else: - try: - plugin_list = setup.cfp.get('lint', 'plugins').split(',') - except (ConfigParser.NoOptionError, ConfigParser.NoSectionError): - plugin_list = Bcfg2.Server.Lint.__all__ + plugin_list = Bcfg2.Server.Lint.__all__ allplugins = dict() for plugin in plugin_list: @@ -144,7 +142,7 @@ def main(): showerrors=Bcfg2.Options.LINT_SHOW_ERRORS, stdin=Bcfg2.Options.LINT_FILES_ON_STDIN, schema=Bcfg2.Options.SCHEMA_PATH, - plugins=Bcfg2.Options.SERVER_PLUGINS) + lint_plugins=Bcfg2.Options.LINT_PLUGINS) optinfo.update(Bcfg2.Options.CLI_COMMON_OPTIONS) optinfo.update(Bcfg2.Options.SERVER_COMMON_OPTIONS) setup = Bcfg2.Options.OptionParser(optinfo) @@ -156,6 +154,7 @@ def main(): Bcfg2.Logger.setup_logging('bcfg2-info', **log_args) setup.cfp.read(setup['lint_config']) + setup.reparse() if setup['stdin']: files = [s.strip() for s in sys.stdin.readlines()] |