aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2023-11-30 17:37:28 +0100
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2023-12-05 20:49:24 -0500
commit1b2572fd17e2ba1ebb0341fd229d0337dfa40a60 (patch)
tree802f37aa464c7399d261432dee767f5c5a61d902
parentded03dcca086f47412d8cf882141b396a955666f (diff)
downloadsos-1b2572fd17e2ba1ebb0341fd229d0337dfa40a60.tar.gz
[report] Update preset opts already in SoSComponent
As SoSComponent already works with --tmp-dir and it can be declared in a preset, we need to move whole options evaluation from SoSReport to SoSComponent constructor. Resolves: #3425 Closes: #3432 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/component.py29
-rw-r--r--sos/report/__init__.py20
2 files changed, 26 insertions, 23 deletions
diff --git a/sos/component.py b/sos/component.py
index 8130e397..3a121469 100644
--- a/sos/component.py
+++ b/sos/component.py
@@ -85,6 +85,10 @@ class SoSComponent():
except Exception:
pass
+ self.opts = SoSOptions(arg_defaults=self._arg_defaults)
+ if self.load_policy:
+ self.load_local_policy()
+
# update args from component's arg_defaults definition
self._arg_defaults.update(self.arg_defaults)
self.opts = self.load_options() # lgtm [py/init-calls-subclass]
@@ -108,9 +112,6 @@ class SoSComponent():
self.tempfile_util = TempFileUtil(self.tmpdir)
self._setup_logging()
- if self.load_policy:
- self.load_local_policy()
-
if self.manifest is not None:
self.manifest.add_field('version', __version__)
self.manifest.add_field('cmdline', ' '.join(self.cmdline))
@@ -265,6 +266,28 @@ class SoSComponent():
opts = self.apply_options_from_cmdline(opts)
+ # user specified command line preset
+ self.preset = None
+ if hasattr(opts, 'preset'):
+ if opts.preset != self._arg_defaults["preset"]:
+ self.preset = self.policy.find_preset(opts.preset)
+ if not self.preset:
+ sys.stderr.write("Unknown preset: '%s'\n" % opts.preset)
+ self.preset = self.policy.probe_preset()
+ opts.list_presets = True
+
+ # --preset=auto
+ if not self.preset:
+ self.preset = self.policy.probe_preset()
+ # now merge preset options to opts
+ opts.merge(self.preset.opts)
+ # re-apply any cmdline overrides to the preset
+ opts = self.apply_options_from_cmdline(opts)
+
+ if hasattr(self.preset.opts, 'verbosity') and \
+ self.preset.opts.verbosity > 0:
+ self.set_loggers_verbosity(self.preset.opts.verbosity)
+
return opts
def cleanup(self):
diff --git a/sos/report/__init__.py b/sos/report/__init__.py
index d4ec9922..591782ee 100644
--- a/sos/report/__init__.py
+++ b/sos/report/__init__.py
@@ -142,7 +142,6 @@ class SoSReport(SoSComponent):
self.archive = None
self._args = args
self.sysroot = "/"
- self.preset = None
self.estimated_plugsizes = {}
self.print_header()
@@ -153,25 +152,6 @@ class SoSReport(SoSComponent):
# add a manifest section for report
self.report_md = self.manifest.components.add_section('report')
- # user specified command line preset
- if self.opts.preset != self.arg_defaults["preset"]:
- self.preset = self.policy.find_preset(self.opts.preset)
- if not self.preset:
- sys.stderr.write("Unknown preset: '%s'\n" % self.opts.preset)
- self.preset = self.policy.probe_preset()
- self.opts.list_presets = True
-
- # --preset=auto
- if not self.preset:
- self.preset = self.policy.probe_preset()
- # now merge preset options to self.opts
- self.opts.merge(self.preset.opts)
- # re-apply any cmdline overrides to the preset
- self.opts = self.apply_options_from_cmdline(self.opts)
- if hasattr(self.preset.opts, 'verbosity') and \
- self.preset.opts.verbosity > 0:
- self.set_loggers_verbosity(self.preset.opts.verbosity)
-
self._set_directories()
msg = "default"