]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
ceph-monstore-tool: add --monmap <path> argument to rebuild command
authorSage Weil <sage@redhat.com>
Thu, 10 Jan 2019 17:01:19 +0000 (11:01 -0600)
committerSage Weil <sage@redhat.com>
Fri, 11 Jan 2019 22:10:14 +0000 (16:10 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/tools/ceph_monstore_tool.cc

index 043fdd93cd03238d15bc86dacd4b8e5574f06d13..ae3e151b2b427d01ecaa22fbce9117c147ff1a97 100644 (file)
@@ -496,13 +496,27 @@ static int update_auth(MonitorDBStore& st, const string& keyring_path)
   return 0;
 }
 
-static int update_mkfs(MonitorDBStore& st)
+static int update_mkfs(MonitorDBStore& st, const string& monmap_path)
 {
   MonMap monmap;
-  int r = monmap.build_initial(g_ceph_context, true, cerr);
-  if (r) {
-    cerr << "no initial monitors" << std::endl;
-    return -EINVAL;
+  if (!monmap_path.empty()) {
+    cout << __func__ << " pulling initial monmap from " << monmap_path << std::endl;
+    bufferlist bl;
+    string err;
+    int r = bl.read_file(monmap_path.c_str(), &err);
+    if (r < 0) {
+      cerr << "failed to read monmap from " << monmap_path << ": "
+          << cpp_strerror(r) << std::endl;
+      return r;
+    }
+    monmap.decode(bl);
+  } else {
+    cout << __func__ << " generating seed initial monmap" << std::endl;
+    int r = monmap.build_initial(g_ceph_context, true, cerr);
+    if (r) {
+      cerr << "no initial monitors" << std::endl;
+      return -EINVAL;
+    }
   }
   monmap.print(cout);
   bufferlist bl;
@@ -626,9 +640,12 @@ int rebuild_monstore(const char* progname,
 {
   po::options_description op_desc("Allowed 'rebuild' options");
   string keyring_path;
+  string monmap_path;
   op_desc.add_options()
     ("keyring", po::value<string>(&keyring_path),
-     "path to the client.admin key");
+     "path to the client.admin key")
+    ("monmap", po::value<string>(&monmap_path),
+     "path to the initial monmap");
   po::variables_map op_vm;
   int r = parse_cmd_args(&op_desc, nullptr, nullptr, subcmds, &op_vm);
   if (r) {
@@ -649,7 +666,7 @@ int rebuild_monstore(const char* progname,
   if ((r = update_paxos(st))) {
     return r;
   }
-  if ((r = update_mkfs(st))) {
+  if ((r = update_mkfs(st, monmap_path))) {
     return r;
   }
   if ((r = update_monitor(st))) {