usage();
exit(1);
}
-
+
// 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?
}
} else {
// is a local address listed without a name? if so, name myself.
-
- // *******
+ list<entity_addr_t> ls;
+ monmap.list_addrs(ls);
+ entity_addr_t local;
+ if (have_local_addr(g_ceph_context, ls, &local)) {
+ string name;
+ monmap.get_addr_name(local, name);
+
+ if (name.find("noname-") == 0) {
+ cout << argv[0] << ": mon." << name << " " << local
+ << " is local, renaming to mon." << g_conf->name.get_id() << std::endl;
+ monmap.rename(name, g_conf->name.get_id());
+ } else {
+ cout << argv[0] << ": mon." << name << " " << local
+ << " is local, but not 'noname-' + something; not assuming it's me" << std::endl;
+ }
+ }
}
}
epoch_t get_epoch() { return epoch; }
void set_epoch(epoch_t e) { epoch = e; }
+ void list_addrs(list<entity_addr_t>& ls) const {
+ for (map<string,entity_addr_t>::const_iterator p = mon_addr.begin();
+ p != mon_addr.end();
+ ++p)
+ ls.push_back(p->second);
+ }
+
void add(const string &name, const entity_addr_t &addr) {
assert(mon_addr.count(name) == 0);
mon_addr[name] = addr;