aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sos/__init__.py1
-rw-r--r--sos/policies/__init__.py11
-rw-r--r--sos/sosreport.py8
3 files changed, 17 insertions, 3 deletions
diff --git a/sos/__init__.py b/sos/__init__.py
index 315d6777..c7534034 100644
--- a/sos/__init__.py
+++ b/sos/__init__.py
@@ -55,6 +55,7 @@ _arg_defaults = {
"log_size": 10,
"chroot": "auto",
"compression_type": "auto",
+ "preset": "auto"
}
diff --git a/sos/policies/__init__.py b/sos/policies/__init__.py
index 2ad8b632..a5ba8109 100644
--- a/sos/policies/__init__.py
+++ b/sos/policies/__init__.py
@@ -517,7 +517,7 @@ No changes will be made to system configuration.
"""Find a preset profile matching the specified preset string.
:param preset: a string containing a preset profile name.
- :returns: a matching ProductProfile.
+ :returns: a matching PresetProfile.
"""
# FIXME: allow fuzzy matching?
for match in self.presets.keys():
@@ -527,6 +527,15 @@ No changes will be made to system configuration.
# Return default preset
return self.presets[""]
+ def probe_preset(self):
+ """Return a ``PresetDefaults`` object matching the runing host.
+
+ Stub method to be implemented by derived policy classes.
+
+ :returns: a ``PresetDefaults`` object.
+ """
+ return self.presets[""]
+
class GenericPolicy(Policy):
"""This Policy will be returned if no other policy can be loaded. This
diff --git a/sos/sosreport.py b/sos/sosreport.py
index b08baf77..d4afebed 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -274,7 +274,7 @@ def _parse_args(args):
dest="onlyplugins", type=str,
help="enable these plugins only", default=deque())
parser.add_argument("--preset", action="store", type=str,
- help="A preset identifier")
+ help="A preset identifier", default="auto")
parser.add_argument("-p", "--profile", action="extend",
dest="profiles", type=str, default=deque(),
help="enable plugins used by the given profiles")
@@ -343,7 +343,11 @@ class SoSReport(object):
self._is_root = self.policy.is_root()
- self.preset = self.policy.find_preset(cmd_args.preset)
+ # Apply per-preset command line defaults
+ if cmd_args.preset != _arg_defaults["preset"]:
+ self.preset = self.policy.find_preset(cmd_args.preset)
+ else:
+ self.preset = self.policy.probe_preset()
self.opts.merge(self.preset.opts)
# system temporary directory to use