From: Sage Weil Date: Fri, 21 May 2021 22:49:58 +0000 (-0400) Subject: mgr: expose ceph.conf path to modules X-Git-Tag: v17.1.0~1845^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F41488%2Fhead;p=ceph.git mgr: expose ceph.conf path to modules This is useful for shelling back out to ceph utilities. Signed-off-by: Sage Weil --- diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 5acd93ed3bf..23395185397 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -599,6 +599,12 @@ ceph_get_version(BaseMgrModule *self, PyObject *args) return PyUnicode_FromString(pretty_version_to_str().c_str()); } +static PyObject * +ceph_get_ceph_conf_path(BaseMgrModule *self, PyObject *args) +{ + return PyUnicode_FromString(g_conf().get_conf_path().c_str()); +} + static PyObject * ceph_get_release_name(BaseMgrModule *self, PyObject *args) { @@ -1407,6 +1413,9 @@ PyMethodDef BaseMgrModule_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_ceph_conf_path", (PyCFunction)ceph_get_ceph_conf_path, METH_NOARGS, + "Get path to ceph.conf"}, + {"_ceph_get_option", (PyCFunction)ceph_option_get, METH_VARARGS, "Get a native configuration option value"}, diff --git a/src/pybind/mgr/ceph_module.pyi b/src/pybind/mgr/ceph_module.pyi index 19ad8a4f8a5..2a7f2d2711e 100644 --- a/src/pybind/mgr/ceph_module.pyi +++ b/src/pybind/mgr/ceph_module.pyi @@ -80,6 +80,7 @@ class BaseMgrModule(object): inbuf: Optional[str]) -> None: ... def _ceph_set_health_checks(self, checks: Mapping[str, HealthCheckT]) -> None: ... def _ceph_get_mgr_id(self) -> str: ... + def _ceph_get_ceph_conf_path(self) -> str: ... def _ceph_get_option(self, key: str) -> OptionValue: ... def _ceph_get_foreign_option(self, entity: str, key: str) -> OptionValue: ... def _ceph_get_module_option(self, diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 8c7e4710c64..07ed288199e 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -1369,6 +1369,9 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin): """ return self._ceph_get_mgr_id() + def get_ceph_conf_path(self) -> str: + return self._ceph_get_ceph_conf_path() + def get_ceph_option(self, key: str) -> OptionValue: return self._ceph_get_option(key) diff --git a/src/pybind/mgr/tests/__init__.py b/src/pybind/mgr/tests/__init__.py index 9d5e2dcabea..66c1cbc87b6 100644 --- a/src/pybind/mgr/tests/__init__.py +++ b/src/pybind/mgr/tests/__init__.py @@ -184,6 +184,7 @@ if 'UNITTEST' in os.environ: super(M, self).__init__() self._ceph_get_version = mock.Mock() + self._ceph_get_ceph_conf_path = mock.MagicMock() self._ceph_get_option = mock.MagicMock() self._ceph_get_context = mock.MagicMock() self._ceph_register_client = mock.MagicMock()