aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2018-05-27 09:17:03 +0100
committerBryn M. Reeves <bmr@redhat.com>2018-06-20 18:01:21 +0100
commit5ebe80605ead91b448a4731881d618ed334c6e77 (patch)
tree8faa539ad5653af21a003aa3c09675c977d005cf
parent6c7b540d72383d8669157a3726f1001777865723 (diff)
downloadsos-5ebe80605ead91b448a4731881d618ed334c6e77.tar.gz
[sosreport] add --list-presets
Add a command line option to list out presets and their options: Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/__init__.py7
-rw-r--r--sos/sosreport.py26
2 files changed, 30 insertions, 3 deletions
diff --git a/sos/__init__.py b/sos/__init__.py
index c7534034..96e77414 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py
@@ -45,9 +45,9 @@ _sos = _default
_arg_names = [
'all_logs', 'batch', 'build', 'case_id', 'chroot', 'compression_type',
'config_file', 'debug', 'enableplugins', 'experimental', 'label',
- 'list_plugins', 'list_profiles', 'log_size', 'noplugins', 'noreport',
- 'onlyplugins', 'plugopts', 'preset', 'profiles', 'quiet', 'sysroot',
- 'tmp_dir', 'usealloptions', 'verbosity', 'verify'
+ 'list_plugins', 'list_presets', 'list_profiles', 'log_size', 'noplugins',
+ 'noreport', 'onlyplugins', 'plugopts', 'preset', 'profiles', 'quiet',
+ 'sysroot', 'tmp_dir', 'usealloptions', 'verbosity', 'verify'
]
#: Arguments with non-zero default values
@@ -72,6 +72,7 @@ class SoSOptions(object):
experimental = False
label = ""
list_plugins = False
+ list_presets = False
list_profiles = False
log_size = _arg_defaults["log_size"]
noplugins = []
diff --git a/sos/sosreport.py b/sos/sosreport.py
index d4afebed..ec9ca5c0 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -257,6 +257,8 @@ def _parse_args(args):
parser.add_argument("-l", "--list-plugins", action="store_true",
dest="list_plugins", default=False,
help="list plugins and available plugin options")
+ parser.add_argument("--list-presets", action="store_true",
+ help="display a list of available presets")
parser.add_argument("--list-profiles", action="store_true",
dest="list_profiles", default=False,
help="display a list of available profiles and "
@@ -837,6 +839,27 @@ class SoSReport(object):
self.ui_log.info(" %s" % line)
self._report_profiles_and_plugins()
+ def list_presets(self):
+ if not self.policy.presets:
+ self.soslog.fatal(_("no valid presets found"))
+ return
+ self.ui_log.info(_("The following presets are available:"))
+ self.ui_log.info("")
+
+ for preset in self.policy.presets.keys():
+ if not preset:
+ continue
+ preset = self.policy.presets[preset]
+ self.ui_log.info("%-15s %s" % (preset.name, preset.desc))
+ if preset.note:
+ self.ui_log.info("%-15s (%s)" % ("", preset.note))
+ if self.opts.verbosity > 0:
+ opts = str(preset.opts).split()
+ lines = _format_list("%-15s" % "options: ", opts, indent=True)
+ for line in lines:
+ self.ui_log.info(line)
+ self.ui_log.info("")
+
def batch(self):
if self.opts.batch:
self.ui_log.info(self.policy.get_msg())
@@ -1334,6 +1357,9 @@ class SoSReport(object):
if self.opts.list_profiles:
self.list_profiles()
return True
+ if self.opts.list_presets:
+ self.list_presets()
+ return True
# verify that at least one plug-in is enabled
if not self.verify_plugins():