From 94bfbed7651edf8252ea4bbc020d58800ac3afea Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Dec 2018 17:35:49 -0600 Subject: [PATCH] pybind/mgr: add get_ceph_option to standby module interface Signed-off-by: Sage Weil --- src/mgr/BaseMgrStandbyModule.cc | 23 +++++++++++++++++++++++ src/pybind/mgr/mgr_module.py | 3 +++ 2 files changed, 26 insertions(+) diff --git a/src/mgr/BaseMgrStandbyModule.cc b/src/mgr/BaseMgrStandbyModule.cc index 991cbf94ad6..0f1725fe876 100644 --- a/src/mgr/BaseMgrStandbyModule.cc +++ b/src/mgr/BaseMgrStandbyModule.cc @@ -80,6 +80,26 @@ ceph_get_module_option(BaseMgrStandbyModule *self, PyObject *args) } } +static PyObject* +ceph_option_get(BaseMgrStandbyModule *self, PyObject *args) +{ + char *what = nullptr; + if (!PyArg_ParseTuple(args, "s:ceph_option_get", &what)) { + derr << "Invalid args!" << dendl; + return nullptr; + } + + std::string value; + int r = g_conf().get_val(string(what), &value); + if (r >= 0) { + dout(10) << "ceph_option_get " << what << " found: " << value << dendl; + return PyString_FromString(value.c_str()); + } else { + dout(4) << "ceph_option_get " << what << " not found " << dendl; + Py_RETURN_NONE; + } +} + static PyObject* ceph_store_get(BaseMgrStandbyModule *self, PyObject *args) { @@ -136,6 +156,9 @@ PyMethodDef BaseMgrStandbyModule_methods[] = { {"_ceph_get_module_option", (PyCFunction)ceph_get_module_option, METH_VARARGS, "Get a module configuration option value"}, + {"_ceph_get_option", (PyCFunction)ceph_option_get, METH_VARARGS, + "Get a native configuration option value"}, + {"_ceph_get_store", (PyCFunction)ceph_store_get, METH_VARARGS, "Get a KV store value"}, diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 362c085fbd5..8808d7a9b8a 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -246,6 +246,9 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule): else: return r + def get_ceph_option(self, key): + return self._ceph_get_option(key) + def get_store(self, key): """ Retrieve the value of a persistent KV store entry -- 2.39.5