]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: set/get_localized_config in MgrModule
authorWido den Hollander <wido@42on.com>
Fri, 30 Jun 2017 14:49:46 +0000 (16:49 +0200)
committerWido den Hollander <wido@42on.com>
Mon, 3 Jul 2017 12:47:23 +0000 (14:47 +0200)
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 <wido@42on.com>
src/pybind/mgr/dashboard/module.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/restful/module.py

index 362faddad11df865fbc1660373f1b90bbb3ccd29..02a1a75bd2a21da46b29e7db2f0a47295fed9180 100644 (file)
@@ -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']])
index e76aa04be8a487244bce772b1f908e1f2a9981c0..cf7fff949d744bf59b06a13e7169594a2918bfee 100644 (file)
@@ -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)
+
index 508bb7f5274fc1d49aa936ff70509010bceaf0ac..a2fef7a68981280d65805aab8e0cdaf34334fb09 100644 (file)
@@ -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 {}