From 00d12ad3cf24dcc6c73e9bcf63db1d3f17e58bb1 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Thu, 1 Jul 2021 10:50:54 -0400 Subject: [PATCH] [sosnode] Properly format skip-commands and skip-files on nodes Fixes an issue where options provided for `skip-commands` and `skip-files` were not properly formatted, thus causing an exception during the finalization of the node's sos command. Signed-off-by: Jake Hunsaker --- sos/collector/sosnode.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py index 6597d236..426edcba 100644 --- a/sos/collector/sosnode.py +++ b/sos/collector/sosnode.py @@ -734,11 +734,12 @@ class SosNode(): if self.check_sos_version('4.1'): if self.opts.skip_commands: sos_opts.append( - '--skip-commands=%s' % (quote(self.opts.skip_commands)) + '--skip-commands=%s' % ( + quote(','.join(self.opts.skip_commands))) ) if self.opts.skip_files: sos_opts.append( - '--skip-files=%s' % (quote(self.opts.skip_files)) + '--skip-files=%s' % (quote(','.join(self.opts.skip_files))) ) if self.check_sos_version('4.2'): -- 2.31.1 From de7edce3f92ed50abcb28dd0dbcbeb104dc7c679 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Fri, 2 Jul 2021 09:52:11 +0200 Subject: [PATCH] [collector] fix a typo in --plugin-option Sos report uses --plugin-option or --plugopts. Relevant: #2606 Signed-off-by: Pavel Moravec --- sos/collector/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 6d96d692..f072287e 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -272,7 +272,7 @@ class SoSCollector(SoSComponent): help="chroot executed commands to SYSROOT") sos_grp.add_argument('-e', '--enable-plugins', action="extend", help='Enable specific plugins for sosreport') - sos_grp.add_argument('-k', '--plugin-options', action="extend", + sos_grp.add_argument('-k', '--plugin-option', action="extend", help='Plugin option as plugname.option=value') sos_grp.add_argument('--log-size', default=0, type=int, help='Limit the size of individual logs (in MiB)') -- 2.31.1 From 24a79ae8df8f29276f6139c68d4ba9b05114f951 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Fri, 2 Jul 2021 09:53:47 +0200 Subject: [PATCH] [options] allow variant option names in config file While cmdline allows --plugin-option as well as --plugopts, it stores the value under `plugopts` key. Therefore parsing config file ignores --plugin-option. Similarly for --name/--label and --profile/--profiles. When processing config file, we must unify those potentially duplicit keys. Resolves: #2606 Signed-off-by: Pavel Moravec --- sos/options.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sos/options.py b/sos/options.py index 1eda55d6..a014a022 100644 --- a/sos/options.py +++ b/sos/options.py @@ -186,9 +186,18 @@ class SoSOptions(): if 'verbose' in odict.keys(): odict['verbosity'] = int(odict.pop('verbose')) # convert options names + # unify some of them if multiple variants of the + # cmdoption exist + rename_opts = { + 'name': 'label', + 'plugin_option': 'plugopts', + 'profile': 'profiles' + } for key in list(odict): if '-' in key: odict[key.replace('-', '_')] = odict.pop(key) + if key in rename_opts: + odict[rename_opts[key]] = odict.pop(key) # set the values according to the config file for key, val in odict.items(): if isinstance(val, str): -- 2.31.1 From c7d3644c0c64e9e5439806250592a55c8e2de26f Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Thu, 1 Jul 2021 08:11:15 +0200 Subject: [PATCH] [report,collect] unify --map-file arguments Unify --map[-file] argument among report/collect/clean. Resolves: #2602 Signed-off-by: Pavel Moravec --- sos/cleaner/__init__.py | 2 +- sos/collector/__init__.py | 2 +- sos/report/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py index 7414b55e0..4c9837826 100644 --- a/sos/cleaner/__init__.py +++ b/sos/cleaner/__init__.py @@ -192,7 +192,7 @@ def add_parser_options(cls, parser): 'file for obfuscation')) clean_grp.add_argument('--no-update', dest='no_update', default=False, action='store_true', - help='Do not update the --map file with new ' + help='Do not update the --map-file with new ' 'mappings from this run') clean_grp.add_argument('--keep-binary-files', default=False, action='store_true', diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 7b8cfcf72..6d96d6923 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -427,7 +427,7 @@ def add_parser_options(cls, parser): cleaner_grp.add_argument('--no-update', action='store_true', default=False, dest='no_update', help='Do not update the default cleaner map') - cleaner_grp.add_argument('--map', dest='map_file', + cleaner_grp.add_argument('--map-file', dest='map_file', default='/etc/sos/cleaner/default_mapping', help=('Provide a previously generated mapping' ' file for obfuscation')) diff --git a/sos/report/__init__.py b/sos/report/__init__.py index 7ad2d24a4..411c4eb03 100644 --- a/sos/report/__init__.py +++ b/sos/report/__init__.py @@ -341,7 +341,7 @@ def add_parser_options(cls, parser): cleaner_grp.add_argument('--no-update', action='store_true', default=False, dest='no_update', help='Do not update the default cleaner map') - cleaner_grp.add_argument('--map', dest='map_file', + cleaner_grp.add_argument('--map-file', dest='map_file', default='/etc/sos/cleaner/default_mapping', help=('Provide a previously generated mapping' ' file for obfuscation')) From fd75745e7a5a6c5def8e6d23190227872b9912c3 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Wed, 11 Aug 2021 10:48:41 -0400 Subject: [PATCH] [sosnode] Fix passing of plugin options when using `--only-plugins` Fixes the handling of plugin options passed by `sos collect` to each node by first aligning the SoSOption name to those of `report` (`plugopts`), and second re-arranges the handling of plugin options and preset options passed by the user when also using `--only-plugins` so that the former are preserved and passed only with the `--only-plugins` option value. Resolves: #2641 Signed-off-by: Jake Hunsaker --- sos/collector/__init__.py | 5 +++-- sos/collector/sosnode.py | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py index 57ef074e..70b7a69e 100644 --- a/sos/collector/__init__.py +++ b/sos/collector/__init__.py @@ -84,7 +84,7 @@ class SoSCollector(SoSComponent): 'only_plugins': [], 'password': False, 'password_per_node': False, - 'plugin_options': [], + 'plugopts': [], 'plugin_timeout': None, 'cmd_timeout': None, 'preset': '', @@ -273,7 +273,8 @@ class SoSCollector(SoSComponent): help="chroot executed commands to SYSROOT") sos_grp.add_argument('-e', '--enable-plugins', action="extend", help='Enable specific plugins for sosreport') - sos_grp.add_argument('-k', '--plugin-option', action="extend", + sos_grp.add_argument('-k', '--plugin-option', '--plugopts', + action="extend", dest='plugopts', help='Plugin option as plugname.option=value') sos_grp.add_argument('--log-size', default=0, type=int, help='Limit the size of individual logs (in MiB)') diff --git a/sos/collector/sosnode.py b/sos/collector/sosnode.py index 426edcba..5d05c297 100644 --- a/sos/collector/sosnode.py +++ b/sos/collector/sosnode.py @@ -667,10 +667,10 @@ class SosNode(): if self.cluster.sos_plugin_options: for opt in self.cluster.sos_plugin_options: - if not any(opt in o for o in self.plugin_options): + if not any(opt in o for o in self.plugopts): option = '%s=%s' % (opt, self.cluster.sos_plugin_options[opt]) - self.plugin_options.append(option) + self.plugopts.append(option) # set master-only options if self.cluster.check_node_is_master(self): @@ -688,7 +688,7 @@ class SosNode(): self.only_plugins = list(self.opts.only_plugins) self.skip_plugins = list(self.opts.skip_plugins) self.enable_plugins = list(self.opts.enable_plugins) - self.plugin_options = list(self.opts.plugin_options) + self.plugopts = list(self.opts.plugopts) self.preset = list(self.opts.preset) def finalize_sos_cmd(self): @@ -754,6 +754,20 @@ class SosNode(): os.path.join(self.host.sos_bin_path, self.sos_bin) ) + if self.plugopts: + opts = [o for o in self.plugopts + if self._plugin_exists(o.split('.')[0]) + and self._plugin_option_exists(o.split('=')[0])] + if opts: + sos_opts.append('-k %s' % quote(','.join(o for o in opts))) + + if self.preset: + if self._preset_exists(self.preset): + sos_opts.append('--preset=%s' % quote(self.preset)) + else: + self.log_debug('Requested to enable preset %s but preset does ' + 'not exist on node' % self.preset) + if self.only_plugins: plugs = [o for o in self.only_plugins if self._plugin_exists(o)] if len(plugs) != len(self.only_plugins): @@ -792,20 +806,6 @@ class SosNode(): if enable: sos_opts.append('--enable-plugins=%s' % quote(enable)) - if self.plugin_options: - opts = [o for o in self.plugin_options - if self._plugin_exists(o.split('.')[0]) - and self._plugin_option_exists(o.split('=')[0])] - if opts: - sos_opts.append('-k %s' % quote(','.join(o for o in opts))) - - if self.preset: - if self._preset_exists(self.preset): - sos_opts.append('--preset=%s' % quote(self.preset)) - else: - self.log_debug('Requested to enable preset %s but preset does ' - 'not exist on node' % self.preset) - self.sos_cmd = "%s %s" % (sos_cmd, ' '.join(sos_opts)) self.log_info('Final sos command set to %s' % self.sos_cmd) self.manifest.add_field('final_sos_command', self.sos_cmd) -- 2.31.1