]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: implement --extract-monmap <filename>
authorSage Weil <sage@inktank.com>
Tue, 21 May 2013 21:36:11 +0000 (14:36 -0700)
committerSage Weil <sage@inktank.com>
Tue, 21 May 2013 22:15:33 +0000 (15:15 -0700)
This will make for a simpler process for
  http://ceph.com/docs/master/rados/operations/add-or-rm-mons/#removing-monitors-from-an-unhealthy-cluster

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit c0268e27497a4d8228ef54da9d4ca12f3ac1f1bf)

src/ceph_mon.cc

index 28e897e961a976919ac73c955dbecbd10eb85ec8..541c239ef98f79ce5c8ba13d89122dafc8d59ae9 100644 (file)
@@ -116,7 +116,7 @@ int main(int argc, const char **argv)
 
   bool mkfs = false;
   bool compact = false;
-  std::string osdmapfn, inject_monmap;
+  std::string osdmapfn, inject_monmap, extract_monmap;
 
   vector<const char*> args;
   argv_to_vec(argc, argv, args);
@@ -140,6 +140,8 @@ int main(int argc, const char **argv)
       osdmapfn = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--inject_monmap", (char*)NULL)) {
       inject_monmap = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--extract-monmap", (char*)NULL)) {
+      extract_monmap = val;
     } else {
       ++i;
     }
@@ -380,11 +382,21 @@ int main(int argc, const char **argv)
         cerr << "can't decode monmap: " << e.what() << std::endl;
       }
     } else {
-      std::cerr << "unable to obtain a monmap: "
-                << cpp_strerror(err) << std::endl;
+      derr << "unable to obtain a monmap: " << cpp_strerror(err) << dendl;
+    }
+    if (!extract_monmap.empty()) {
+      int r = mapbl.write_file(extract_monmap.c_str());
+      if (r < 0) {
+       r = -errno;
+       derr << "error writing monmap to " << extract_monmap << ": " << cpp_strerror(r) << dendl;
+       prefork.exit(1);
+      }
+      derr << "wrote monmap to " << extract_monmap << dendl;
+      prefork.exit(0);
     }
   }
 
+
   // this is what i will bind to
   entity_addr_t ipaddr;