]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: expose get_store into MgrStandbyModule
authorJohn Spray <john.spray@redhat.com>
Wed, 25 Apr 2018 09:53:22 +0000 (05:53 -0400)
committerJohn Spray <john.spray@redhat.com>
Fri, 27 Apr 2018 13:58:46 +0000 (09:58 -0400)
Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/BaseMgrStandbyModule.cc
src/pybind/mgr/mgr_module.py

index b7bd0f66383164260111bfda451a094f00c4cd1d..b6f6e53255d8619b53e4fa2de7c737061cc8b645 100644 (file)
@@ -80,6 +80,26 @@ ceph_config_get(BaseMgrStandbyModule *self, PyObject *args)
   }
 }
 
+static PyObject*
+ceph_store_get(BaseMgrStandbyModule *self, PyObject *args)
+{
+  char *what = nullptr;
+  if (!PyArg_ParseTuple(args, "s:ceph_store_get", &what)) {
+    derr << "Invalid args!" << dendl;
+    return nullptr;
+  }
+
+  std::string value;
+  bool found = self->this_module->get_store(what, &value);
+  if (found) {
+    dout(10) << "ceph_store_get " << what << " found: " << value.c_str() << dendl;
+    return PyString_FromString(value.c_str());
+  } else {
+    dout(4) << "ceph_store_get " << what << " not found " << dendl;
+    Py_RETURN_NONE;
+  }
+}
+
 static PyObject*
 ceph_get_active_uri(BaseMgrStandbyModule *self, PyObject *args)
 {
@@ -110,6 +130,9 @@ PyMethodDef BaseMgrStandbyModule_methods[] = {
   {"_ceph_get_config", (PyCFunction)ceph_config_get, METH_VARARGS,
    "Get a configuration value"},
 
+  {"_ceph_get_store", (PyCFunction)ceph_store_get, METH_VARARGS,
+   "Get a KV store value"},
+
   {"_ceph_get_active_uri", (PyCFunction)ceph_get_active_uri, METH_NOARGS,
    "Get the URI of the active instance of this module, if any"},
 
index a68d16571b94193aa84df6f74bdc83acea885550..b09dc965a100e73edc585826e72c26b949520f54 100644 (file)
@@ -198,6 +198,14 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule):
         else:
             return r
 
+    def get_store(self, key):
+        """
+        Retrieve the value of a persistent KV store entry
+
+        :param key: String
+        :return: Byte string or None
+        """
+        return self._ceph_get_store(key)
 
     def get_active_uri(self):
         return self._ceph_get_active_uri()