aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2014-07-07 20:24:12 +0100
committerBryn M. Reeves <bmr@redhat.com>2014-07-07 20:24:39 +0100
commit9b3a1a2788ce36f8f008aa7abcf88cc87b067ea2 (patch)
tree55eba82166dd671708a9e188bc10af40eca90bd7
parent9969aa0722c2cef0393c9520aa6690bfc03c16cf (diff)
downloadsos-9b3a1a2788ce36f8f008aa7abcf88cc87b067ea2.tar.gz
[plugin] implement global --verify option
Introduce a mechanism to allow plugins selective access to global command line options via the standard Plugin.get_option() method. Use this to implement a global --verify that plugins can test to determine whether or not to execute potentially costly verify operations. Related: #304. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py5
-rw-r--r--sos/sosreport.py17
2 files changed, 22 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 12b5c70b..b3a2ebac 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -367,6 +367,11 @@ class Plugin(object):
matches any of the option names is returned.
"""
+ global_options = ('verify',)
+
+ if optionname in global_options:
+ return getattr(self.commons['cmdlineopts'], optionname)
+
def _check(key):
if hasattr(optionname, "__iter__"):
return key in optionname
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 42a5f11e..7ee09292 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -208,6 +208,7 @@ class SoSOptions(object):
_batch = False
_build = False
_verbosity = 0
+ _verify = False
_quiet = False
_debug = False
_ticket_number = ""
@@ -342,6 +343,19 @@ class SoSOptions(object):
self._verbosity = value
@property
+ def verify(self):
+ if self._options != None:
+ return self._options.verify
+ return self._verify
+
+ @verify.setter
+ def verify(self, value):
+ self._check_options_initialized()
+ if value < 0 or value > 3:
+ raise ValueError("SoSOptions.verify expects a value [0..3]")
+ self._verify = value
+
+ @property
def quiet(self):
if self._options != None:
return self._options.quiet
@@ -467,6 +481,9 @@ class SoSOptions(object):
parser.add_option("-v", "--verbose", action="count",
dest="verbosity",
help="increase verbosity")
+ parser.add_option("", "--verify", action="store_true",
+ dest="verify", default=False,
+ help="perform data verification during collection")
parser.add_option("", "--quiet", action="store_true",
dest="quiet", default=False,
help="only print fatal errors")