From: Sage Weil Date: Tue, 22 Nov 2011 22:53:45 +0000 (-0800) Subject: mon: name self in monmap if --public-addr specified during mkfs X-Git-Tag: v0.39~17^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3a20b425d6dc0b5e085c2f628f5e0f450d76ad42;p=ceph.git mon: name self in monmap if --public-addr specified during mkfs Signed-off-by: Sage Weil --- diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 1d8d5695d51..3560c540b8e 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -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 diff --git a/src/mon/MonMap.h b/src/mon/MonMap.h index 0736e5b4e9e..e524b4d7bb0 100644 --- a/src/mon/MonMap.h +++ b/src/mon/MonMap.h @@ -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];