From: John Spray Date: Wed, 25 Apr 2018 09:53:22 +0000 (-0400) Subject: mgr: expose get_store into MgrStandbyModule X-Git-Tag: v13.1.0~25^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=37faa383156fd6f50d53fd381fffecc564cadb93;p=ceph.git mgr: expose get_store into MgrStandbyModule Signed-off-by: John Spray --- diff --git a/src/mgr/BaseMgrStandbyModule.cc b/src/mgr/BaseMgrStandbyModule.cc index b7bd0f663831..b6f6e53255d8 100644 --- a/src/mgr/BaseMgrStandbyModule.cc +++ b/src/mgr/BaseMgrStandbyModule.cc @@ -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"}, diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index a68d16571b94..b09dc965a100 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -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()