The python module interface doesn't change (yet).
Signed-off-by: Sage Weil <sage@redhat.com>
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;
+ dout(4) << "ceph_option_get " << what << " not found " << dendl;
Py_RETURN_NONE;
}
}
static PyObject*
-ceph_config_get(BaseMgrModule *self, PyObject *args)
+ceph_get_module_option(BaseMgrModule *self, PyObject *args)
{
char *what = nullptr;
- if (!PyArg_ParseTuple(args, "s:ceph_config_get", &what)) {
+ if (!PyArg_ParseTuple(args, "s:ceph_get_module_option", &what)) {
derr << "Invalid args!" << dendl;
return nullptr;
}
bool found = self->py_modules->get_config(self->this_module->get_name(),
what, &value);
if (found) {
- dout(10) << "ceph_config_get " << what << " found: " << value.c_str() << dendl;
+ dout(10) << __func__ << " " << what << " found: " << value.c_str() << dendl;
return PyString_FromString(value.c_str());
} else {
- dout(4) << "ceph_config_get " << what << " not found " << dendl;
+ dout(4) << __func__ << " " << what << " not found " << dendl;
Py_RETURN_NONE;
}
}
"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"},
+ "Get a native configuration option value"},
- {"_ceph_get_config", (PyCFunction)ceph_config_get, METH_VARARGS,
- "Get a configuration value"},
+ {"_ceph_get_module_option", (PyCFunction)ceph_get_module_option, METH_VARARGS,
+ "Get a module configuration option value"},
{"_ceph_get_store_prefix", (PyCFunction)ceph_store_get_prefix, METH_VARARGS,
"Get all KV store values with a given prefix"},
}
static PyObject*
-ceph_config_get(BaseMgrStandbyModule *self, PyObject *args)
+ceph_get_module_option(BaseMgrStandbyModule *self, PyObject *args)
{
char *what = nullptr;
- if (!PyArg_ParseTuple(args, "s:ceph_config_get", &what)) {
+ if (!PyArg_ParseTuple(args, "s:ceph_get_module_option", &what)) {
derr << "Invalid args!" << dendl;
return nullptr;
}
std::string value;
bool found = self->this_module->get_config(what, &value);
if (found) {
- dout(10) << "ceph_config_get " << what << " found: " << value.c_str() << dendl;
+ dout(10) << __func__ << " " << what << " found: " << value.c_str() << dendl;
return PyString_FromString(value.c_str());
} else {
- dout(4) << "ceph_config_get " << what << " not found " << dendl;
+ dout(4) << __func__ << " " << what << " not found " << dendl;
Py_RETURN_NONE;
}
}
{"_ceph_get_mgr_id", (PyCFunction)ceph_get_mgr_id, METH_NOARGS,
"Get the name of the Mgr daemon where we are running"},
- {"_ceph_get_config", (PyCFunction)ceph_config_get, METH_VARARGS,
+ {"_ceph_get_module_option", (PyCFunction)ceph_get_module_option, METH_VARARGS,
"Get a configuration value"},
{"_ceph_get_store", (PyCFunction)ceph_store_get, METH_VARARGS,
:param default: the default value of the config if it is not found
:return: str
"""
- r = self._ceph_get_config(key)
+ r = self._ceph_get_module_option(key)
if r is None:
return default
else:
def get_option(self, key):
return self._ceph_get_option(key)
- def _validate_option(self, key):
+ def _validate_module_option(self, key):
"""
Helper: don't allow get/set config callers to
access config options that they didn't declare
raise RuntimeError("Config option '{0}' is not in {1}.MODULE_OPTIONS".\
format(key, self.__class__.__name__))
- def _get_config(self, key, default):
- r = self._ceph_get_config(key)
+ def _get_module_option(self, key, default):
+ r = self._ceph_get_module_option(key)
if r is None:
return default
else:
:param str key:
:return: str
"""
- self._validate_option(key)
- return self._get_config(key, default)
+ self._validate_module_option(key)
+ return self._get_module_option(key, default)
def get_store_prefix(self, key_prefix):
"""
:param str default:
:return: str
"""
- self._validate_option(key)
- return self._get_localized(key, default, self._get_config)
+ self._validate_module_option(key)
+ return self._get_localized(key, default, self._get_module_option)
def _set_config(self, key, val):
return self._ceph_set_config(key, val)
:param str key:
:param str val:
"""
- self._validate_option(key)
+ self._validate_module_option(key)
return self._set_config(key, val)
def set_localized_config(self, key, val):
:param str default:
:return: str
"""
- self._validate_option(key)
+ self._validate_module_option(key)
return self._set_localized(key, val, self._set_config)
def set_store(self, key, val):