]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/monc: set name using a setter
authorKefu Chai <kchai@redhat.com>
Wed, 28 Nov 2018 13:00:33 +0000 (21:00 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 17 Jan 2019 12:23:13 +0000 (20:23 +0800)
* set entity_name using a setter not pass it to constructor, because
  the entity_name is retrieved in seastar's app.run() by ConfigProxy,
  while it'd be simpler if we can instantiate mon::Client in main()
  as a local variable, instead of managing it on heap using a smart
  pointer. so we cannot pass the entity_name as a parameter of ctor.
* also cleanup the #include's, as they are included already in the
  header.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/mon/MonClient.cc
src/crimson/mon/MonClient.h
src/test/crimson/test_monc.cc

index b56b07a0cd1feefd5e92f39cff8d9ffb0f2746f9..e4bd870650561b057cfdeab478583dabae3db0ab 100644 (file)
@@ -7,8 +7,6 @@
 #include <seastar/util/log.hh>
 
 #include "auth/AuthClientHandler.h"
-#include "auth/AuthMethodList.h"
-#include "auth/KeyRing.h"
 #include "auth/RotatingKeyRing.h"
 
 #include "crimson/auth/KeyRing.h"
@@ -248,10 +246,9 @@ AuthMethodList create_auth_methods(uint32_t entity_type)
 }
 }
 
-Client::Client(const EntityName& name,
-               ceph::net::Messenger& messenger)
-  : entity_name{name},
-    auth_methods{create_auth_methods(entity_name.get_type())},
+Client::Client(ceph::net::Messenger& messenger)
+  // currently, crimson is OSD-only
+  : auth_methods{create_auth_methods(CEPH_ENTITY_TYPE_OSD)},
     want_keys{CEPH_ENTITY_TYPE_MON |
               CEPH_ENTITY_TYPE_OSD |
               CEPH_ENTITY_TYPE_MGR},
@@ -262,6 +259,13 @@ Client::Client(const EntityName& name,
 Client::Client(Client&&) = default;
 Client::~Client() = default;
 
+void Client::set_name(const EntityName& name)
+{
+  entity_name = name;
+  // should always be OSD, though
+  auth_methods = create_auth_methods(name.get_type());
+}
+
 seastar::future<> Client::load_keyring()
 {
   if (!auth_methods.is_supported_auth(CEPH_AUTH_CEPHX)) {
index cc291f7510ad9c312823da976d024cce3be150a7..49fa9201bdf739b9d94de4fe57de3bc6fddbb90a 100644 (file)
@@ -37,7 +37,7 @@ namespace ceph::mon {
 class Connection;
 
 class Client : public ceph::net::Dispatcher {
-  const EntityName entity_name;
+  EntityName entity_name;
   KeyRing keyring;
   AuthMethodList auth_methods;
   const uint32_t want_keys;
@@ -65,10 +65,11 @@ class Client : public ceph::net::Dispatcher {
   MonSub sub;
 
 public:
-  Client(const EntityName& name,
-        ceph::net::Messenger& messenger);
+  Client(ceph::net::Messenger& messenger);
   Client(Client&&);
   ~Client();
+  void set_name(const EntityName& name);
+
   seastar::future<> load_keyring();
   seastar::future<> build_initial_map();
   seastar::future<> authenticate();
index de6c4681869c5d74b21650bb8147ecee6caa03eb..9fe541b42e310aa73f4855ce4c87b38a2f9c1a83 100644 (file)
@@ -32,8 +32,9 @@ static seastar::future<> test_monc()
       if (conf->ms_crc_header) {
         msgr.set_crc_header();
       }
-      return seastar::do_with(MonClient{conf->name, msgr},
+      return seastar::do_with(MonClient{msgr},
                               [&msgr](auto& monc) {
+        monc.set_name(ceph::common::local_conf()->name);
         return monc.build_initial_map().then([&monc] {
           return monc.load_keyring();
         }).then([&msgr, &monc] {