From 56d26f0ef53d89de4bb651e45e2c2631e62f608f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 4 Dec 2018 17:22:23 -0600 Subject: [PATCH] mgr: rename internal get_config -> get_module_option The python module interface doesn't change (yet). Signed-off-by: Sage Weil --- src/mgr/BaseMgrModule.cc | 16 ++++++++-------- src/mgr/BaseMgrStandbyModule.cc | 10 +++++----- src/pybind/mgr/mgr_module.py | 20 ++++++++++---------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 7a86298c45e..2833e277662 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -380,16 +380,16 @@ ceph_option_get(BaseMgrModule *self, PyObject *args) 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; } @@ -398,10 +398,10 @@ ceph_config_get(BaseMgrModule *self, PyObject *args) 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; } } @@ -959,10 +959,10 @@ PyMethodDef BaseMgrModule_methods[] = { "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"}, diff --git a/src/mgr/BaseMgrStandbyModule.cc b/src/mgr/BaseMgrStandbyModule.cc index db980a2bcc5..088bb91838d 100644 --- a/src/mgr/BaseMgrStandbyModule.cc +++ b/src/mgr/BaseMgrStandbyModule.cc @@ -61,10 +61,10 @@ ceph_get_mgr_id(BaseMgrStandbyModule *self, PyObject *args) } 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; } @@ -72,10 +72,10 @@ ceph_config_get(BaseMgrStandbyModule *self, PyObject *args) 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; } } @@ -133,7 +133,7 @@ PyMethodDef BaseMgrStandbyModule_methods[] = { {"_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, diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 221a02d2346..c71e019bfea 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -240,7 +240,7 @@ class MgrStandbyModule(ceph_module.BaseMgrStandbyModule): :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: @@ -678,7 +678,7 @@ class MgrModule(ceph_module.BaseMgrModule): 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 @@ -688,8 +688,8 @@ class MgrModule(ceph_module.BaseMgrModule): 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: @@ -702,8 +702,8 @@ class MgrModule(ceph_module.BaseMgrModule): :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): """ @@ -732,8 +732,8 @@ class MgrModule(ceph_module.BaseMgrModule): :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) @@ -745,7 +745,7 @@ class MgrModule(ceph_module.BaseMgrModule): :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): @@ -755,7 +755,7 @@ class MgrModule(ceph_module.BaseMgrModule): :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): -- 2.39.5