This source file includes following definitions.
- pcmk__readable_action
- pcmk__is_up_action
- pcmk__is_down_action
1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__CRM_COMMON_ACTIONS_INTERNAL__H
11 #define PCMK__CRM_COMMON_ACTIONS_INTERNAL__H
12
13 #include <stdbool.h>
14 #include <stdint.h>
15 #include <glib.h>
16 #include <libxml/tree.h>
17
18 #include <crm/common/actions.h>
19 #include <crm/common/roles.h>
20 #include <crm/common/scheduler_types.h>
21 #include <crm/common/strings_internal.h>
22
23 #include <crm/common/strings_internal.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29
30 #define PCMK__OP_FMT "%s_%s_%u"
31
32
33
34
35
36
37
38
39 #define pcmk__set_action_flags(action, flags_to_set) do { \
40 (action)->flags = pcmk__set_flags_as(__func__, __LINE__, \
41 LOG_TRACE, \
42 "Action", (action)->uuid, \
43 (action)->flags, \
44 (flags_to_set), \
45 #flags_to_set); \
46 } while (0)
47
48
49
50
51
52
53
54
55 #define pcmk__clear_action_flags(action, flags_to_clear) do { \
56 (action)->flags = pcmk__clear_flags_as(__func__, __LINE__, \
57 LOG_TRACE, \
58 "Action", (action)->uuid, \
59 (action)->flags, \
60 (flags_to_clear), \
61 #flags_to_clear); \
62 } while (0)
63
64
65
66
67
68
69
70
71
72 #define pcmk__set_raw_action_flags(action_flags, action_name, to_set) do { \
73 action_flags = pcmk__set_flags_as(__func__, __LINE__, \
74 LOG_TRACE, "Action", action_name, \
75 (action_flags), \
76 (to_set), #to_set); \
77 } while (0)
78
79
80
81
82
83
84
85
86
87 #define pcmk__clear_raw_action_flags(action_flags, action_name, to_clear) \
88 do { \
89 action_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
90 "Action", action_name, \
91 (action_flags), \
92 (to_clear), #to_clear); \
93 } while (0)
94
95
96 enum pcmk__action_type {
97 pcmk__action_unspecified = 0,
98 pcmk__action_monitor,
99
100
101
102 pcmk__action_stop,
103 pcmk__action_stopped,
104
105 pcmk__action_start,
106 pcmk__action_started,
107
108 pcmk__action_notify,
109 pcmk__action_notified,
110
111 pcmk__action_promote,
112 pcmk__action_promoted,
113
114 pcmk__action_demote,
115 pcmk__action_demoted,
116
117 pcmk__action_shutdown,
118 pcmk__action_fence,
119 };
120
121
122 enum pcmk__action_flags {
123
124 pcmk__no_action_flags = 0,
125
126
127 pcmk__action_pseudo = (UINT32_C(1) << 0),
128
129
130 pcmk__action_runnable = (UINT32_C(1) << 1),
131
132
133 pcmk__action_optional = (UINT32_C(1) << 2),
134
135
136 pcmk__action_always_in_graph = (UINT32_C(1) << 3),
137
138
139 pcmk__action_attrs_evaluated = (UINT32_C(1) << 4),
140
141
142 pcmk__action_migratable = (UINT32_C(1) << 7),
143
144
145 pcmk__action_added_to_graph = (UINT32_C(1) << 8),
146
147
148 pcmk__action_migration_abort = (UINT32_C(1) << 11),
149
150
151 pcmk__action_reschedule = (UINT32_C(1) << 13),
152
153
154 pcmk__action_detect_loop = (UINT32_C(1) << 14),
155
156
157 pcmk__action_inputs_deduplicated = (UINT32_C(1) << 15),
158
159
160 pcmk__action_on_dc = (UINT32_C(1) << 16),
161 };
162
163
164
165
166
167
168 enum pcmk__on_fail {
169 pcmk__on_fail_ignore,
170 pcmk__on_fail_demote,
171 pcmk__on_fail_restart,
172
173
174
175
176
177 pcmk__on_fail_reset_remote,
178
179 pcmk__on_fail_restart_container,
180 pcmk__on_fail_ban,
181 pcmk__on_fail_block,
182 pcmk__on_fail_stop,
183 pcmk__on_fail_standby_node,
184 pcmk__on_fail_fence_node,
185 };
186
187
188 enum pcmk__requires {
189 pcmk__requires_nothing = 0,
190 pcmk__requires_quorum = 1,
191 pcmk__requires_fencing = 2,
192 };
193
194
195 struct pcmk__action {
196 int id;
197
198
199
200
201
202
203 int priority;
204
205 pcmk_resource_t *rsc;
206 pcmk_node_t *node;
207 xmlNode *op_entry;
208 char *task;
209 char *uuid;
210 char *cancel_task;
211 char *reason;
212 uint32_t flags;
213 enum pcmk__requires needs;
214 enum pcmk__on_fail on_fail;
215 enum rsc_role_e fail_role;
216 GHashTable *meta;
217 GHashTable *extra;
218 pcmk_scheduler_t *scheduler;
219
220
221
222
223 int runnable_before;
224
225
226
227
228
229
230 int required_runnable_before;
231
232
233 GList *actions_before;
234 GList *actions_after;
235 };
236
237 void pcmk__free_action(gpointer user_data);
238 char *pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms);
239 char *pcmk__notify_key(const char *rsc_id, const char *notify_type,
240 const char *op_type);
241 char *pcmk__transition_key(int transition_id, int action_id, int target_rc,
242 const char *node);
243 void pcmk__filter_op_for_digest(xmlNode *param_set);
244 bool pcmk__is_fencing_action(const char *action);
245 enum pcmk__action_type pcmk__parse_action(const char *action_name);
246 const char *pcmk__action_text(enum pcmk__action_type action);
247 const char *pcmk__on_fail_text(enum pcmk__on_fail on_fail);
248
249
250
251
252
253
254
255
256
257
258
259 static inline const char *
260 pcmk__readable_action(const char *action_name, guint interval_ms) {
261 if ((interval_ms == 0)
262 && pcmk__str_eq(action_name, PCMK_ACTION_MONITOR, pcmk__str_none)) {
263 return "probe";
264 }
265 return action_name;
266 }
267
268
269
270
271
272
273
274
275
276 static inline bool
277 pcmk__is_up_action(const char *action)
278 {
279 return pcmk__str_any_of(action, PCMK_ACTION_START, PCMK_ACTION_PROMOTE,
280 PCMK_ACTION_MIGRATE_FROM, NULL);
281 }
282
283
284
285
286
287
288
289
290
291 static inline bool
292 pcmk__is_down_action(const char *action)
293 {
294 return pcmk__str_any_of(action, PCMK_ACTION_STOP, PCMK_ACTION_DEMOTE,
295 PCMK_ACTION_MIGRATE_TO, NULL);
296 }
297
298 #ifdef __cplusplus
299 }
300 #endif
301
302 #endif