]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: expose ceph.conf path to modules 41488/head
authorSage Weil <sage@newdream.net>
Fri, 21 May 2021 22:49:58 +0000 (18:49 -0400)
committerSage Weil <sage@newdream.net>
Fri, 21 May 2021 22:52:09 +0000 (18:52 -0400)
This is useful for shelling back out to ceph utilities.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mgr/BaseMgrModule.cc
src/pybind/mgr/ceph_module.pyi
src/pybind/mgr/mgr_module.py
src/pybind/mgr/tests/__init__.py

index 5acd93ed3bf49688fd711aa2da56343f3c7724b6..233951853971ed11fec00bf3afe92bf87d151353 100644 (file)
@@ -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"},
 
index 19ad8a4f8a54c0a605fddb823f3019893173c302..2a7f2d2711e5c06403c88ea4a6cd08f918af8b8e 100644 (file)
@@ -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,
index 8c7e4710c64f01161871fef4d76165a51afe947c..07ed288199eaaec4bd06812b540989f11522b846 100644 (file)
@@ -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)
 
index 9d5e2dcabea7335233861b7b10b62316d07c27ef..66c1cbc87b698cdf6fd1122f0756fe7a0d262801 100644 (file)
@@ -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()