]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: take '--fsid foo' arg with --mkfs
authorSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 05:02:23 +0000 (21:02 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Sat, 12 Nov 2011 05:04:58 +0000 (21:04 -0800)
This will set the seed monmap's fsid.  This is useful if the monmap is
dynamically generated (e.g., based on ceph.conf or --mon-host list).

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/ceph_mon.cc
src/include/uuid.h

index a9d6138869371a0143d543e7efd3d764b0afe7d4..ff65c55c6be39d9a13f7a8446c3b3421fd890e05 100644 (file)
@@ -63,6 +63,7 @@ int main(int argc, const char **argv)
 
   global_init(args, CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, 0);
 
+  uuid_d fsid;
   std::string val;
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
@@ -76,6 +77,11 @@ 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, "--fsid", (char*)NULL)) {
+      if (!fsid.parse(val.c_str())) {
+       cerr << "unable to parse fsid '" << val << "'" << std::endl;
+       exit(1);
+      }
     } else {
       ++i;
     }
@@ -122,6 +128,16 @@ int main(int argc, const char **argv)
       }
     }
 
+    if (!fsid.is_zero()) {
+      cout << argv[0] << ": setting fsid to " << fsid << std::endl;
+      monmap.fsid = fsid;
+    }
+    
+    if (monmap.fsid.is_zero()) {
+      cerr << argv[0] << ": generated monmap has no fsid; use --fsid" << std::endl;
+      exit(10);
+    }
+
     // osdmap
     err = osdmapbl.read_file(osdmapfn.c_str(), &error);
     if (err < 0) {
index 8c7ce8faf4454fb07b827d7047cf1af90406d2d0..60049b173af99238b74cfbc7fd2e6c0a10ee3f70 100644 (file)
@@ -15,6 +15,10 @@ extern "C" {
 struct uuid_d {
   uuid_t uuid;
 
+  uuid_d() {
+    memset(&uuid, 0, sizeof(uuid));
+  }
+
   bool is_zero() {
     return uuid_is_null(uuid);
   }
@@ -23,7 +27,7 @@ struct uuid_d {
     uuid_generate(uuid);
   }
   
-  bool parse(char *s) {
+  bool parse(const char *s) {
     return uuid_parse(s, uuid) == 0;
   }
   void print(char *s) {