]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/tools/ceph_monstore_tool.cc
update sources to v12.2.3
[ceph.git] / ceph / src / tools / ceph_monstore_tool.cc
index bf607ffa9c415f44151874c6e88f99689f533f77..4d6a8bdb7323011fb0d4a925abf313f7450075c7 100644 (file)
@@ -29,7 +29,8 @@
 #include "mon/MonitorDBStore.h"
 #include "mon/Paxos.h"
 #include "mon/MonMap.h"
-#include "mds/MDSMap.h"
+#include "mds/FSMap.h"
+#include "mon/MgrMap.h"
 #include "osd/OSDMap.h"
 #include "crush/CrushCompiler.h"
 
@@ -203,6 +204,8 @@ void usage(const char *n, po::options_description &d)
   << "                                  (default: last committed)\n"
   << "  get mdsmap [-- options]         get mdsmap (version VER if specified)\n"
   << "                                  (default: last committed)\n"
+  << "  get mgr [-- options]            get mgr map (version VER if specified)\n"
+  << "                                  (default: last committed)\n"
   << "  get crushmap [-- options]       get crushmap (version VER if specified)\n"
   << "                                  (default: last committed)\n"
   << "  show-versions [-- options]      show the first&last committed version of map\n"
@@ -589,6 +592,9 @@ static int update_monitor(MonitorDBStore& st)
   return 0;
 }
 
+// rebuild
+//  - mgr
+//  - mgr_command_desc
 static int update_mgrmap(MonitorDBStore& st)
 {
   auto t = make_shared<MonitorDBStore::Transaction>();
@@ -729,6 +735,9 @@ int rebuild_monstore(const char* progname,
   if ((r = update_pgmap_meta(st))) {
     return r;
   }
+  if ((r = update_mgrmap(st))) {
+    return r;
+  }
   if ((r = update_paxos(st))) {
     return r;
   }
@@ -738,9 +747,6 @@ int rebuild_monstore(const char* progname,
   if ((r = update_monitor(st))) {
     return r;
   }
-  if ((r = update_mgrmap(st))) {
-    return r;
-  }
   return 0;
 }
 
@@ -949,28 +955,42 @@ int main(int argc, char **argv) {
     if (readable) {
       stringstream ss;
       bufferlist out;
-      if (map_type == "monmap") {
-        MonMap monmap;
-        monmap.decode(bl);
-        monmap.print(ss);
-      } else if (map_type == "osdmap") {
-        OSDMap osdmap;
-        osdmap.decode(bl);
-        osdmap.print(ss);
-      } else if (map_type == "mdsmap") {
-        MDSMap mdsmap;
-        mdsmap.decode(bl);
-        mdsmap.print(ss);
-      } else if (map_type == "crushmap") {
-        CrushWrapper cw;
-        bufferlist::iterator it = bl.begin();
-        cw.decode(it);
-        CrushCompiler cc(cw, std::cerr, 0);
-        cc.decompile(ss);
-      } else {
-        std::cerr << "This type of readable map does not exist: " << map_type << std::endl
-                  << "You can only specify[osdmap|monmap|mdsmap|crushmap]" << std::endl;
+      try {
+        if (map_type == "monmap") {
+          MonMap monmap;
+          monmap.decode(bl);
+          monmap.print(ss);
+        } else if (map_type == "osdmap") {
+          OSDMap osdmap;
+          osdmap.decode(bl);
+          osdmap.print(ss);
+        } else if (map_type == "mdsmap") {
+          FSMap fs_map;
+          fs_map.decode(bl);
+          fs_map.print(ss);
+        } else if (map_type == "mgr") {
+          MgrMap mgr_map;
+          auto p = bl.begin();
+          mgr_map.decode(p);
+          JSONFormatter f;
+          f.dump_object("mgrmap", mgr_map);
+          f.flush(ss);
+        } else if (map_type == "crushmap") {
+          CrushWrapper cw;
+          bufferlist::iterator it = bl.begin();
+          cw.decode(it);
+          CrushCompiler cc(cw, std::cerr, 0);
+          cc.decompile(ss);
+        } else {
+          std::cerr << "This type of readable map does not exist: " << map_type
+                    << std::endl << "You can only specify[osdmap|monmap|mdsmap"
+                    "|crushmap|mgr]" << std::endl;
+        }
+      } catch (const buffer::error &err) {
+        std::cerr << "Could not decode for human readable output (you may still"
+                     " use non-readable mode).  Detail: " << err << std::endl;
       }
+
       out.append(ss);
       out.write_fd(fd);
     } else {