]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/influx: use get_module_option() for typed option
authorKefu Chai <kchai@redhat.com>
Mon, 22 Feb 2021 05:57:55 +0000 (13:57 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 25 Feb 2021 07:54:12 +0000 (15:54 +0800)
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 <kchai@redhat.com>
src/pybind/mgr/influx/module.py

index 52179aac71856f9077366e6b04129f0edd9cc32a..c58d2d547d8365bcb0ce742d34db375fd092144b 100644 (file)
@@ -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)