diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 1c127cacd3c..4f05de756e5 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -362,6 +362,13 @@ PyObject *ActivePyModules::get_python(const std::string &what) mgr_map.dump(&f); }); return f.get(); + } else if (what == "ec_profiles") { + PyFormatter f; + cluster_state.with_osdmap([&f, &what](const OSDMap &osdmap){ + const auto &profiles = osdmap.get_erasure_code_profiles(); + osdmap.dump_erasure_code_profiles(profiles, &f); + }); + return f.get(); } else { derr << "Python module requested unknown data '" << what << "'" << dendl; Py_RETURN_NONE; diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 107e390710a..2111af66309 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1128,7 +1128,9 @@ void OSDMap::Incremental::dump(Formatter *f) const } f->close_section(); + f->open_object_section("erasure_code_profiles"); OSDMap::dump_erasure_code_profiles(new_erasure_code_profiles, f); + f->close_section(); f->open_array_section("old_erasure_code_profiles"); for (const auto &erasure_code_profile : old_erasure_code_profiles) { f->dump_string("old", erasure_code_profile.c_str()); @@ -3116,7 +3118,6 @@ void OSDMap::dump_erasure_code_profiles( const mempool::osdmap::map>& profiles, Formatter *f) { - f->open_object_section("erasure_code_profiles"); for (const auto &profile : profiles) { f->open_object_section(profile.first.c_str()); for (const auto &profm : profile.second) { @@ -3124,7 +3125,6 @@ void OSDMap::dump_erasure_code_profiles( } f->close_section(); } - f->close_section(); } void OSDMap::dump(Formatter *f) const @@ -3256,7 +3256,9 @@ void OSDMap::dump(Formatter *f) const } f->close_section(); + f->open_object_section("erasure_code_profiles"); dump_erasure_code_profiles(erasure_code_profiles, f); + f->close_section(); f->open_array_section("removed_snaps_queue"); for (auto& p : removed_snaps_queue) { diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 629aee22ac2..cca8eeffc27 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -345,7 +345,7 @@ class MgrModule(ceph_module.BaseMgrModule): :param str data_name: Valid things to fetch are osd_crush_map_text, osd_map, osd_map_tree, osd_map_crush, config, mon_map, fs_map, osd_metadata, pg_summary, io_rate, pg_dump, df, osd_stats, - health, mon_status, devices, device . + health, mon_status, devices, device , ec_profiles. Note: All these structures have their own JSON representations: experiment diff --git a/src/pybind/mgr/selftest/module.py b/src/pybind/mgr/selftest/module.py index e87bfcca395..0a08e3d8757 100644 --- a/src/pybind/mgr/selftest/module.py +++ b/src/pybind/mgr/selftest/module.py @@ -131,7 +131,8 @@ class Module(MgrModule): "osd_stats", "health", "mon_status", - "mgr_map" + "mgr_map", + "ec_profiles" ] for obj in objects: self.get(obj)