64 lines
2.1 KiB
Diff
64 lines
2.1 KiB
Diff
|
From df219b43b5edab9868cb7d7511f7da1c1f5e225a Mon Sep 17 00:00:00 2001
|
||
|
From: "Bryn M. Reeves" <bmr@redhat.com>
|
||
|
Date: Wed, 1 Jul 2015 14:18:50 +0100
|
||
|
Subject: [PATCH] [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>
|
||
|
---
|
||
|
sos/sosreport.py | 10 ++++++++++
|
||
|
1 file changed, 10 insertions(+)
|
||
|
|
||
|
diff --git a/sos/sosreport.py.orig b/sos/sosreport.py
|
||
|
index 7ea7b33..2af9de5 100644
|
||
|
--- a/sos/sosreport.py.orig
|
||
|
+++ b/sos/sosreport.py
|
||
|
@@ -844,6 +844,7 @@ class SoSReport(object):
|
||
|
self.plugin_names = deque()
|
||
|
self.profiles = set()
|
||
|
using_profiles = len(self.opts.profiles)
|
||
|
+ remaining_profiles = list(self.opts.profiles)
|
||
|
# validate and load plugins
|
||
|
for plug in plugins:
|
||
|
plugbase, ext = os.path.splitext(plug)
|
||
|
@@ -896,12 +897,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:
|