From 62935db879219be8c39f16b19beac919adc29463 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 21 Jun 2017 20:12:58 -0400 Subject: [PATCH] mgr: expose a MgrMap in PyModules Signed-off-by: John Spray --- src/mgr/Mgr.cc | 2 ++ src/mgr/Mgr.h | 1 + src/mgr/PyModules.cc | 6 ++++++ src/mgr/PyModules.h | 1 + 4 files changed, 10 insertions(+) diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 9c9ea5d82d3..aa4cc6a7f7b 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 fd96a20b6be..ccf22da9e7c 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 113dd665d9c..8412e6cbf5f 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 8e52e173062..467555b51a1 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" -- 2.39.5