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