Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / mirror / PromoteRequest.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_PROMOTE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_PROMOTE_REQUEST_H
6
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "librbd/mirror/Types.h"
9
10 struct Context;
11
12 namespace librbd {
13
14 struct ImageCtx;
15
16 namespace mirror {
17
18 template <typename ImageCtxT = librbd::ImageCtx>
19 class PromoteRequest {
20 public:
21   static PromoteRequest *create(ImageCtxT &image_ctx, bool force,
22                                 Context *on_finish) {
23     return new PromoteRequest(image_ctx, force, on_finish);
24   }
25
26   PromoteRequest(ImageCtxT &image_ctx, bool force, Context *on_finish)
27     : m_image_ctx(image_ctx), m_force(force), m_on_finish(on_finish) {
28   }
29
30   void send();
31
32 private:
33   /**
34    * @verbatim
35    *
36    * <start>
37    *    |
38    *    v
39    * GET_INFO
40    *    |
41    *    v
42    * GET_TAG_OWNER
43    *    |
44    *    v
45    * PROMOTE
46    *    |
47    *    v
48    * <finish>
49    *
50    * @endverbatim
51    */
52
53   ImageCtxT &m_image_ctx;
54   bool m_force;
55   Context *m_on_finish;
56
57   cls::rbd::MirrorImage m_mirror_image;
58   PromotionState m_promotion_state;
59
60   void get_info();
61   void handle_get_info(int r);
62
63   void promote();
64   void handle_promote(int r);
65
66   void finish(int r);
67
68 };
69
70 } // namespace mirror
71 } // namespace librbd
72
73 extern template class librbd::mirror::PromoteRequest<librbd::ImageCtx>;
74
75 #endif // CEPH_LIBRBD_MIRROR_PROMOTE_REQUEST_H