diff options
author | Sage Weil <sage@inktank.com> | 2013-05-21 14:36:11 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-05-21 15:15:33 -0700 |
commit | 8a030eb0e1b61121f7b1e2b7a551bb213d1c428b (patch) | |
tree | bcf5150bc3fef606b2700895b947051d17f48bf4 | |
parent | 4ad13c945fd29a2d183f7ea6c6ac8a51d24dabe1 (diff) | |
download | ceph-8a030eb0e1b61121f7b1e2b7a551bb213d1c428b.tar.gz |
mon: implement --extract-monmap <filename>
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)
-rw-r--r-- | src/ceph_mon.cc | 18 |
1 files changed, 15 insertions, 3 deletions
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<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; |