Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / mirror / GetInfoRequest.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_LIBRBD_MIRROR_GET_INFO_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_GET_INFO_REQUEST_H
6
7 #include "include/buffer.h"
8 #include "librbd/mirror/Types.h"
9 #include <string>
10
11 struct Context;
12 namespace cls { namespace rbd { struct MirrorImage; } }
13
14 namespace librbd {
15
16 struct ImageCtx;
17
18 namespace mirror {
19
20 template <typename ImageCtxT = librbd::ImageCtx>
21 class GetInfoRequest {
22 public:
23   static GetInfoRequest *create(ImageCtxT &image_ctx,
24                                 cls::rbd::MirrorImage *mirror_image,
25                                 PromotionState *promotion_state,
26                                 Context *on_finish) {
27     return new GetInfoRequest(image_ctx, mirror_image, promotion_state,
28                               on_finish);
29   }
30
31   GetInfoRequest(ImageCtxT &image_ctx, cls::rbd::MirrorImage *mirror_image,
32                  PromotionState *promotion_state, Context *on_finish)
33     : m_image_ctx(image_ctx), m_mirror_image(mirror_image),
34       m_promotion_state(promotion_state), m_on_finish(on_finish) {
35   }
36
37   void send();
38
39 private:
40   /**
41    * @verbatim
42    *
43    * <start>
44    *    |
45    *    v
46    * REFRESH
47    *    |
48    *    v
49    * GET_MIRROR_IMAGE
50    *    |
51    *    v
52    * GET_TAG_OWNER
53    *    |
54    *    v
55    * <finish>
56    *
57    * @endverbatim
58    */
59
60   ImageCtxT &m_image_ctx;
61   cls::rbd::MirrorImage *m_mirror_image;
62   PromotionState *m_promotion_state;
63   Context *m_on_finish;
64
65   bufferlist m_out_bl;
66   std::string m_mirror_uuid;
67
68   void refresh_image();
69   void handle_refresh_image(int r);
70
71   void get_mirror_image();
72   void handle_get_mirror_image(int r);
73
74   void get_tag_owner();
75   void handle_get_tag_owner(int r);
76
77   void finish(int r);
78
79 };
80
81 } // namespace mirror
82 } // namespace librbd
83
84 extern template class librbd::mirror::GetInfoRequest<librbd::ImageCtx>;
85
86 #endif // CEPH_LIBRBD_MIRROR_GET_INFO_REQUEST_H
87