]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/api/Mirror.h
import ceph 14.2.5
[ceph.git] / ceph / src / librbd / api / Mirror.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 LIBRBD_API_MIRROR_H
5 #define LIBRBD_API_MIRROR_H
6
7 #include "include/rbd/librbd.hpp"
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 struct Context;
13
14 namespace librbd {
15
16 struct ImageCtx;
17
18 namespace api {
19
20 template <typename ImageCtxT = librbd::ImageCtx>
21 struct Mirror {
22 typedef std::map<std::string, std::string> Attributes;
23 typedef std::map<std::string, mirror_image_status_t> IdToMirrorImageStatus;
24 typedef std::map<mirror_image_status_state_t, int> MirrorImageStatusStates;
25
26 static int site_name_get(librados::Rados& rados, std::string* name);
27 static int site_name_set(librados::Rados& rados, const std::string& name);
28
29 static int mode_get(librados::IoCtx& io_ctx, rbd_mirror_mode_t *mirror_mode);
30 static int mode_set(librados::IoCtx& io_ctx, rbd_mirror_mode_t mirror_mode);
31
32 static int peer_bootstrap_create(librados::IoCtx& io_ctx, std::string* token);
33 static int peer_bootstrap_import(librados::IoCtx& io_ctx,
34 rbd_mirror_peer_direction_t direction,
35 const std::string& token);
36
37 static int peer_add(librados::IoCtx& io_ctx, std::string *uuid,
38 const std::string &cluster_name,
39 const std::string &client_name);
40 static int peer_remove(librados::IoCtx& io_ctx, const std::string &uuid);
41 static int peer_list(librados::IoCtx& io_ctx,
42 std::vector<mirror_peer_t> *peers);
43 static int peer_set_client(librados::IoCtx& io_ctx, const std::string &uuid,
44 const std::string &client_name);
45 static int peer_set_cluster(librados::IoCtx& io_ctx, const std::string &uuid,
46 const std::string &cluster_name);
47 static int peer_get_attributes(librados::IoCtx& io_ctx,
48 const std::string &uuid,
49 Attributes* attributes);
50 static int peer_set_attributes(librados::IoCtx& io_ctx,
51 const std::string &uuid,
52 const Attributes& attributes);
53
54 static int image_status_list(librados::IoCtx& io_ctx,
55 const std::string &start_id, size_t max,
56 IdToMirrorImageStatus *images);
57 static int image_status_summary(librados::IoCtx& io_ctx,
58 MirrorImageStatusStates *states);
59 static int image_instance_id_list(librados::IoCtx& io_ctx,
60 const std::string &start_image_id,
61 size_t max,
62 std::map<std::string, std::string> *ids);
63
64 static int image_enable(ImageCtxT *ictx, bool relax_same_pool_parent_check);
65 static int image_disable(ImageCtxT *ictx, bool force);
66 static int image_promote(ImageCtxT *ictx, bool force);
67 static void image_promote(ImageCtxT *ictx, bool force, Context *on_finish);
68 static int image_demote(ImageCtxT *ictx);
69 static void image_demote(ImageCtxT *ictx, Context *on_finish);
70 static int image_resync(ImageCtxT *ictx);
71 static int image_get_info(ImageCtxT *ictx,
72 mirror_image_info_t *mirror_image_info);
73 static void image_get_info(ImageCtxT *ictx,
74 mirror_image_info_t *mirror_image_info,
75 Context *on_finish);
76 static int image_get_status(ImageCtxT *ictx, mirror_image_status_t *status);
77 static void image_get_status(ImageCtxT *ictx, mirror_image_status_t *status,
78 Context *on_finish);
79 static int image_get_instance_id(ImageCtxT *ictx, std::string *instance_id);
80 };
81
82 } // namespace api
83 } // namespace librbd
84
85 extern template class librbd::api::Mirror<librbd::ImageCtx>;
86
87 #endif // LIBRBD_API_MIRROR_H