From 6ed5f5104260e20301b7598519cea18b2c91dfca Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Feb 2021 13:57:55 +0800 Subject: [PATCH] mgr/influx: use get_module_option() for typed option get_module_option() cast the option to the type claimed in its defition, also, the returned value are always validated before it is originally set. so there is no need to repeat this in mgr module. Signed-off-by: Kefu Chai --- src/pybind/mgr/influx/module.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 52179aac718..c58d2d547d8 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -264,30 +264,6 @@ class Module(MgrModule): } } - def set_config_option(self, option: str, value: str) -> None: - if option not in self.config_keys.keys(): - raise RuntimeError('{0} is a unknown configuration ' - 'option'.format(option)) - - if option in ['port', 'interval', 'threads', 'batch_size']: - try: - value = int(value) - except (ValueError, TypeError): - raise RuntimeError('invalid {0} configured. Please specify ' - 'a valid integer'.format(option)) - - if option == 'interval' and value < 5: - raise RuntimeError('interval should be set to at least 5 seconds') - - if option in ['ssl', 'verify_ssl']: - value = value.lower() == 'true' - - if option == 'threads': - if 1 > value > 32: - raise RuntimeError('threads should be in range 1-32') - - self.config[option] = value - def init_module_config(self) -> None: self.config['hostname'] = \ self.get_module_option("hostname", default=self.config_keys['hostname']) @@ -447,7 +423,7 @@ class Module(MgrModule): self.log.debug('Setting configuration option %s to %s', key, value) try: self.set_module_option(key, value) - self.set_config_option(key, value) + self.config[key] = self.get_module_option(key) return 0, 'Configuration option {0} updated'.format(key), '' except ValueError as e: return -errno.EINVAL, '', str(e) -- 2.39.5