From f2a95990627f1a4f6ea9aa24866f786692101929 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 19 Dec 2011 08:03:59 -0800 Subject: [PATCH] mon: pull addr from ceph.conf, mon_host as needed when joining mon cluster Signed-off-by: Sage Weil --- src/ceph_mon.cc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc index 48758150f6c..b90df7c8b7b 100644 --- a/src/ceph_mon.cc +++ b/src/ceph_mon.cc @@ -331,12 +331,24 @@ int main(int argc, const char **argv) dout(0) << g_conf->name << " does not exist in monmap, will attempt to join an existing cluster" << dendl; pick_addresses(g_ceph_context); - if (g_conf->public_addr.is_blank_ip()) { - derr << "no public_addr or public_network specified, and " << g_conf->name - << " not present in monmap" << dendl; - exit(1); + if (!g_conf->public_addr.is_blank_ip()) { + ipaddr = g_conf->public_addr; + } else { + MonMap tmpmap; + int err = MonClient::build_initial_monmap(g_ceph_context, tmpmap); + if (err < 0) { + cerr << argv[0] << ": error generating initial monmap: " << cpp_strerror(err) << std::endl; + usage(); + exit(1); + } + if (tmpmap.contains(g_conf->name.get_id())) { + ipaddr = tmpmap.get_addr(g_conf->name.get_id()); + } else { + derr << "no public_addr or public_network specified, and " << g_conf->name + << " not present in monmap or ceph.conf" << dendl; + exit(1); + } } - ipaddr = g_conf->public_addr; } // bind