Blame SOURCES/sos-bz1655984-lvmdump-am-ignored.patch

fce3c4
From 9db825247452d54152f1c866b6b90f897be32f15 Mon Sep 17 00:00:00 2001
fce3c4
From: "Bryn M. Reeves" <bmr@redhat.com>
fce3c4
Date: Wed, 12 Dec 2018 15:41:42 +0000
fce3c4
Subject: [PATCH] [Plugin] clean up Plugin.get_option()
fce3c4
fce3c4
There's a lot of ancient junk in this method (and associated code
fce3c4
strewn around sos.sosreport and tests). Remove the ability to pass
fce3c4
a list of options to the method since nothing uses this, and also
fce3c4
delete the incomplete implementation of global plugin options via
fce3c4
the commons dictionary (this work was already completed some time
fce3c4
ago by mapping these options directly to the command line args).
fce3c4
fce3c4
Resolves: #1498
fce3c4
fce3c4
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
fce3c4
---
fce3c4
 sos/plugins/__init__.py | 13 +------------
fce3c4
 sos/sosreport.py        |  5 -----
fce3c4
 tests/option_tests.py   | 16 ++++------------
fce3c4
 3 files changed, 5 insertions(+), 29 deletions(-)
fce3c4
fce3c4
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
fce3c4
index 3abe29db..c87ae19b 100644
fce3c4
--- a/sos/plugins/__init__.py
fce3c4
+++ b/sos/plugins/__init__.py
fce3c4
@@ -531,23 +531,12 @@ class Plugin(object):
fce3c4
         if optionname in global_options:
fce3c4
             return getattr(self.commons['cmdlineopts'], optionname)
fce3c4
 
fce3c4
-        def _check(key):
fce3c4
-            if hasattr(optionname, "__iter__"):
fce3c4
-                return key in optionname
fce3c4
-            else:
fce3c4
-                return key == optionname
fce3c4
-
fce3c4
         for name, parms in zip(self.opt_names, self.opt_parms):
fce3c4
-            if _check(name):
fce3c4
+            if name == optionname:
fce3c4
                 val = parms['enabled']
fce3c4
                 if val is not None:
fce3c4
                     return val
fce3c4
 
fce3c4
-        items = six.iteritems(self.commons.get('global_plugin_options', {}))
fce3c4
-        for key, value in items:
fce3c4
-            if _check(key):
fce3c4
-                return value
fce3c4
-
fce3c4
         return default
fce3c4
 
fce3c4
     def get_option_as_list(self, optionname, delimiter=",", default=None):
fce3c4
diff --git a/sos/sosreport.py b/sos/sosreport.py
fce3c4
index 77ae7161..97bee10c 100644
fce3c4
--- a/sos/sosreport.py
fce3c4
+++ b/sos/sosreport.py
fce3c4
@@ -336,7 +336,6 @@ class SoSReport(object):
fce3c4
         self.skipped_plugins = []
fce3c4
         self.all_options = []
fce3c4
         self.xml_report = XmlReport()
fce3c4
-        self.global_plugin_options = {}
fce3c4
         self.archive = None
fce3c4
         self.tempfile_util = None
fce3c4
         self._args = args
fce3c4
@@ -432,7 +431,6 @@ class SoSReport(object):
fce3c4
             'xmlreport': self.xml_report,
fce3c4
             'cmdlineopts': self.opts,
fce3c4
             'config': self.config,
fce3c4
-            'global_plugin_options': self.global_plugin_options,
fce3c4
         }
fce3c4
 
fce3c4
     def get_temp_file(self):
fce3c4
@@ -1426,9 +1424,6 @@ class SoSReport(object):
fce3c4
             return False
fce3c4
         return True
fce3c4
 
fce3c4
-    def set_global_plugin_option(self, key, value):
fce3c4
-        self.global_plugin_options[key] = value
fce3c4
-
fce3c4
     def _cleanup(self):
fce3c4
         # archive and tempfile cleanup may fail due to a fatal
fce3c4
         # OSError exception (ENOSPC, EROFS etc.).
fce3c4
diff --git a/tests/option_tests.py b/tests/option_tests.py
fce3c4
index a4267e2e..a99be4b0 100644
fce3c4
--- a/tests/option_tests.py
fce3c4
+++ b/tests/option_tests.py
fce3c4
@@ -12,27 +12,19 @@ class GlobalOptionTest(unittest.TestCase):
fce3c4
         self.commons = {
fce3c4
             'sysroot': '/',
fce3c4
             'policy': LinuxPolicy(),
fce3c4
-            'global_plugin_options': {
fce3c4
-                'test_option': 'foobar',
fce3c4
-                'baz': None,
fce3c4
-                'empty_global': True
fce3c4
-            },
fce3c4
         }
fce3c4
         self.plugin = Plugin(self.commons)
fce3c4
-        self.plugin.opt_names = ['baz', 'empty']
fce3c4
-        self.plugin.opt_parms = [{'enabled': False}, {'enabled': None}]
fce3c4
+        self.plugin.opt_names = ['baz', 'empty', 'test_option']
fce3c4
+        self.plugin.opt_parms = [
fce3c4
+            {'enabled': False}, {'enabled': None}, {'enabled': 'foobar'}
fce3c4
+        ]
fce3c4
 
fce3c4
     def test_simple_lookup(self):
fce3c4
         self.assertEquals(self.plugin.get_option('test_option'), 'foobar')
fce3c4
 
fce3c4
-    def test_multi_lookup(self):
fce3c4
-        self.assertEquals(self.plugin.get_option(('not_there', 'test_option')), 'foobar')
fce3c4
-
fce3c4
     def test_cascade(self):
fce3c4
         self.assertEquals(self.plugin.get_option(('baz')), False)
fce3c4
 
fce3c4
-    def test_none_should_cascade(self):
fce3c4
-        self.assertEquals(self.plugin.get_option(('empty', 'empty_global')), True)
fce3c4
 
fce3c4
 if __name__ == "__main__":
fce3c4
     unittest.main()
fce3c4
-- 
fce3c4
2.17.2
fce3c4