aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2020-04-14 10:37:11 -0400
committerJake Hunsaker <jhunsake@redhat.com>2020-04-22 10:01:01 -0400
commit1c71c0e4fdb8b17c24e237749931f6ea6d2ca138 (patch)
tree03a3dde6420a4c27a64340d32e17fe58aedbb385
parent16f72a4cd80b38c72a843ff572694c0547ea84f5 (diff)
downloadsos-1c71c0e4fdb8b17c24e237749931f6ea6d2ca138.tar.gz
[collector] Actually validate cluster option values
At some point in the transition process, it seems we stopped calling `_validate_option()` on provided cluster options via the CLI. Fix that, so that we can be sure that clusters are getting the data types they expect for options they support. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/collector/__init__.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/sos/collector/__init__.py b/sos/collector/__init__.py
index 6d1d20a6..74116106 100644
--- a/sos/collector/__init__.py
+++ b/sos/collector/__init__.py
@@ -374,12 +374,13 @@ class SoSCollector(SoSComponent):
match = False
for clust in self.clusters:
for option in self.clusters[clust].options:
- if opt.name == option.name:
+ if opt.name == option.name and opt.cluster == clust:
match = True
+ opt.value = self._validate_option(option, opt)
break
if not match:
self.exit('Unknown cluster option provided: %s.%s'
- % (opt.cluster, opt.name))
+ % (opt.cluster, opt.name))
def _validate_option(self, default, cli):
"""Checks to make sure that the option given on the CLI is valid.
@@ -396,12 +397,12 @@ class SoSCollector(SoSComponent):
return cli.value
else:
val = cli.value.lower()
- if val not in ['true', 'on', 'false', 'off']:
+ if val not in ['true', 'on', 'yes', 'false', 'off', 'no']:
msg = ("Invalid value for %s. Accepted values are: 'true', "
- "'false', 'on', 'off'")
+ "'false', 'on', 'off', 'yes', 'no'.")
self.exit(msg % cli.name)
else:
- if val in ['true', 'on']:
+ if val in ['true', 'on', 'yes']:
return True
else:
return False
@@ -620,8 +621,8 @@ class SoSCollector(SoSComponent):
self.log_debug("Unable to determine local installation: %s" %
err)
self.exit('Unable to determine local installation. Use the '
- '--no-local option if localhost should not be '
- 'included.\nAborting...\n', 1)
+ '--no-local option if localhost should not be '
+ 'included.\nAborting...\n', 1)
if self.opts.cluster_type:
if self.opts.cluster_type == 'none':
@@ -662,7 +663,7 @@ class SoSCollector(SoSComponent):
if not self.node_list and not self.master.connected:
self.exit('No nodes were detected, or nodes do not have sos '
- 'installed.\nAborting...')
+ 'installed.\nAborting...')
self.ui_log.info('The following is a list of nodes to collect from:')
if self.master.connected: