Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / librbd / operation / SnapshotRenameRequest.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_OPERATION_SNAPSHOT_RENAME_REQUEST_H
5 #define CEPH_LIBRBD_OPERATION_SNAPSHOT_RENAME_REQUEST_H
6
7 #include "librbd/operation/Request.h"
8 #include <string>
9
10 class Context;
11
12 namespace librbd {
13
14 class ImageCtx;
15
16 namespace operation {
17
18 template <typename ImageCtxT = ImageCtx>
19 class SnapshotRenameRequest : public Request<ImageCtxT> {
20 public:
21   /**
22    * Snap Rename goes through the following state machine:
23    *
24    * @verbatim
25    *
26    * <start>
27    *    |
28    *    v
29    * STATE_RENAME_SNAP
30    *    |
31    *    v
32    * <finish>
33    *
34    * @endverbatim
35    *
36    */
37   enum State {
38     STATE_RENAME_SNAP
39   };
40
41   SnapshotRenameRequest(ImageCtxT &image_ctx, Context *on_finish,
42                         uint64_t snap_id, const std::string &snap_name);
43
44   journal::Event create_event(uint64_t op_tid) const override;
45
46 protected:
47   void send_op() override;
48   bool should_complete(int r) override;
49
50 private:
51   uint64_t m_snap_id;
52   std::string m_snap_name;
53   State m_state;
54
55   void send_rename_snap();
56 };
57
58 } // namespace operation
59 } // namespace librbd
60
61 extern template class librbd::operation::SnapshotRenameRequest<librbd::ImageCtx>;
62
63 #endif // CEPH_LIBRBD_OPERATION_SNAPSHOT_RENAME_REQUEST_H