From: John Spray Date: Mon, 16 Apr 2018 16:10:13 +0000 (-0400) Subject: mgr: add MgrModule.OPTIONS definitions to modules X-Git-Tag: v13.1.0~143^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a5f71c59a5973c65586ee4da5d23eaf3cf8cc098;p=ceph.git mgr: add MgrModule.OPTIONS definitions to modules They need these to do upgrades properly. Where there was an existing structure describing config, merge these together to avoid having two lists of options. Signed-off-by: John Spray --- diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 289fc127d83b..91d6722968ae 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -201,6 +201,20 @@ class Eval: return r class Module(MgrModule): + OPTIONS = [ + {'name': 'active'}, + {'name': 'begin_time'}, + {'name': 'crush_compat_max_iteratons'}, + {'name': 'crush_compat_step'}, + {'name': 'end_time'}, + {'name': 'max_misplaced'}, + {'name': 'min_score'}, + {'name': 'mode'}, + {'name': 'sleep_interval'}, + {'name': 'upmap_max_iterations'}, + {'name': 'upmap_max_deviations'}, + ] + COMMANDS = [ { "cmd": "balancer status", diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 5bd0007af31d..67fcc20a510c 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -30,7 +30,8 @@ from .controllers import generate_routes, json_error_page from .controllers.auth import Auth from .tools import SessionExpireAtBrowserCloseTool, NotificationQueue, \ RequestLoggingTool, TaskManager -from .settings import options_command_list, handle_option_command +from .settings import options_command_list, options_schema_list, \ + handle_option_command # cherrypy likes to sys.exit on error. don't let it take us down too! @@ -73,6 +74,16 @@ class Module(MgrModule): ] COMMANDS.extend(options_command_list()) + OPTIONS = [ + {'name': 'server_addr'}, + {'name': 'server_port'}, + {'name': 'session-expire'}, + {'name': 'password'}, + {'name': 'url_prefix'}, + {'name': 'username'}, + ] + OPTIONS.extend(options_schema_list()) + @property def url_prefix(self): return self._url_prefix diff --git a/src/pybind/mgr/dashboard/settings.py b/src/pybind/mgr/dashboard/settings.py index bb5c3c613098..3875f268254a 100644 --- a/src/pybind/mgr/dashboard/settings.py +++ b/src/pybind/mgr/dashboard/settings.py @@ -102,6 +102,19 @@ def options_command_list(): return cmd_list +def options_schema_list(): + def filter_attr(member): + return not inspect.isroutine(member) + + result = [] + for option, value in inspect.getmembers(Options, filter_attr): + if option.startswith('_'): + continue + result.append({'name': option, 'default': value[0]}) + + return result + + def handle_option_command(cmd): if cmd['prefix'] not in _OPTIONS_COMMAND_MAP: return (-errno.ENOSYS, '', "Command not found '{}'".format(cmd['prefix'])) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index aea8b913e790..d24135aa3b9a 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -15,6 +15,46 @@ except ImportError: class Module(MgrModule): + OPTIONS = [ + { + 'name': 'hostname', + 'default': None + }, + { + 'name': 'port', + 'default': 8086 + }, + { + 'name': 'database', + 'default': 'ceph' + }, + { + 'name': 'username', + 'default': None + }, + { + 'name': 'password', + 'default': None + }, + { + 'name': 'interval', + 'default': 30 + }, + { + 'name': 'ssl', + 'default': 'false' + }, + { + 'name': 'verify_ssl', + 'default': 'true' + }, + ] + + @property + def config_keys(self): + return dict((o['name'], o.get('default', None)) + for o in self.OPTIONS) + COMMANDS = [ { "cmd": "influx config-set name=key,type=CephString " @@ -39,17 +79,6 @@ class Module(MgrModule): }, ] - config_keys = { - 'hostname': None, - 'port': 8086, - 'database': 'ceph', - 'username': None, - 'password': None, - 'interval': 30, - 'ssl': 'false', - 'verify_ssl': 'true' - } - def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) self.event = Event() diff --git a/src/pybind/mgr/localpool/module.py b/src/pybind/mgr/localpool/module.py index fac3d1c7f6c7..794c1dba3961 100644 --- a/src/pybind/mgr/localpool/module.py +++ b/src/pybind/mgr/localpool/module.py @@ -3,6 +3,16 @@ import json import threading class Module(MgrModule): + + OPTIONS = [ + {'name': 'failure_domain'}, + {'name': 'min_size'}, + {'name': 'num_rep'}, + {'name': 'pg_num'}, + {'name': 'prefix'}, + {'name': 'subtree'}, + ] + def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) self.serve_event = threading.Event() diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index c7daa128dd8a..4cdde9809d05 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -337,6 +337,11 @@ class Module(MgrModule): }, ] + OPTIONS = [ + {'name': 'server_addr'}, + {'name': 'server_port'}, + ] + def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) self.metrics = Metrics() diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index e1b76aa3c75e..8856987cd37a 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -203,6 +203,12 @@ class CommandsRequest(object): class Module(MgrModule): + OPTIONS = [ + {'name': 'server_addr'}, + {'name': 'server_port'}, + {'name': 'key_file'}, + ] + COMMANDS = [ { "cmd": "restful create-key name=key_name,type=CephString", diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index ae8f50c47d5c..dfc57ae5c2bf 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -25,6 +25,14 @@ class Module(MgrModule): WORKLOADS = (WORKLOAD_COMMAND_SPAM, WORKLOAD_THROW_EXCEPTION) + # The test code in qa/ relies on these options existing -- they + # are of course not really used for anything in the module + OPTIONS = [ + {'name': 'testkey'}, + {'name': 'testlkey'}, + {'name': 'testnewline'} + ] + COMMANDS = [ { "cmd": "mgr self-test run", diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index 128d45702200..df319f7b05ca 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -52,13 +52,33 @@ class Module(MgrModule): config = dict() ceph_health_mapping = {'HEALTH_OK': 0, 'HEALTH_WARN': 1, 'HEALTH_ERR': 2} - config_keys = { - 'zabbix_sender': '/usr/bin/zabbix_sender', - 'zabbix_host': None, - 'zabbix_port': 10051, - 'identifier': "", - 'interval': 60 - } + @property + def config_keys(self): + return dict((o['name'], o.get('default', None)) + for o in self.OPTIONS) + + OPTIONS = [ + { + 'name': 'zabbix_sender', + 'default': '/usr/bin/zabbix_sender' + }, + { + 'name': 'zabbix_host', + 'default': None + }, + { + 'name': 'zabbix_port', + 'default': 10051 + }, + { + 'name': 'identifier', + 'default': "" + }, + { + 'name': 'interval', + 'default': 60 + } + ] COMMANDS = [ {