]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
pybind/mgr: add get_ceph_option to standby module interface
authorSage Weil <sage@redhat.com>
Tue, 4 Dec 2018 23:35:49 +0000 (17:35 -0600)
committerSage Weil <sage@redhat.com>
Tue, 11 Dec 2018 09:54:52 +0000 (03:54 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/BaseMgrStandbyModule.cc
src/pybind/mgr/mgr_module.py

index 991cbf94ad6c60dbf4a78217d4a02a74f1feda4e..0f1725fe87677d7cbbbdfc26273be891288d55b4 100644 (file)
@@ -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"},
 
index 362c085fbd52f967df651089ba2f8f24e0e08b29..8808d7a9b8adf5be9bbd555c770e08df601d19a2 100644 (file)
@@ -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