]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mon: add '--fsid foo' arg for setting generated monmap fsid
authorSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 21:16:30 +0000 (13:16 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 21:16:30 +0000 (13:16 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
doc/man/8/monmaptool.rst
src/common/config_opts.h
src/mon/MonClient.cc
src/monmaptool.cc

index 924c66a962cbbc554576d3812b545562f776223d..52ec475cc047436d3b5409404f55140536243545 100644 (file)
@@ -52,6 +52,10 @@ Options
 
     will remove the monitor with the specified ip:port from the map.
 
+.. option:: --fsid uuid
+
+    will set the fsid to the given uuid.  If not specified with --create, a random fsid will be generated.
+
 
 Example
 =======
index 6db81102dc9b0bf2e17270d0a502311e58b975b1..363911fc23aec760d696a9dd0dd4db0287aac29f 100644 (file)
@@ -14,6 +14,7 @@
 
 /* note: no header guard */
 OPTION(host, OPT_STR, "localhost")
+OPTION(fsid, OPT_STR, "")              // used for mkfs
 OPTION(public_addr, OPT_ADDR, entity_addr_t())
 OPTION(cluster_addr, OPT_ADDR, entity_addr_t())
 OPTION(num_client, OPT_INT, 1)
index 2b7d9d69a2cf769a1588b15d9a056113724c760b..fa1dc4fe63dfed3ed49d0457ee3bd3f42aa3cf99 100644 (file)
@@ -96,6 +96,13 @@ int MonClient::build_initial_monmap(CephContext *cct, MonMap &monmap)
     return r;
   }
 
+  // fsid from conf?
+  if (cct->_conf->fsid.length()) {
+    if (!monmap.fsid.parse(cct->_conf->fsid.c_str())) {
+      cerr << " failed to parse fsid '" << cct->_conf->fsid << "'" << std::endl;
+    }
+  }
+
   // -m foo?
   if (!conf->mon_host.empty()) {
     vector<entity_addr_t> addrs;
index dd9f95c6d46158094df85fcf0bf58ffc394ac088..08f99d8920a82202798e8df8f3f3b8e1aeaa7999 100644 (file)
@@ -124,8 +124,18 @@ int main(int argc, const char **argv)
     monmap.created = ceph_clock_now(g_ceph_context);
     monmap.last_changed = monmap.created;
     srand(getpid() + time(0));
-    monmap.generate_fsid();
-    cout << me << ": generated fsid " << monmap.fsid << std::endl;
+    if (g_conf->fsid.empty()) {
+      monmap.generate_fsid();
+      cout << me << ": generated fsid " << monmap.fsid << std::endl;
+    }
+    modified = true;
+  }
+  if (g_conf->fsid.length()) {
+    if (!monmap.fsid.parse(g_conf->fsid.c_str())) {
+      cerr << me << ": failed to parse fsid '" << g_conf->fsid << "'" << std::endl;
+      exit(1);
+    }
+    cout << me << ": set fsid to " << monmap.fsid << std::endl;
     modified = true;
   }