aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2019-08-16 13:09:42 +0100
committerBryn M. Reeves <bmr@redhat.com>2019-08-16 14:17:37 +0100
commite758e9708aa8b204289a52f81749242b5524a8e6 (patch)
treebfacc642e5c4b9e92500d7af45ea9592aaf3e14a
parent856bddc6fe2f12a23e96401dd11247116a6d7a70 (diff)
downloadsos-e758e9708aa8b204289a52f81749242b5524a8e6.tar.gz
[Plugin] add generic log_skipped_command() handler
Add a generic method to Plugin to log the reason that a command was skipped during predicate evaluation. The method accepts bool arguments indicating whether the command relies on kmod or service presence checks, and a 'change' argument that indicates that it may alter system configuration (adn so can be collected if the user supplies --allow-system-changes). Related: #1678 Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index a6adc23f..9157fafb 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -426,6 +426,27 @@ class Plugin(object):
return bool(pred)
return False
+ def log_skipped_cmd(self, pred, cmd, kmods=False, services=False,
+ changes=False):
+ """Log that a command was skipped due to predicate evaluation.
+
+ Emit a warning message indicating that a command was skipped due
+ to predicate evaluation. If ``kmods`` or ``services`` are ``True``
+ then the list of expected kernel modules or services will be
+ included in the log message. If ``allow_changes`` is ``True`` a
+ message indicating that the missing data can be collected by using
+ the "--allow-system-changes" command line option will be included.
+ """
+ msg = ("skipped command '%s': required kernel modules or"
+ " services not present (%s).")
+
+ needs = "kmods=[%s] services=[%s]" % (",".join(pred.kmods),
+ ",".join(pred.services))
+ if changes:
+ msg += " Use '--allow-system-changes' to enable collection."
+
+ self._log_warn(msg % (cmd, needs))
+
def do_cmd_private_sub(self, cmd):
'''Remove certificate and key output archived by sosreport. cmd
is the command name from which output is collected (i.e. exlcuding