This matches the previous ceph-osd-prestart.sh behavior, which
called ceph-crush-location, which calls 'hostname -s'.
Fixes: http://tracker.ceph.com/issues/15840
Signed-off-by: Sage Weil <sage@redhat.com>
int r = gethostname(hostname, sizeof(hostname)-1);
if (r < 0)
strcpy(hostname, "unknown_host");
+ // use short hostname
+ for (unsigned i=0; hostname[i]; ++i) {
+ if (hostname[i] == '.') {
+ hostname[i] = '\0';
+ break;
+ }
+ }
std::lock_guard<std::mutex> l(lock);
loc.clear();
loc.insert(make_pair<std::string,std::string>("host", hostname));