From e9d20ffe19d79a3af0279972c248d903f22c7766 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 21 May 2013 14:36:11 -0700 Subject: mon: implement --extract-monmap 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 (cherry picked from commit c0268e27497a4d8228ef54da9d4ca12f3ac1f1bf) --- src/ceph_mon.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/ceph_mon.cc') diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 28e897e961a..541c239ef98 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -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 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; -- cgit v1.2.1