Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / mirror / GetStatusRequest.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_STATUS_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_GET_STATUS_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 namespace cls { namespace rbd { struct MirrorImageStatus; } }
14
15 namespace librbd {
16
17 struct ImageCtx;
18
19 namespace mirror {
20
21 template <typename ImageCtxT = librbd::ImageCtx>
22 class GetStatusRequest {
23 public:
24   static GetStatusRequest *create(ImageCtxT &image_ctx,
25                                   cls::rbd::MirrorImageStatus *status,
26                                   cls::rbd::MirrorImage *mirror_image,
27                                   PromotionState *promotion_state,
28                                   Context *on_finish) {
29     return new GetStatusRequest(image_ctx, status, mirror_image,
30                                 promotion_state, on_finish);
31   }
32
33   GetStatusRequest(ImageCtxT &image_ctx, cls::rbd::MirrorImageStatus *status,
34                    cls::rbd::MirrorImage *mirror_image,
35                    PromotionState *promotion_state, Context *on_finish)
36     : m_image_ctx(image_ctx), m_mirror_image_status(status),
37       m_mirror_image(mirror_image), m_promotion_state(promotion_state),
38       m_on_finish(on_finish) {
39   }
40
41   void send();
42
43 private:
44   /**
45    * @verbatim
46    *
47    * <start>
48    *    |
49    *    v
50    * GET_INFO
51    *    |
52    *    v
53    * GET_STATUS
54    *    |
55    *    v
56    * <finish>
57    *
58    * @endverbatim
59    */
60
61   ImageCtxT &m_image_ctx;
62   cls::rbd::MirrorImageStatus *m_mirror_image_status;
63   cls::rbd::MirrorImage *m_mirror_image;
64   PromotionState *m_promotion_state;
65   Context *m_on_finish;
66
67   bufferlist m_out_bl;
68
69   void get_info();
70   void handle_get_info(int r);
71
72   void get_status();
73   void handle_get_status(int r);
74
75   void finish(int r);
76
77 };
78
79 } // namespace mirror
80 } // namespace librbd
81
82 extern template class librbd::mirror::GetStatusRequest<librbd::ImageCtx>;
83
84 #endif // CEPH_LIBRBD_MIRROR_GET_STATUS_REQUEST_H
85