]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/pybind: expose erasure code profiles
authorNoah Watkins <nwatkins@redhat.com>
Tue, 10 Jul 2018 21:09:44 +0000 (14:09 -0700)
committerNoah Watkins <nwatkins@redhat.com>
Thu, 12 Jul 2018 16:27:48 +0000 (09:27 -0700)
handles the insights cases that had been using Ceph CLI
`erasure-code-profile ls/get` to access the same data.

Signed-off-by: Noah Watkins <nwatkins@redhat.com>
src/mgr/ActivePyModules.cc
src/osd/OSDMap.cc
src/pybind/mgr/mgr_module.py
src/pybind/mgr/selftest/module.py

index 1c127cacd3cf57027ce5cbb1da5a18d78dd5f7df..4f05de756e5f89094cdb81ee7b46f649cf3dd26a 100644 (file)
@@ -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;
index 107e390710a49992d86932814e70bc7828604c3d..2111af663091d6112fe2ccf3fe672e983fb30ac2 100644 (file)
@@ -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<string,map<string,string>>& 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) {
index 629aee22ac2cb6fbda4dffc83bfdf5c81a7a4bf5..cca8eeffc276cf167add7500c8d2618d98d0187e 100644 (file)
@@ -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 <devid>.
+                health, mon_status, devices, device <devid>, ec_profiles.
 
         Note:
             All these structures have their own JSON representations: experiment
index e87bfcca395db5b519eddc3eb563ec6be3f01a46..0a08e3d87570a35a80af5add71b437ae65e09f59 100644 (file)
@@ -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)