Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / cls / statelog / cls_statelog_ops.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_CLS_STATELOG_OPS_H
5 #define CEPH_CLS_STATELOG_OPS_H
6
7 #include "cls_statelog_types.h"
8
9 struct cls_statelog_add_op {
10   list<cls_statelog_entry> entries;
11
12   cls_statelog_add_op() {}
13
14   void encode(bufferlist& bl) const {
15     ENCODE_START(1, 1, bl);
16     ::encode(entries, bl);
17     ENCODE_FINISH(bl);
18   }
19
20   void decode(bufferlist::iterator& bl) {
21     DECODE_START(1, bl);
22     ::decode(entries, bl);
23     DECODE_FINISH(bl);
24   }
25 };
26 WRITE_CLASS_ENCODER(cls_statelog_add_op)
27
28 struct cls_statelog_list_op {
29   string object;
30   string client_id;
31   string op_id;
32   string marker; /* if not empty, overrides from_time */
33   int max_entries; /* upperbound to returned num of entries
34                       might return less than that and still be truncated */
35
36   cls_statelog_list_op() : max_entries(0) {}
37
38   void encode(bufferlist& bl) const {
39     ENCODE_START(1, 1, bl);
40     ::encode(object, bl);
41     ::encode(client_id, bl);
42     ::encode(op_id, bl);
43     ::encode(marker, bl);
44     ::encode(max_entries, bl);
45     ENCODE_FINISH(bl);
46   }
47
48   void decode(bufferlist::iterator& bl) {
49     DECODE_START(1, bl);
50     ::decode(object, bl);
51     ::decode(client_id, bl);
52     ::decode(op_id, bl);
53     ::decode(marker, bl);
54     ::decode(max_entries, bl);
55     DECODE_FINISH(bl);
56   }
57 };
58 WRITE_CLASS_ENCODER(cls_statelog_list_op)
59
60 struct cls_statelog_list_ret {
61   list<cls_statelog_entry> entries;
62   string marker;
63   bool truncated;
64
65   cls_statelog_list_ret() : truncated(false) {}
66
67   void encode(bufferlist& bl) const {
68     ENCODE_START(1, 1, bl);
69     ::encode(entries, bl);
70     ::encode(marker, bl);
71     ::encode(truncated, bl);
72     ENCODE_FINISH(bl);
73   }
74
75   void decode(bufferlist::iterator& bl) {
76     DECODE_START(1, bl);
77     ::decode(entries, bl);
78     ::decode(marker, bl);
79     ::decode(truncated, bl);
80     DECODE_FINISH(bl);
81   }
82 };
83 WRITE_CLASS_ENCODER(cls_statelog_list_ret)
84
85
86 /*
87  * operation will return 0 when successfully removed but not done. Will return
88  * -ENODATA when done, so caller needs to repeat sending request until that.
89  */
90 struct cls_statelog_remove_op {
91   string client_id;
92   string op_id;
93   string object;
94
95   cls_statelog_remove_op() {}
96
97   void encode(bufferlist& bl) const {
98     ENCODE_START(1, 1, bl);
99     ::encode(client_id, bl);
100     ::encode(op_id, bl);
101     ::encode(object, bl);
102     ENCODE_FINISH(bl);
103   }
104
105   void decode(bufferlist::iterator& bl) {
106     DECODE_START(1, bl);
107     ::decode(client_id, bl);
108     ::decode(op_id, bl);
109     ::decode(object, bl);
110     DECODE_FINISH(bl);
111   }
112 };
113 WRITE_CLASS_ENCODER(cls_statelog_remove_op)
114
115 struct cls_statelog_check_state_op {
116   string client_id;
117   string op_id;
118   string object;
119   uint32_t state;
120
121   cls_statelog_check_state_op() : state(0) {}
122
123   void encode(bufferlist& bl) const {
124     ENCODE_START(1, 1, bl);
125     ::encode(client_id, bl);
126     ::encode(op_id, bl);
127     ::encode(object, bl);
128     ::encode(state, bl);
129     ENCODE_FINISH(bl);
130   }
131
132   void decode(bufferlist::iterator& bl) {
133     DECODE_START(1, bl);
134     ::decode(client_id, bl);
135     ::decode(op_id, bl);
136     ::decode(object, bl);
137     ::decode(state, bl);
138     DECODE_FINISH(bl);
139   }
140 };
141 WRITE_CLASS_ENCODER(cls_statelog_check_state_op)
142
143 #endif