From: John Spray Date: Thu, 22 Jun 2017 00:12:58 +0000 (-0400) Subject: mgr: expose a MgrMap in PyModules X-Git-Tag: v12.1.1~25^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=62935db879219be8c39f16b19beac919adc29463;p=ceph.git mgr: expose a MgrMap in PyModules Signed-off-by: John Spray --- diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 9c9ea5d82d30..aa4cc6a7f7b0 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -599,7 +599,9 @@ bool Mgr::got_mgr_map(const MgrMap& m) << dendl; return true; } + cluster_state.set_mgr_map(m); + return false; } diff --git a/src/mgr/Mgr.h b/src/mgr/Mgr.h index fd96a20b6be6..ccf22da9e7c4 100644 --- a/src/mgr/Mgr.h +++ b/src/mgr/Mgr.h @@ -29,6 +29,7 @@ #include "auth/Auth.h" #include "common/Finisher.h" #include "common/Timer.h" +#include "mon/MgrMap.h" #include "DaemonServer.h" #include "PyModules.h" diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 113dd665d9c4..8412e6cbf5ff 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -281,6 +281,12 @@ PyObject *PyModules::get_python(const std::string &what) } f.dump_string("json", json.to_str()); return f.get(); + } else if (what == "mgr_map") { + PyFormatter f; + cluster_state.with_mgrmap([&f](const MgrMap &mgr_map) { + mgr_map.dump(&f); + }); + return f.get(); } else { derr << "Python module requested unknown data '" << what << "'" << dendl; Py_RETURN_NONE; diff --git a/src/mgr/PyModules.h b/src/mgr/PyModules.h index 8e52e173062a..467555b51a1f 100644 --- a/src/mgr/PyModules.h +++ b/src/mgr/PyModules.h @@ -23,6 +23,7 @@ #include "osdc/Objecter.h" #include "client/Client.h" #include "common/LogClient.h" +#include "mon/MgrMap.h" #include "DaemonState.h" #include "ClusterState.h"