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

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 3194b8d789ecf6d6b9cd8cadfd962011fa5f6ea0)

src/mgr/BaseMgrModule.cc
src/pybind/mgr/ceph_module.pyi
src/pybind/mgr/mgr_module.py
src/pybind/mgr/tests/__init__.py

index 8bf924d6a12a4e3432930722cce927fd4f19b635..da8785eaa97d3f00e380ddd661f607158b318bd7 100644 (file)
@@ -601,6 +601,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)
 {
@@ -1418,6 +1424,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 701b1eaf1e5dc33765d420469d229f8c1f48140b..eee8fc346f9cc1b25fcfde092194df9faf35b115 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()