return PyString_FromString(g_conf()->name.get_id().c_str());
}
+static PyObject*
+ceph_option_get(BaseMgrModule *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_config_get " << what << " not found " << dendl;
+ Py_RETURN_NONE;
+ }
+}
+
static PyObject*
ceph_config_get(BaseMgrModule *self, PyObject *args)
{
{"_ceph_get_mgr_id", (PyCFunction)ceph_get_mgr_id, METH_NOARGS,
"Get the name of the Mgr daemon where we are running"},
+ {"_ceph_get_option", (PyCFunction)ceph_option_get, METH_VARARGS,
+ "Get a configuration option value"},
+
{"_ceph_get_config", (PyCFunction)ceph_config_get, METH_VARARGS,
"Get a configuration value"},
"""
return self._ceph_get_mgr_id()
+ def get_option(self, key):
+ return self._ceph_get_option(key)
+
def _validate_option(self, key):
"""
Helper: don't allow get/set config callers to