From: huanwen ren Date: Wed, 30 Aug 2017 08:47:24 +0000 (+0800) Subject: mgr: add the ip addr of standbys X-Git-Tag: v13.0.1~1051^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=389d676b5d153116eb09769af49230bbfac2d562;p=ceph-ci.git mgr: add the ip addr of standbys we need to manage the ip addr of the "standbys" state, because the hostname/gid is insufficient to locate the Standby node. we add ip of the mgr standby to metadata. Signed-off-by: huanwen ren --- diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 99df69c909f..07157736137 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -162,6 +162,7 @@ void MgrStandby::send_beacon() << " modules " << modules << dendl; map metadata; + metadata["addr"] = monc.get_my_addr().ip_only_to_str(); collect_sys_info(&metadata, g_ceph_context); MMgrBeacon *m = new MMgrBeacon(monc.get_fsid(), diff --git a/src/msg/msg_types.cc b/src/msg/msg_types.cc index 67a699c9c4d..28cedef1cb2 100644 --- a/src/msg/msg_types.cc +++ b/src/msg/msg_types.cc @@ -290,3 +290,22 @@ void entity_addrvec_t::generate_test_instances(list& ls) ls.back()->v.push_back(entity_addr_t()); ls.back()->v.push_back(entity_addr_t()); } + +std::string entity_addr_t::ip_only_to_str() const +{ + const char *host_ip = NULL; + char addr_buf[INET6_ADDRSTRLEN]; + switch (get_family()) { + case AF_INET: + host_ip = inet_ntop(AF_INET, &in4_addr().sin_addr, + addr_buf, INET_ADDRSTRLEN); + break; + case AF_INET6: + host_ip = inet_ntop(AF_INET6, &in6_addr().sin6_addr, + addr_buf, INET6_ADDRSTRLEN); + break; + default: + break; + } + return host_ip ? host_ip : ""; +} diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 5632950f309..8a20ba0f060 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -384,6 +384,8 @@ struct entity_addr_t { } } + std::string ip_only_to_str() const; + bool parse(const char *s, const char **end = 0); void decode_legacy_addr_after_marker(bufferlist::iterator& bl)