aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2019-01-11 12:13:05 -0500
committerBryn M. Reeves <bmr@redhat.com>2019-03-19 19:01:17 +0000
commit9343fd7c640f6aa371aad2f0e7b0afccff0095cf (patch)
treede6a8685b8ef0839961179f2613a6399284d902e
parent16f0fed775da29506b5f6197e4a2644cd9ded84b (diff)
downloadsos-9343fd7c640f6aa371aad2f0e7b0afccff0095cf.tar.gz
[policy] Add a 'none' preset to Policy to override automatic presets
Adds a 'none' preset to the base Policy class that can be used to override any distro-specific presets that may be otherwise automatically loaded when a bare 'sosreport' is run due to the presence of certian packages. In other words, using '--preset=none' will cause sosreport to run identically to how sosreport ran before presets were introduced. Additionally this 'none' preset is now the default preset returned by the Policy class if probe_preset() is not overridden by individual policies. Resolves: #1537 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/policies/__init__.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index e3c1b60d..07c3f922 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -395,6 +395,16 @@ class PresetDefaults(object):
os.unlink(os.path.join(presets_path, self.name))
+NO_PRESET = 'none'
+NO_PRESET_DESC = 'Do not load a preset'
+NO_PRESET_NOTE = 'Use to disable automatically loaded presets'
+
+GENERIC_PRESETS = {
+ NO_PRESET: PresetDefaults(name=NO_PRESET, desc=NO_PRESET_DESC,
+ note=NO_PRESET_NOTE, opts=SoSOptions())
+ }
+
+
class Policy(object):
msg = _("""\
@@ -438,6 +448,7 @@ No changes will be made to system configuration.
self._valid_subclasses = []
self.set_exec_path()
self._host_sysroot = sysroot
+ self.register_presets(GENERIC_PRESETS)
def get_valid_subclasses(self):
return [IndependentPlugin] + self._valid_subclasses
@@ -720,7 +731,7 @@ No changes will be made to system configuration.
:returns: a ``PresetDefaults`` object.
"""
- return self.presets[""]
+ return self.presets[NO_PRESET]
def load_presets(self, presets_path=None):
"""Load presets from disk.