]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: add the ip addr of standbys 16476/head
authorhuanwen ren <ren.huanwen@zte.com.cn>
Wed, 30 Aug 2017 08:47:24 +0000 (16:47 +0800)
committerhuanwen ren <ren.huanwen@zte.com.cn>
Mon, 4 Sep 2017 03:00:27 +0000 (11:00 +0800)
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 <ren.huanwen@zte.com.cn>
src/mgr/MgrStandby.cc
src/msg/msg_types.cc
src/msg/msg_types.h

index 99df69c909fdea44512973aabe69e3e45990d525..07157736137f5054a0ea95abe58c3c9cc8bc1e2d 100644 (file)
@@ -162,6 +162,7 @@ void MgrStandby::send_beacon()
           << " modules " << modules << dendl;
 
   map<string,string> 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(),
index 67a699c9c4d247f877b96d42b2f34f77f8601601..28cedef1cb2726e04a1b021a9f727f6f3dcaa92c 100644 (file)
@@ -290,3 +290,22 @@ void entity_addrvec_t::generate_test_instances(list<entity_addrvec_t*>& 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 : "";
+}
index 5632950f30918f40c0458014790fddc8b2c31dc4..8a20ba0f060eb5fb3c6286e1b0652eee60f2634f 100644 (file)
@@ -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)