]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
9f95a23c TL |
12 | class ContextWQ; |
13 | ||
7c673cae FG |
14 | struct Context; |
15 | ||
16 | namespace librbd { | |
17 | ||
18 | struct ImageCtx; | |
19 | ||
20 | namespace api { | |
21 | ||
22 | template <typename ImageCtxT = librbd::ImageCtx> | |
23 | struct Mirror { | |
11fdf7f2 | 24 | typedef std::map<std::string, std::string> Attributes; |
9f95a23c TL |
25 | typedef std::map<std::string, mirror_image_global_status_t> |
26 | IdToMirrorImageGlobalStatus; | |
7c673cae FG |
27 | typedef std::map<mirror_image_status_state_t, int> MirrorImageStatusStates; |
28 | ||
eafe8130 TL |
29 | static int site_name_get(librados::Rados& rados, std::string* name); |
30 | static int site_name_set(librados::Rados& rados, const std::string& name); | |
31 | ||
7c673cae FG |
32 | static int mode_get(librados::IoCtx& io_ctx, rbd_mirror_mode_t *mirror_mode); |
33 | static int mode_set(librados::IoCtx& io_ctx, rbd_mirror_mode_t mirror_mode); | |
34 | ||
9f95a23c TL |
35 | static int uuid_get(librados::IoCtx& io_ctx, std::string* mirror_uuid); |
36 | static void uuid_get(librados::IoCtx& io_ctx, std::string* mirror_uuid, | |
37 | Context* on_finish); | |
38 | ||
eafe8130 TL |
39 | static int peer_bootstrap_create(librados::IoCtx& io_ctx, std::string* token); |
40 | static int peer_bootstrap_import(librados::IoCtx& io_ctx, | |
41 | rbd_mirror_peer_direction_t direction, | |
42 | const std::string& token); | |
43 | ||
9f95a23c TL |
44 | static int peer_site_add(librados::IoCtx& io_ctx, std::string *uuid, |
45 | mirror_peer_direction_t direction, | |
46 | const std::string &site_name, | |
47 | const std::string &client_name); | |
48 | static int peer_site_remove(librados::IoCtx& io_ctx, const std::string &uuid); | |
49 | static int peer_site_list(librados::IoCtx& io_ctx, | |
50 | std::vector<mirror_peer_site_t> *peers); | |
51 | static int peer_site_set_client(librados::IoCtx& io_ctx, | |
52 | const std::string &uuid, | |
53 | const std::string &client_name); | |
54 | static int peer_site_set_name(librados::IoCtx& io_ctx, | |
55 | const std::string &uuid, | |
56 | const std::string &site_name); | |
57 | static int peer_site_set_direction(librados::IoCtx& io_ctx, | |
58 | const std::string &uuid, | |
59 | mirror_peer_direction_t direction); | |
60 | static int peer_site_get_attributes(librados::IoCtx& io_ctx, | |
61 | const std::string &uuid, | |
62 | Attributes* attributes); | |
63 | static int peer_site_set_attributes(librados::IoCtx& io_ctx, | |
64 | const std::string &uuid, | |
65 | const Attributes& attributes); | |
66 | ||
67 | static int image_global_status_list(librados::IoCtx& io_ctx, | |
68 | const std::string &start_id, size_t max, | |
69 | IdToMirrorImageGlobalStatus *images); | |
70 | ||
7c673cae FG |
71 | static int image_status_summary(librados::IoCtx& io_ctx, |
72 | MirrorImageStatusStates *states); | |
11fdf7f2 TL |
73 | static int image_instance_id_list(librados::IoCtx& io_ctx, |
74 | const std::string &start_image_id, | |
75 | size_t max, | |
76 | std::map<std::string, std::string> *ids); | |
7c673cae | 77 | |
9f95a23c TL |
78 | static int image_info_list( |
79 | librados::IoCtx& io_ctx, mirror_image_mode_t *mode_filter, | |
80 | const std::string &start_id, size_t max, | |
81 | std::map<std::string, std::pair<mirror_image_mode_t, | |
82 | mirror_image_info_t>> *entries); | |
83 | ||
84 | static int image_enable(ImageCtxT *ictx, mirror_image_mode_t mode, | |
85 | bool relax_same_pool_parent_check); | |
7c673cae FG |
86 | static int image_disable(ImageCtxT *ictx, bool force); |
87 | static int image_promote(ImageCtxT *ictx, bool force); | |
88 | static void image_promote(ImageCtxT *ictx, bool force, Context *on_finish); | |
89 | static int image_demote(ImageCtxT *ictx); | |
90 | static void image_demote(ImageCtxT *ictx, Context *on_finish); | |
91 | static int image_resync(ImageCtxT *ictx); | |
92 | static int image_get_info(ImageCtxT *ictx, | |
11fdf7f2 | 93 | mirror_image_info_t *mirror_image_info); |
7c673cae FG |
94 | static void image_get_info(ImageCtxT *ictx, |
95 | mirror_image_info_t *mirror_image_info, | |
11fdf7f2 | 96 | Context *on_finish); |
9f95a23c TL |
97 | static int image_get_info(librados::IoCtx& io_ctx, |
98 | ContextWQ *op_work_queue, | |
99 | const std::string &image_id, | |
100 | mirror_image_info_t *mirror_image_info); | |
101 | static void image_get_info(librados::IoCtx& io_ctx, | |
102 | ContextWQ *op_work_queue, | |
103 | const std::string &image_id, | |
104 | mirror_image_info_t *mirror_image_info, | |
105 | Context *on_finish); | |
106 | static int image_get_mode(ImageCtxT *ictx, mirror_image_mode_t *mode); | |
107 | static void image_get_mode(ImageCtxT *ictx, mirror_image_mode_t *mode, | |
108 | Context *on_finish); | |
109 | static int image_get_global_status(ImageCtxT *ictx, | |
110 | mirror_image_global_status_t *status); | |
111 | static void image_get_global_status(ImageCtxT *ictx, | |
112 | mirror_image_global_status_t *status, | |
113 | Context *on_finish); | |
11fdf7f2 | 114 | static int image_get_instance_id(ImageCtxT *ictx, std::string *instance_id); |
9f95a23c TL |
115 | |
116 | static int image_snapshot_create(ImageCtxT *ictx, uint64_t *snap_id); | |
7c673cae FG |
117 | }; |
118 | ||
119 | } // namespace api | |
120 | } // namespace librbd | |
121 | ||
122 | extern template class librbd::api::Mirror<librbd::ImageCtx>; | |
123 | ||
124 | #endif // LIBRBD_API_MIRROR_H |