Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MMgrOpen.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2016 John Spray <john.spray@redhat.com>
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  */
13
14
15 #ifndef CEPH_MMGROPEN_H_
16 #define CEPH_MMGROPEN_H_
17
18 #include "msg/Message.h"
19
20 class MMgrOpen : public Message
21 {
22   static const int HEAD_VERSION = 2;
23   static const int COMPAT_VERSION = 1;
24
25 public:
26
27   std::string daemon_name;
28   std::string service_name;  // optional; otherwise infer from entity type
29
30   bool service_daemon = false;
31   std::map<std::string,std::string> daemon_metadata;
32   std::map<std::string,std::string> daemon_status;
33
34   void decode_payload() override
35   {
36     bufferlist::iterator p = payload.begin();
37     ::decode(daemon_name, p);
38     if (header.version >= 2) {
39       ::decode(service_name, p);
40       ::decode(service_daemon, p);
41       if (service_daemon) {
42         ::decode(daemon_metadata, p);
43         ::decode(daemon_status, p);
44       }
45     }
46   }
47
48   void encode_payload(uint64_t features) override {
49     ::encode(daemon_name, payload);
50     ::encode(service_name, payload);
51     ::encode(service_daemon, payload);
52     if (service_daemon) {
53       ::encode(daemon_metadata, payload);
54       ::encode(daemon_status, payload);
55     }
56   }
57
58   const char *get_type_name() const override { return "mgropen"; }
59   void print(ostream& out) const override {
60     out << get_type_name() << "(";
61     if (service_name.length()) {
62       out << service_name;
63     } else {
64       out << ceph_entity_type_name(get_source().type());
65     }
66     out << "." << daemon_name;
67     if (service_daemon) {
68       out << " daemon";
69     }
70     out << ")";
71   }
72
73   MMgrOpen()
74     : Message(MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION)
75   {}
76 };
77
78 #endif
79