From 641d9e42ba14b3a27f9738abcda97a0f62764de2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 3 Dec 2018 14:22:18 -0600 Subject: [PATCH] pybind/mgr: OPTIONS -> MODULE_OPTIONS We want to distinguish between module options (mgr/$module/name) and compiled-in ceph options (common/options.cc). Signed-off-by: Sage Weil --- src/mgr/PyModule.cc | 8 ++++---- src/mgr/PyModule.h | 2 +- src/pybind/mgr/balancer/module.py | 2 +- src/pybind/mgr/dashboard/module.py | 4 ++-- src/pybind/mgr/deepsea/module.py | 4 ++-- src/pybind/mgr/devicehealth/module.py | 6 +++--- src/pybind/mgr/diskprediction_cloud/module.py | 8 ++++---- src/pybind/mgr/diskprediction_local/module.py | 8 ++++---- src/pybind/mgr/influx/module.py | 4 ++-- src/pybind/mgr/localpool/module.py | 2 +- src/pybind/mgr/mgr_module.py | 6 +++--- src/pybind/mgr/orchestrator_cli/module.py | 2 +- src/pybind/mgr/prometheus/module.py | 2 +- src/pybind/mgr/restful/module.py | 2 +- src/pybind/mgr/rook/module.py | 2 +- src/pybind/mgr/selftest/module.py | 2 +- src/pybind/mgr/telegraf/module.py | 4 ++-- src/pybind/mgr/telemetry/module.py | 4 ++-- src/pybind/mgr/zabbix/module.py | 4 ++-- 19 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index 9838bbff7c2..e2b855a2920 100644 --- a/src/mgr/PyModule.cc +++ b/src/mgr/PyModule.cc @@ -372,9 +372,9 @@ int PyModule::load(PyThreadState *pMainThreadState) r = load_options(); if (r != 0) { - derr << "Missing or invalid OPTIONS attribute in module '" + derr << "Missing or invalid MODULE_OPTIONS attribute in module '" << module_name << "'" << dendl; - error_string = "Missing or invalid OPTIONS attribute"; + error_string = "Missing or invalid MODULE_OPTIONS attribute"; return r; } @@ -514,13 +514,13 @@ int PyModule::load_commands() int PyModule::load_options() { - int r = walk_dict_list("OPTIONS", [this](PyObject *pOption) -> int { + int r = walk_dict_list("MODULE_OPTIONS", [this](PyObject *pOption) -> int { PyObject *pName = PyDict_GetItemString(pOption, "name"); ceph_assert(pName != nullptr); ModuleOption option; option.name = PyString_AsString(pName); - dout(20) << "loaded option " << option.name << dendl; + dout(20) << "loaded module option " << option.name << dendl; options[option.name] = std::move(option); diff --git a/src/mgr/PyModule.h b/src/mgr/PyModule.h index 84d3a6f62f0..fe4ba9fc37f 100644 --- a/src/mgr/PyModule.h +++ b/src/mgr/PyModule.h @@ -81,7 +81,7 @@ private: // Populated if loaded, can_run or failed indicates a problem std::string error_string; - // Helper for loading OPTIONS and COMMANDS members + // Helper for loading MODULE_OPTIONS and COMMANDS members int walk_dict_list( const std::string &attr_name, std::function fn); diff --git a/src/pybind/mgr/balancer/module.py b/src/pybind/mgr/balancer/module.py index 3d51aad7b95..77c1459755f 100644 --- a/src/pybind/mgr/balancer/module.py +++ b/src/pybind/mgr/balancer/module.py @@ -201,7 +201,7 @@ class Eval: return r class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'active'}, {'name': 'begin_time'}, {'name': 'crush_compat_max_iterations'}, diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 9558be86273..c7c9892e8cc 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -239,7 +239,7 @@ class Module(MgrModule, CherryPyConfig): COMMANDS.extend(ACCESS_CONTROL_COMMANDS) COMMANDS.extend(SSO_COMMANDS) - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'server_addr'}, {'name': 'server_port'}, {'name': 'jwt_token_ttl'}, @@ -250,7 +250,7 @@ class Module(MgrModule, CherryPyConfig): {'name': 'crt_file'}, {'name': 'ssl'} ] - OPTIONS.extend(options_schema_list()) + MODULE_OPTIONS.extend(options_schema_list()) def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) diff --git a/src/pybind/mgr/deepsea/module.py b/src/pybind/mgr/deepsea/module.py index ededbd8885b..d94ab86dfe5 100644 --- a/src/pybind/mgr/deepsea/module.py +++ b/src/pybind/mgr/deepsea/module.py @@ -44,7 +44,7 @@ class DeepSeaReadCompletion(orchestrator.ReadCompletion): class DeepSeaOrchestrator(MgrModule, orchestrator.Orchestrator): - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'salt_api_url', 'default': None @@ -81,7 +81,7 @@ class DeepSeaOrchestrator(MgrModule, orchestrator.Orchestrator): @property def config_keys(self): - return dict((o['name'], o.get('default', None)) for o in self.OPTIONS) + return dict((o['name'], o.get('default', None)) for o in self.MODULE_OPTIONS) def get_config(self, key, default=None): diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 3513cd5269b..215811a21f6 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -24,7 +24,7 @@ HEALTH_MESSAGES = { class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'enable_monitoring', 'default': str(False), @@ -113,7 +113,7 @@ class Module(MgrModule): super(Module, self).__init__(*args, **kwargs) # options - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], opt['default']) # other @@ -189,7 +189,7 @@ class Module(MgrModule): assert before != after def config_notify(self): - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], self.get_config(opt['name']) or opt['default']) diff --git a/src/pybind/mgr/diskprediction_cloud/module.py b/src/pybind/mgr/diskprediction_cloud/module.py index 885243ab75a..583f99b5fe2 100644 --- a/src/pybind/mgr/diskprediction_cloud/module.py +++ b/src/pybind/mgr/diskprediction_cloud/module.py @@ -36,7 +36,7 @@ def decode_string(value): class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'diskprediction_server', 'default': '' @@ -128,7 +128,7 @@ class Module(MgrModule): self._run = True def config_notify(self): - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], self.get_config(opt['name']) or opt['default']) @@ -140,7 +140,7 @@ class Module(MgrModule): @property def config_keys(self): - return dict((o['name'], o.get('default', None)) for o in self.OPTIONS) + return dict((o['name'], o.get('default', None)) for o in self.MODULE_OPTIONS) def set_config_option(self, option, value): if option not in self.config_keys.keys(): @@ -232,7 +232,7 @@ class Module(MgrModule): return 0, msg, '' def refresh_config(self): - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], self.get_config(opt['name']) or opt['default']) diff --git a/src/pybind/mgr/diskprediction_local/module.py b/src/pybind/mgr/diskprediction_local/module.py index 98a014209f0..17e3fc2cff3 100644 --- a/src/pybind/mgr/diskprediction_local/module.py +++ b/src/pybind/mgr/diskprediction_local/module.py @@ -16,7 +16,7 @@ TIME_WEEK = TIME_DAYS * 7 class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'sleep_interval', 'default': str(600), @@ -32,14 +32,14 @@ class Module(MgrModule): def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) # options - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], opt['default']) # other self._run = True self._event = Event() def config_notify(self): - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], self.get_config(opt['name']) or opt['default']) @@ -48,7 +48,7 @@ class Module(MgrModule): self._event.set() def refresh_config(self): - for opt in self.OPTIONS: + for opt in self.MODULE_OPTIONS: setattr(self, opt['name'], self.get_config(opt['name']) or opt['default']) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 6937cc9fc8c..a9db1a263d4 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -20,7 +20,7 @@ except ImportError: class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'hostname', 'default': None @@ -66,7 +66,7 @@ class Module(MgrModule): @property def config_keys(self): return dict((o['name'], o.get('default', None)) - for o in self.OPTIONS) + for o in self.MODULE_OPTIONS) COMMANDS = [ { diff --git a/src/pybind/mgr/localpool/module.py b/src/pybind/mgr/localpool/module.py index dd37e0adadb..ca556d68ac9 100644 --- a/src/pybind/mgr/localpool/module.py +++ b/src/pybind/mgr/localpool/module.py @@ -4,7 +4,7 @@ import threading class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'failure_domain'}, {'name': 'min_size'}, {'name': 'num_rep'}, diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 040833a6064..221a02d2346 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -269,7 +269,7 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule): class MgrModule(ceph_module.BaseMgrModule): COMMANDS = [] - OPTIONS = [] + MODULE_OPTIONS = [] # Priority definitions for perf counters PRIO_CRITICAL = 10 @@ -684,8 +684,8 @@ class MgrModule(ceph_module.BaseMgrModule): access config options that they didn't declare in their schema. """ - if key not in [o['name'] for o in self.OPTIONS]: - raise RuntimeError("Config option '{0}' is not in {1}.OPTIONS".\ + if key not in [o['name'] for o in self.MODULE_OPTIONS]: + raise RuntimeError("Config option '{0}' is not in {1}.MODULE_OPTIONS".\ format(key, self.__class__.__name__)) def _get_config(self, key, default): diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 756f9326366..a4e3675d7e7 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -10,7 +10,7 @@ class NoOrchestrator(Exception): class OrchestratorCli(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'orchestrator'} ] COMMANDS = [ diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 4806202ac30..44ad503d2d1 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -153,7 +153,7 @@ class Module(MgrModule): }, ] - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'server_addr'}, {'name': 'server_port'}, {'name': 'scrape_interval'}, diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 009425d2219..163f428ec16 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -199,7 +199,7 @@ class CommandsRequest(object): class Module(MgrModule): - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'server_addr'}, {'name': 'server_port'}, {'name': 'key_file'}, diff --git a/src/pybind/mgr/rook/module.py b/src/pybind/mgr/rook/module.py index d01576d21d1..0ed0f0936c5 100644 --- a/src/pybind/mgr/rook/module.py +++ b/src/pybind/mgr/rook/module.py @@ -128,7 +128,7 @@ def deferred_read(f): class RookOrchestrator(MgrModule, orchestrator.Orchestrator): - OPTIONS = [ + MODULE_OPTIONS = [ # TODO: configure k8s API addr instead of assuming local ] diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index 3e86774aa29..9635abeac58 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -28,7 +28,7 @@ class Module(MgrModule): # The test code in qa/ relies on these options existing -- they # are of course not really used for anything in the module - OPTIONS = [ + MODULE_OPTIONS = [ {'name': 'testkey'}, {'name': 'testlkey'}, {'name': 'testnewline'} diff --git a/src/pybind/mgr/telegraf/module.py b/src/pybind/mgr/telegraf/module.py index 4d0346ab68a..c0fb653c588 100644 --- a/src/pybind/mgr/telegraf/module.py +++ b/src/pybind/mgr/telegraf/module.py @@ -36,7 +36,7 @@ class Module(MgrModule): }, ] - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'address', 'default': 'unixgram:///tmp/telegraf.sock', @@ -51,7 +51,7 @@ class Module(MgrModule): @property def config_keys(self): - return dict((o['name'], o.get('default', None)) for o in self.OPTIONS) + return dict((o['name'], o.get('default', None)) for o in self.MODULE_OPTIONS) def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) diff --git a/src/pybind/mgr/telemetry/module.py b/src/pybind/mgr/telemetry/module.py index f331e182532..f648ae821bd 100644 --- a/src/pybind/mgr/telemetry/module.py +++ b/src/pybind/mgr/telemetry/module.py @@ -31,7 +31,7 @@ class Module(MgrModule): "distro" ] - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'url', 'default': 'https://telemetry.ceph.com/report' @@ -92,7 +92,7 @@ class Module(MgrModule): @property def config_keys(self): - return dict((o['name'], o.get('default', None)) for o in self.OPTIONS) + return dict((o['name'], o.get('default', None)) for o in self.MODULE_OPTIONS) def __init__(self, *args, **kwargs): super(Module, self).__init__(*args, **kwargs) diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index 27f7a5c3296..e9aa2cc1206 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -55,9 +55,9 @@ class Module(MgrModule): @property def config_keys(self): return dict((o['name'], o.get('default', None)) - for o in self.OPTIONS) + for o in self.MODULE_OPTIONS) - OPTIONS = [ + MODULE_OPTIONS = [ { 'name': 'zabbix_sender', 'default': '/usr/bin/zabbix_sender' -- 2.39.5