aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-09-15 18:32:47 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-09-16 11:08:03 +0100
commitb76aba9059bdfeeefa3ce4458632dc98ef2a88f8 (patch)
treeb3d7c0002b1f9b0b71d3a8ec7a63aa704bf59d61
parent2b9cf8b0746c0125d4e4516b03d3add39d0adaad (diff)
downloadsos-b76aba9059bdfeeefa3ce4458632dc98ef2a88f8.tar.gz
[sosreport] allow --profile with -o and -n
Allow the user to fine-tune the set of enabled plugins using the -o (--only-plugins) and -n (--skip-plugins) options. These add and remove plugins from the set defined by the active profile(s). Both options may be specified multiple times, or given lists of plugins to operate on. E.g.: Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 4e2f2685..29b6f640 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -779,12 +779,15 @@ class SoSReport(object):
self.config.get("plugins", "disable").split(',')]
return disabled
- def _is_in_profile(self, plugin_class, profiles):
- if not len(profiles):
+ def _is_in_profile(self, plugin_class):
+ onlyplugins = self.opts.onlyplugins
+ if not len(self.profiles):
return True
if not hasattr(plugin_class, "profiles"):
return False
- return any([p in profiles for p in plugin_class.profiles])
+ if onlyplugins and not self._is_not_specified(plugin_class.name()):
+ return True
+ return any([p in self.opts.profiles for p in plugin_class.profiles])
def _is_skipped(self, plugin_name):
return (plugin_name in self.opts.noplugins or
@@ -853,7 +856,8 @@ class SoSReport(object):
if hasattr(plugin_class, "profiles"):
self.profiles.update(plugin_class.profiles)
- if not self._is_in_profile(plugin_class, self.opts.profiles):
+ in_profile = self._is_in_profile(plugin_class)
+ if not in_profile:
self._skip(plugin_class, _("excluded"))
continue
@@ -869,7 +873,7 @@ class SoSReport(object):
self._skip(plugin_class, _("not default"))
continue
- if self._is_not_specified(plugbase):
+ if self._is_not_specified(plugbase) and not in_profile:
self._skip(plugin_class, _("not specified"))
continue