]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.h
update sources to v12.1.3
[ceph.git] / ceph / src / tools / rbd_mirror / image_replayer / PrepareRemoteImageRequest.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 RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H
6
7 #include "include/buffer.h"
8 #include <string>
9
10 namespace librados { struct IoCtx; }
11 namespace librbd { struct ImageCtx; }
12
13 struct Context;
14 struct ContextWQ;
15
16 namespace rbd {
17 namespace mirror {
18 namespace image_replayer {
19
20 template <typename ImageCtxT = librbd::ImageCtx>
21 class PrepareRemoteImageRequest {
22 public:
23 static PrepareRemoteImageRequest *create(librados::IoCtx &io_ctx,
24 const std::string &global_image_id,
25 std::string *remote_mirror_uuid,
26 std::string *remote_image_id,
27 Context *on_finish) {
28 return new PrepareRemoteImageRequest(io_ctx, global_image_id,
29 remote_mirror_uuid, remote_image_id,
30 on_finish);
31 }
32
33 PrepareRemoteImageRequest(librados::IoCtx &io_ctx,
34 const std::string &global_image_id,
35 std::string *remote_mirror_uuid,
36 std::string *remote_image_id,
37 Context *on_finish)
38 : m_io_ctx(io_ctx), m_global_image_id(global_image_id),
39 m_remote_mirror_uuid(remote_mirror_uuid),
40 m_remote_image_id(remote_image_id),
41 m_on_finish(on_finish) {
42 }
43
44 void send();
45
46 private:
47 /**
48 * @verbatim
49 *
50 * <start>
51 * |
52 * v
53 * GET_REMOTE_MIRROR_UUID
54 * |
55 * v
56 * GET_REMOTE_IMAGE_ID
57 * |
58 * v
59 * <finish>
60
61 * @endverbatim
62 */
63
64 librados::IoCtx &m_io_ctx;
65 std::string m_global_image_id;
66 std::string *m_remote_mirror_uuid;
67 std::string *m_remote_image_id;
68 Context *m_on_finish;
69
70 bufferlist m_out_bl;
71
72 void get_remote_mirror_uuid();
73 void handle_get_remote_mirror_uuid(int r);
74
75 void get_remote_image_id();
76 void handle_get_remote_image_id(int r);
77
78 void finish(int r);
79
80 };
81
82 } // namespace image_replayer
83 } // namespace mirror
84 } // namespace rbd
85
86 extern template class rbd::mirror::image_replayer::PrepareRemoteImageRequest<librbd::ImageCtx>;
87
88 #endif // RBD_MIRROR_IMAGE_REPLAYER_PREPARE_REMOTE_IMAGE_REQUEST_H