From: Wido den Hollander Date: Fri, 30 Jun 2017 14:49:46 +0000 (+0200) Subject: mgr: set/get_localized_config in MgrModule X-Git-Tag: v12.1.1~156^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=43380f8d98168bb3b2770275fb47084606e3be3d;p=ceph.git mgr: set/get_localized_config in MgrModule get_localized_config was getting redundant as it was copied to various modules. This commit also introduces set_localized_config() which set a localized configuration option for a module. Signed-off-by: Wido den Hollander --- diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 362faddad11d..02a1a75bd2a2 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -103,12 +103,6 @@ class Module(MgrModule): return self._rados - def get_localized_config(self, key): - r = self.get_config(self.get_mgr_id() + '/' + key) - if r is None: - r = self.get_config(key) - return r - def update_pool_stats(self): df = global_instance().get("df") pool_stats = dict([(p['id'], p['stats']) for p in df['pools']]) diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index e76aa04be8a4..cf7fff949d74 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -191,6 +191,21 @@ class MgrModule(object): """ return ceph_state.get_config_prefix(self._handle, key_prefix) + def get_localized_config(self, key, default=None): + """ + Retrieve localized configuration for this ceph-mgr instance + :param key: str + :param default: str + :return: str + """ + r = self.get_config(self.get_mgr_id() + '/' + key) + if r is None: + r = self.get_config(key) + + if r is None: + r = default + return r + def set_config(self, key, val): """ Set the value of a persistent configuration setting @@ -200,6 +215,15 @@ class MgrModule(object): """ ceph_state.set_config(self._handle, key, val) + def set_localized_config(self, key, val): + """ + Set localized configuration for this ceph-mgr instance + :param key: str + :param default: str + :return: str + """ + return self.set_config(self.get_mgr_id() + '/' + key, val) + def set_config_json(self, key, val): """ Helper for setting json-serialized-config @@ -221,3 +245,4 @@ class MgrModule(object): return None else: return json.loads(raw) + diff --git a/src/pybind/mgr/restful/module.py b/src/pybind/mgr/restful/module.py index 508bb7f5274f..a2fef7a68981 100644 --- a/src/pybind/mgr/restful/module.py +++ b/src/pybind/mgr/restful/module.py @@ -254,12 +254,6 @@ class Module(MgrModule): self.serve_event.wait() self.serve_event.clear() - def get_localized_config(self, key): - r = self.get_config(self.get_mgr_id() + '/' + key) - if r is None: - r = self.get_config(key) - return r - def refresh_keys(self): self.keys = {} rawkeys = self.get_config_prefix('keys/') or {}