1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__CRM_COMMON_ACTIONS__H
11 #define PCMK__CRM_COMMON_ACTIONS__H
12
13 #include <stdbool.h>
14 #include <strings.h>
15 #include <glib.h>
16 #include <libxml/tree.h>
17
18 #include <crm/lrmd_events.h>
19
20 #include <glib.h>
21 #include <libxml/tree.h>
22
23 #include <crm/common/nodes.h>
24 #include <crm/common/resources.h>
25 #include <crm/common/scheduler_types.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31
32
33
34
35
36
37
38 #define PCMK_DEFAULT_ACTION_TIMEOUT_MS 20000
39
40
41
42 #define PCMK_DEFAULT_METADATA_TIMEOUT_MS 30000
43
44
45 #define PCMK_ACTION_CANCEL "cancel"
46 #define PCMK_ACTION_CLEAR_FAILCOUNT "clear_failcount"
47 #define PCMK_ACTION_CLONE_ONE_OR_MORE "clone-one-or-more"
48 #define PCMK_ACTION_DELETE "delete"
49 #define PCMK_ACTION_DEMOTE "demote"
50 #define PCMK_ACTION_DEMOTED "demoted"
51 #define PCMK_ACTION_DO_SHUTDOWN "do_shutdown"
52 #define PCMK_ACTION_LIST "list"
53 #define PCMK_ACTION_LRM_DELETE "lrm_delete"
54 #define PCMK_ACTION_LOAD_STOPPED "load_stopped"
55 #define PCMK_ACTION_MAINTENANCE_NODES "maintenance_nodes"
56 #define PCMK_ACTION_META_DATA "meta-data"
57 #define PCMK_ACTION_METADATA "metadata"
58 #define PCMK_ACTION_MIGRATE_FROM "migrate_from"
59 #define PCMK_ACTION_MIGRATE_TO "migrate_to"
60 #define PCMK_ACTION_MONITOR "monitor"
61 #define PCMK_ACTION_NOTIFIED "notified"
62 #define PCMK_ACTION_NOTIFY "notify"
63 #define PCMK_ACTION_OFF "off"
64 #define PCMK_ACTION_ON "on"
65 #define PCMK_ACTION_ONE_OR_MORE "one-or-more"
66 #define PCMK_ACTION_PROMOTE "promote"
67 #define PCMK_ACTION_PROMOTED "promoted"
68 #define PCMK_ACTION_REBOOT "reboot"
69 #define PCMK_ACTION_RELOAD "reload"
70 #define PCMK_ACTION_RELOAD_AGENT "reload-agent"
71 #define PCMK_ACTION_RUNNING "running"
72 #define PCMK_ACTION_START "start"
73 #define PCMK_ACTION_STATUS "status"
74 #define PCMK_ACTION_STONITH "stonith"
75 #define PCMK_ACTION_STOP "stop"
76 #define PCMK_ACTION_STOPPED "stopped"
77 #define PCMK_ACTION_VALIDATE_ALL "validate-all"
78
79
80
81
82
83 enum action_tasks {
84 pcmk_action_unspecified = 0,
85 pcmk_action_monitor,
86
87
88
89 pcmk_action_stop,
90 pcmk_action_stopped,
91
92 pcmk_action_start,
93 pcmk_action_started,
94
95 pcmk_action_notify,
96 pcmk_action_notified,
97
98 pcmk_action_promote,
99 pcmk_action_promoted,
100
101 pcmk_action_demote,
102 pcmk_action_demoted,
103
104 pcmk_action_shutdown,
105 pcmk_action_fence,
106
107 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
108 no_action = pcmk_action_unspecified,
109 monitor_rsc = pcmk_action_monitor,
110 stop_rsc = pcmk_action_stop,
111 stopped_rsc = pcmk_action_stopped,
112 start_rsc = pcmk_action_start,
113 started_rsc = pcmk_action_started,
114 action_notify = pcmk_action_notify,
115 action_notified = pcmk_action_notified,
116 action_promote = pcmk_action_promote,
117 action_promoted = pcmk_action_promoted,
118 action_demote = pcmk_action_demote,
119 action_demoted = pcmk_action_demoted,
120 shutdown_crm = pcmk_action_shutdown,
121 stonith_node = pcmk_action_fence,
122 #endif
123 };
124
125
126
127
128
129
130 enum action_fail_response {
131
132
133
134
135
136
137
138
139
140
141
142
143
144 pcmk_on_fail_ignore = 0,
145
146
147 pcmk_on_fail_restart = 1,
148
149
150 pcmk_on_fail_ban = 2,
151
152
153 pcmk_on_fail_block = 3,
154
155
156 pcmk_on_fail_stop = 4,
157
158
159 pcmk_on_fail_standby_node = 5,
160
161
162 pcmk_on_fail_fence_node = 6,
163
164
165
166
167 pcmk_on_fail_restart_container = 7,
168
169
170
171
172
173
174
175 pcmk_on_fail_reset_remote = 8,
176
177
178 pcmk_on_fail_demote = 9,
179
180 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
181 action_fail_ignore = pcmk_on_fail_ignore,
182 action_fail_recover = pcmk_on_fail_restart,
183 action_fail_migrate = pcmk_on_fail_ban,
184 action_fail_block = pcmk_on_fail_block,
185 action_fail_stop = pcmk_on_fail_stop,
186 action_fail_standby = pcmk_on_fail_standby_node,
187 action_fail_fence = pcmk_on_fail_fence_node,
188 action_fail_restart_container = pcmk_on_fail_restart_container,
189 action_fail_reset_remote = pcmk_on_fail_reset_remote,
190 action_fail_demote = pcmk_on_fail_demote,
191 #endif
192 };
193
194
195
196
197
198
199 enum pe_action_flags {
200
201 pcmk_no_action_flags = 0,
202
203
204 pcmk_action_pseudo = (1 << 0),
205
206
207 pcmk_action_runnable = (1 << 1),
208
209
210 pcmk_action_optional = (1 << 2),
211
212
213 pcmk_action_always_in_graph = (1 << 3),
214
215
216 pcmk_action_attrs_evaluated = (1 << 4),
217
218
219 pcmk_action_migratable = (1 << 7),
220
221
222 pcmk_action_added_to_graph = (1 << 8),
223
224
225 pcmk_action_migration_abort = (1 << 11),
226
227
228
229
230
231
232
233 pcmk_action_min_runnable = (1 << 12),
234
235
236 pcmk_action_reschedule = (1 << 13),
237
238
239 pcmk_action_detect_loop = (1 << 14),
240
241
242 pcmk_action_inputs_deduplicated = (1 << 15),
243
244
245 pcmk_action_on_dc = (1 << 16),
246
247 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
248 pe_action_pseudo = pcmk_action_pseudo,
249 pe_action_runnable = pcmk_action_runnable,
250 pe_action_optional = pcmk_action_optional,
251 pe_action_print_always = pcmk_action_always_in_graph,
252 pe_action_have_node_attrs = pcmk_action_attrs_evaluated,
253 pe_action_implied_by_stonith = (1 << 6),
254 pe_action_migrate_runnable = pcmk_action_migratable,
255 pe_action_dumped = pcmk_action_added_to_graph,
256 pe_action_processed = (1 << 9),
257 pe_action_clear = (1 << 10),
258 pe_action_dangle = pcmk_action_migration_abort,
259 pe_action_requires_any = pcmk_action_min_runnable,
260 pe_action_reschedule = pcmk_action_reschedule,
261 pe_action_tracking = pcmk_action_detect_loop,
262 pe_action_dedup = pcmk_action_inputs_deduplicated,
263 pe_action_dc = pcmk_action_on_dc,
264 #endif
265 };
266
267
268
269
270
271
272
273
274
275 enum pe_link_state {
276 pe_link_not_dumped = 0,
277 pe_link_dumped = 1,
278 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
279 pe_link_dup = 2,
280 #endif
281 };
282
283 enum pe_ordering {
284 pe_order_none = 0x0,
285 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
286 pe_order_optional = 0x1,
287 pe_order_apply_first_non_migratable = 0x2,
288 pe_order_implies_first = 0x10,
289 pe_order_implies_then = 0x20,
290 pe_order_promoted_implies_first = 0x40,
291 pe_order_implies_first_migratable = 0x80,
292 pe_order_runnable_left = 0x100,
293 pe_order_pseudo_left = 0x200,
294 pe_order_implies_then_on_node = 0x400,
295 pe_order_probe = 0x800,
296 pe_order_restart = 0x1000,
297 pe_order_stonith_stop = 0x2000,
298 pe_order_serialize_only = 0x4000,
299 pe_order_same_node = 0x8000,
300 pe_order_implies_first_printed = 0x10000,
301 pe_order_implies_then_printed = 0x20000,
302 pe_order_asymmetrical = 0x100000,
303 pe_order_load = 0x200000,
304 pe_order_one_or_more = 0x400000,
305 pe_order_anti_colocation = 0x800000,
306 pe_order_preserve = 0x1000000,
307 pe_order_then_cancels_first = 0x2000000,
308 pe_order_trace = 0x4000000,
309 pe_order_implies_first_master = pe_order_promoted_implies_first,
310 #endif
311 };
312
313
314
315 struct pe_action_wrapper_s {
316
317 enum pe_ordering type;
318
319
320 enum pe_link_state state;
321
322 pcmk_action_t *action;
323 };
324
325
326
327
328
329
330 struct pe_action_s {
331 int id;
332
333
334
335
336
337
338 int priority;
339
340 pcmk_resource_t *rsc;
341 pcmk_node_t *node;
342 xmlNode *op_entry;
343 char *task;
344 char *uuid;
345 char *cancel_task;
346 char *reason;
347
348
349 enum pe_action_flags flags;
350
351 enum rsc_start_requirement needs;
352 enum action_fail_response on_fail;
353 enum rsc_role_e fail_role;
354 GHashTable *meta;
355 GHashTable *extra;
356
357
358
359
360 int runnable_before;
361
362
363
364
365
366
367 int required_runnable_before;
368
369
370 GList *actions_before;
371 GList *actions_after;
372
373
374
375
376
377 void *action_details;
378 };
379
380
381
382
383 const char *pcmk_action_text(enum action_tasks action);
384
385
386
387 enum action_tasks pcmk_parse_action(const char *action_name);
388
389
390
391 const char *pcmk_on_fail_text(enum action_fail_response on_fail);
392
393
394 gboolean parse_op_key(const char *key, char **rsc_id, char **op_type,
395 guint *interval_ms);
396 gboolean decode_transition_key(const char *key, char **uuid, int *transition_id,
397 int *action_id, int *target_rc);
398 gboolean decode_transition_magic(const char *magic, char **uuid,
399 int *transition_id, int *action_id,
400 int *op_status, int *op_rc, int *target_rc);
401
402
403 int rsc_op_expected_rc(const lrmd_event_data_t *event);
404 gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc);
405
406 bool crm_op_needs_metadata(const char *rsc_class, const char *op);
407
408 xmlNode *crm_create_op_xml(xmlNode *parent, const char *prefix,
409 const char *task, const char *interval_spec,
410 const char *timeout);
411
412 bool pcmk_is_probe(const char *task, guint interval);
413 bool pcmk_xe_is_probe(const xmlNode *xml_op);
414 bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op);
415
416 #ifdef __cplusplus
417 }
418 #endif
419
420 #endif