Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MMonMap.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) 2004-2006 Sage Weil <sage@newdream.net>
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_MMONMAP_H
16 #define CEPH_MMONMAP_H
17
18 #include "include/ceph_features.h"
19 #include "msg/Message.h"
20 #include "mon/MonMap.h"
21
22 class MMonMap : public Message {
23 public:
24   bufferlist monmapbl;
25
26   MMonMap() : Message(CEPH_MSG_MON_MAP) { }
27   explicit MMonMap(bufferlist &bl) : Message(CEPH_MSG_MON_MAP) { 
28     monmapbl.claim(bl);
29   }
30 private:
31   ~MMonMap() override {}
32
33 public:
34   const char *get_type_name() const override { return "mon_map"; }
35
36   void encode_payload(uint64_t features) override { 
37     if (monmapbl.length() &&
38         ((features & CEPH_FEATURE_MONENC) == 0 ||
39          (features & CEPH_FEATURE_MSG_ADDR2) == 0)) {
40       // reencode old-format monmap
41       MonMap t;
42       t.decode(monmapbl);
43       monmapbl.clear();
44       t.encode(monmapbl, features);
45     }
46
47     ::encode(monmapbl, payload);
48   }
49   void decode_payload() override { 
50     bufferlist::iterator p = payload.begin();
51     ::decode(monmapbl, p);
52   }
53 };
54
55 #endif