]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/types.h
update sources to v12.1.0
[ceph.git] / ceph / src / tools / rbd_mirror / types.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef CEPH_RBD_MIRROR_TYPES_H
5 #define CEPH_RBD_MIRROR_TYPES_H
6
7 #include <iostream>
8 #include <memory>
9 #include <set>
10 #include <string>
11 #include <vector>
12
13 #include "include/rbd/librbd.hpp"
14
15 namespace rbd {
16 namespace mirror {
17
18 typedef shared_ptr<librados::Rados> RadosRef;
19 typedef shared_ptr<librados::IoCtx> IoCtxRef;
20 typedef shared_ptr<librbd::Image> ImageRef;
21
22 struct ImageId {
23 std::string global_id;
24 std::string id;
25
26 explicit ImageId(const std::string &global_id) : global_id(global_id) {
27 }
28 ImageId(const std::string &global_id, const std::string &id)
29 : global_id(global_id), id(id) {
30 }
31
32 inline bool operator==(const ImageId &rhs) const {
33 return (global_id == rhs.global_id && id == rhs.id);
34 }
35 inline bool operator<(const ImageId &rhs) const {
36 return global_id < rhs.global_id;
37 }
38 };
39
40 std::ostream &operator<<(std::ostream &, const ImageId &image_id);
41
42 typedef std::set<ImageId> ImageIds;
43
44 struct peer_t {
45 peer_t() = default;
46 peer_t(const std::string &uuid, const std::string &cluster_name,
47 const std::string &client_name)
48 : uuid(uuid), cluster_name(cluster_name), client_name(client_name)
49 {
50 }
51 peer_t(const librbd::mirror_peer_t &peer) :
52 uuid(peer.uuid),
53 cluster_name(peer.cluster_name),
54 client_name(peer.client_name)
55 {
56 }
57 std::string uuid;
58 std::string cluster_name;
59 std::string client_name;
60 bool operator<(const peer_t &rhs) const {
61 return this->uuid < rhs.uuid;
62 }
63 bool operator()(const peer_t &lhs, const peer_t &rhs) const {
64 return lhs.uuid < rhs.uuid;
65 }
66 bool operator==(const peer_t &rhs) const {
67 return uuid == rhs.uuid;
68 }
69 };
70
71 std::ostream& operator<<(std::ostream& lhs, const peer_t &peer);
72
73 } // namespace mirror
74 } // namespace rbd
75
76
77 #endif // CEPH_RBD_MIRROR_TYPES_H