]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: name self in monmap if --public-addr specified during mkfs
authorSage Weil <sage@newdream.net>
Tue, 22 Nov 2011 22:53:45 +0000 (14:53 -0800)
committerSage Weil <sage@newdream.net>
Tue, 22 Nov 2011 22:53:45 +0000 (14:53 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
src/ceph_mon.cc
src/mon/MonMap.h

index 1d8d5695d51d907e7008e877266813b308e72cf7..3560c540b8ea029b3e1e6c9f5982d0d21dfd921f 100644 (file)
@@ -126,6 +126,27 @@ int main(int argc, const char **argv)
        usage();
        exit(1);
       }
+
+      pick_addresses(g_ceph_context);
+
+      // am i part of the initial quorum?
+      if (monmap.contains(g_conf->name.get_id())) {
+       // hmm, make sure the ip listed exists on the current host?
+       // maybe later.
+      } else if (!g_conf->public_addr.is_blank_ip()) {
+       if (monmap.contains(g_conf->public_addr)) {
+         string name;
+         monmap.get_addr_name(g_conf->public_addr, name);
+         monmap.rename(name, g_conf->name.get_id());
+         cout << argv[0] << ": renaming mon." << name << " " << g_conf->public_addr
+              << " to mon." << g_conf->name << std::endl;
+       }
+      } else {
+       // is a local address listed without a name?  if so, name myself.
+       
+       // *******
+
+      }
     }
 
     if (!fsid.is_zero()) {
@@ -138,6 +159,8 @@ int main(int argc, const char **argv)
       exit(10);
     }
 
+    //monmap.print(cout);
+
     // osdmap
     if (osdmapfn.length()) {
       err = osdmapbl.read_file(osdmapfn.c_str(), &error);
@@ -294,7 +317,7 @@ int main(int argc, const char **argv)
       derr << "no public_addr or public_network specified, and " << g_conf->name
           << " not present in monmap" << dendl;
       exit(1);
-    }    
+    }
   }
 
   // bind
index 0736e5b4e9ed7e9a431c4ef51c9d7ea9647bf8df..e524b4d7bb0a52a6a2673c509b78c85558dd8a23 100644 (file)
@@ -119,6 +119,13 @@ class MonMap {
     return false;
   }
 
+  void rename(string oldname, string newname) {
+    assert(contains(oldname));
+    assert(!contains(newname));
+    mon_addr[newname] = mon_addr[oldname];
+    mon_addr.erase(oldname);
+  }
+
   const entity_addr_t& get_addr(const string& n) {
     assert(mon_addr.count(n));
     return mon_addr[n];