diff options
author | Bryn M. Reeves <bmr@redhat.com> | 2015-07-01 14:18:50 +0100 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2015-07-01 14:20:59 +0100 |
commit | df219b43b5edab9868cb7d7511f7da1c1f5e225a (patch) | |
tree | c097ee481f48e61c8e732a1e533443cbb0e98950 | |
parent | 5ac02f4fbc38992f23aa1f44974f74f7c4e16ea5 (diff) | |
download | sos-df219b43b5edab9868cb7d7511f7da1c1f5e225a.tar.gz |
[general] verify --profile contains valid plugins only
If --profile contains an invalid profile name, stop, and
print the list of available profiles as well as the offending
profile name (helpful when multiple profiles have been specified).
E.g.:
sosreport (version 3.2)
Unknown or inactive profile(s) provided: virtuous
The following profiles are available:
boot boot, startup, systemd, udev
cluster
[...]
Based on a patch from Pavel Moravec.
Fixes #505.
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/sosreport.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py index 9315438b..efa60433 100644 --- a/sos/sosreport.py +++ b/sos/sosreport.py @@ -870,6 +870,7 @@ class SoSReport(object): extra_classes.append(sos.plugins.ExperimentalPlugin) valid_plugin_classes = tuple(policy_classes + extra_classes) validate_plugin = self.policy.validate_plugin + remaining_profiles = list(self.opts.profiles) # validate and load plugins for plug in plugins: plugbase, ext = os.path.splitext(plug) @@ -922,12 +923,21 @@ class SoSReport(object): self._skip(plugin_class, _("not specified")) continue + for i in plugin_class.profiles: + if i in remaining_profiles: + remaining_profiles.remove(i) + self._load(plugin_class) except Exception as e: self.soslog.warning(_("plugin %s does not install, " "skipping: %s") % (plug, e)) if self.raise_plugins: raise + if len(remaining_profiles) > 0: + self.soslog.error(_("Unknown or inactive profile(s) provided:" + " %s") % ", ".join(remaining_profiles)) + self.list_profiles() + self._exit(1) def _set_all_options(self): if self.opts.usealloptions: |