1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__CRM_PENGINE_PE_TYPES__H
11 # define PCMK__CRM_PENGINE_PE_TYPES__H
12
13
14 # include <stdbool.h>
15 # include <sys/types.h>
16 # include <libxml/tree.h>
17 # include <glib.h>
18 # include <crm/common/iso8601.h>
19 # include <crm/pengine/common.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25
26
27
28
29
30
31 typedef struct pe_node_s pe_node_t;
32 typedef struct pe_action_s pe_action_t;
33 typedef struct pe_resource_s pe_resource_t;
34 typedef struct pe_working_set_s pe_working_set_t;
35
36 enum pe_obj_types {
37 pe_unknown = -1,
38 pe_native = 0,
39 pe_group = 1,
40 pe_clone = 2,
41 pe_container = 3,
42 };
43
44 typedef struct resource_object_functions_s {
45 gboolean (*unpack) (pe_resource_t*, pe_working_set_t*);
46 pe_resource_t *(*find_rsc) (pe_resource_t *parent, const char *search,
47 const pe_node_t *node, int flags);
48
49 char *(*parameter) (pe_resource_t*, pe_node_t*, gboolean, const char*,
50 pe_working_set_t*);
51
52 void (*print) (pe_resource_t*, const char*, long, void*);
53 gboolean (*active) (pe_resource_t*, gboolean);
54 enum rsc_role_e (*state) (const pe_resource_t*, gboolean);
55 pe_node_t *(*location) (const pe_resource_t*, GList**, int);
56 void (*free) (pe_resource_t*);
57 void (*count) (pe_resource_t*);
58 gboolean (*is_filtered) (const pe_resource_t*, GList *, gboolean);
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 pe_node_t *(*active_node)(const pe_resource_t *rsc, unsigned int *count_all,
74 unsigned int *count_clean);
75 } resource_object_functions_t;
76
77 typedef struct resource_alloc_functions_s resource_alloc_functions_t;
78
79 enum pe_quorum_policy {
80 no_quorum_freeze,
81 no_quorum_stop,
82 no_quorum_ignore,
83 no_quorum_suicide,
84 no_quorum_demote
85 };
86
87 enum node_type {
88 node_ping,
89 node_member,
90 node_remote
91 };
92
93
94 enum pe_restart {
95 pe_restart_restart,
96 pe_restart_ignore
97 };
98
99
100 enum pe_find {
101 pe_find_renamed = 0x001,
102 pe_find_anon = 0x002,
103 pe_find_clone = 0x004,
104 pe_find_current = 0x008,
105 pe_find_inactive = 0x010,
106 pe_find_any = 0x020,
107 };
108
109
110
111 # define pe_flag_have_quorum 0x00000001ULL
112 # define pe_flag_symmetric_cluster 0x00000002ULL
113 # define pe_flag_maintenance_mode 0x00000008ULL
114
115 # define pe_flag_stonith_enabled 0x00000010ULL
116 # define pe_flag_have_stonith_resource 0x00000020ULL
117 # define pe_flag_enable_unfencing 0x00000040ULL
118 # define pe_flag_concurrent_fencing 0x00000080ULL
119
120 # define pe_flag_stop_rsc_orphans 0x00000100ULL
121 # define pe_flag_stop_action_orphans 0x00000200ULL
122 # define pe_flag_stop_everything 0x00000400ULL
123
124 # define pe_flag_start_failure_fatal 0x00001000ULL
125
126
127 # define pe_flag_remove_after_stop 0x00002000ULL
128
129 # define pe_flag_startup_fencing 0x00004000ULL
130 # define pe_flag_shutdown_lock 0x00008000ULL
131
132 # define pe_flag_startup_probes 0x00010000ULL
133 # define pe_flag_have_status 0x00020000ULL
134 # define pe_flag_have_remote_nodes 0x00040000ULL
135
136 # define pe_flag_quick_location 0x00100000ULL
137 # define pe_flag_sanitized 0x00200000ULL
138
139
140 # define pe_flag_stdout 0x00400000ULL
141
142
143 # define pe_flag_no_counts 0x00800000ULL
144
145
146
147
148 # define pe_flag_no_compat 0x01000000ULL
149
150 # define pe_flag_show_scores 0x02000000ULL
151 # define pe_flag_show_utilization 0x04000000ULL
152
153
154
155
156
157 # define pe_flag_check_config 0x08000000ULL
158
159 struct pe_working_set_s {
160 xmlNode *input;
161 crm_time_t *now;
162
163
164 char *dc_uuid;
165 pe_node_t *dc_node;
166 const char *stonith_action;
167 const char *placement_strategy;
168
169 unsigned long long flags;
170
171 int stonith_timeout;
172 enum pe_quorum_policy no_quorum_policy;
173
174 GHashTable *config_hash;
175 GHashTable *tickets;
176
177
178 GHashTable *singletons;
179
180 GList *nodes;
181 GList *resources;
182 GList *placement_constraints;
183 GList *ordering_constraints;
184 GList *colocation_constraints;
185 GList *ticket_constraints;
186
187 GList *actions;
188 xmlNode *failed;
189 xmlNode *op_defaults;
190 xmlNode *rsc_defaults;
191
192
193 int num_synapse;
194 int max_valid_nodes;
195 int order_id;
196 int action_id;
197
198
199 xmlNode *graph;
200
201 GHashTable *template_rsc_sets;
202 const char *localhost;
203 GHashTable *tags;
204
205 int blocked_resources;
206 int disabled_resources;
207
208 GList *param_check;
209 GList *stop_needed;
210 time_t recheck_by;
211 int ninstances;
212 guint shutdown_lock;
213 int priority_fencing_delay;
214
215 void *priv;
216 };
217
218 enum pe_check_parameters {
219
220
221
222 pe_check_last_failure,
223
224
225
226
227 pe_check_active,
228 };
229
230 struct pe_node_shared_s {
231 const char *id;
232 const char *uname;
233 enum node_type type;
234
235
236 gboolean online;
237 gboolean standby;
238 gboolean standby_onfail;
239 gboolean pending;
240 gboolean unclean;
241 gboolean unseen;
242 gboolean shutdown;
243 gboolean expected_up;
244 gboolean is_dc;
245 gboolean maintenance;
246 gboolean rsc_discovery_enabled;
247 gboolean remote_requires_reset;
248 gboolean remote_was_fenced;
249 gboolean remote_maintenance;
250 gboolean unpacked;
251
252 int num_resources;
253 pe_resource_t *remote_rsc;
254 GList *running_rsc;
255 GList *allocated_rsc;
256
257 GHashTable *attrs;
258 GHashTable *utilization;
259 GHashTable *digest_cache;
260 int priority;
261 pe_working_set_t *data_set;
262 };
263
264 struct pe_node_s {
265 int weight;
266 gboolean fixed;
267 int count;
268 struct pe_node_shared_s *details;
269 int rsc_discover_mode;
270 };
271
272 # define pe_rsc_orphan 0x00000001ULL
273 # define pe_rsc_managed 0x00000002ULL
274 # define pe_rsc_block 0x00000004ULL
275 # define pe_rsc_orphan_container_filler 0x00000008ULL
276
277 # define pe_rsc_notify 0x00000010ULL
278 # define pe_rsc_unique 0x00000020ULL
279 # define pe_rsc_fence_device 0x00000040ULL
280 # define pe_rsc_promotable 0x00000080ULL
281
282 # define pe_rsc_provisional 0x00000100ULL
283 # define pe_rsc_allocating 0x00000200ULL
284 # define pe_rsc_merging 0x00000400ULL
285 # define pe_rsc_restarting 0x00000800ULL
286
287 # define pe_rsc_stop 0x00001000ULL
288 # define pe_rsc_reload 0x00002000ULL
289 # define pe_rsc_allow_remote_remotes 0x00004000ULL
290 # define pe_rsc_critical 0x00008000ULL
291
292 # define pe_rsc_failed 0x00010000ULL
293 # define pe_rsc_detect_loop 0x00020000ULL
294 # define pe_rsc_runnable 0x00040000ULL
295 # define pe_rsc_start_pending 0x00080000ULL
296
297
298 # define pe_rsc_starting 0x00100000ULL
299
300
301 # define pe_rsc_stopping 0x00200000ULL
302
303 # define pe_rsc_stop_unexpected 0x00400000ULL
304 # define pe_rsc_allow_migrate 0x00800000ULL
305
306 # define pe_rsc_failure_ignored 0x01000000ULL
307 # define pe_rsc_replica_container 0x02000000ULL
308 # define pe_rsc_maintenance 0x04000000ULL
309 # define pe_rsc_is_container 0x08000000ULL
310
311 # define pe_rsc_needs_quorum 0x10000000ULL
312 # define pe_rsc_needs_fencing 0x20000000ULL
313 # define pe_rsc_needs_unfencing 0x40000000ULL
314
315
316 enum pe_action_flags {
317 pe_action_pseudo = 0x00001,
318 pe_action_runnable = 0x00002,
319 pe_action_optional = 0x00004,
320 pe_action_print_always = 0x00008,
321
322 pe_action_have_node_attrs = 0x00010,
323 pe_action_implied_by_stonith = 0x00040,
324 pe_action_migrate_runnable = 0x00080,
325
326 pe_action_dumped = 0x00100,
327 pe_action_processed = 0x00200,
328 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
329 pe_action_clear = 0x00400,
330 #endif
331 pe_action_dangle = 0x00800,
332
333
334
335
336 pe_action_requires_any = 0x01000,
337
338 pe_action_reschedule = 0x02000,
339 pe_action_tracking = 0x04000,
340 pe_action_dedup = 0x08000,
341
342 pe_action_dc = 0x10000,
343 };
344
345
346 struct pe_resource_s {
347 char *id;
348 char *clone_name;
349 xmlNode *xml;
350 xmlNode *orig_xml;
351 xmlNode *ops_xml;
352
353 pe_working_set_t *cluster;
354 pe_resource_t *parent;
355
356 enum pe_obj_types variant;
357 void *variant_opaque;
358 resource_object_functions_t *fns;
359 resource_alloc_functions_t *cmds;
360
361 enum rsc_recovery_type recovery_type;
362
363 enum pe_restart restart_type;
364
365 int priority;
366 int stickiness;
367 int sort_index;
368 int failure_timeout;
369 int migration_threshold;
370 guint remote_reconnect_ms;
371 char *pending_task;
372
373 unsigned long long flags;
374
375
376 gboolean is_remote_node;
377 gboolean exclusive_discover;
378
379
380
381
382
383
384
385
386
387
388 GList *rsc_cons_lhs;
389 GList *rsc_cons;
390 GList *rsc_location;
391 GList *actions;
392 GList *rsc_tickets;
393
394
395 pe_node_t *allocated_to;
396 pe_node_t *partial_migration_target;
397 pe_node_t *partial_migration_source;
398 GList *running_on;
399 GHashTable *known_on;
400 GHashTable *allowed_nodes;
401
402 enum rsc_role_e role;
403 enum rsc_role_e next_role;
404
405 GHashTable *meta;
406 GHashTable *parameters;
407 GHashTable *utilization;
408
409 GList *children;
410 GList *dangling_migrations;
411
412 pe_resource_t *container;
413 GList *fillers;
414
415
416 pe_node_t *pending_node;
417 pe_node_t *lock_node;
418
419 time_t lock_time;
420
421
422
423
424
425
426 GHashTable *parameter_cache;
427 };
428
429 struct pe_action_s {
430 int id;
431 int priority;
432
433 pe_resource_t *rsc;
434 pe_node_t *node;
435 xmlNode *op_entry;
436
437 char *task;
438 char *uuid;
439 char *cancel_task;
440 char *reason;
441
442 enum pe_action_flags flags;
443 enum rsc_start_requirement needs;
444 enum action_fail_response on_fail;
445 enum rsc_role_e fail_role;
446
447 GHashTable *meta;
448 GHashTable *extra;
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465 int runnable_before;
466
467
468 int required_runnable_before;
469
470 GList *actions_before;
471 GList *actions_after;
472
473
474
475
476 void *action_details;
477 };
478
479 typedef struct pe_ticket_s {
480 char *id;
481 gboolean granted;
482 time_t last_granted;
483 gboolean standby;
484 GHashTable *state;
485 } pe_ticket_t;
486
487 typedef struct pe_tag_s {
488 char *id;
489 GList *refs;
490 } pe_tag_t;
491
492
493 enum pe_link_state {
494 pe_link_not_dumped,
495 pe_link_dumped,
496 pe_link_dup,
497 };
498
499 enum pe_discover_e {
500 pe_discover_always = 0,
501 pe_discover_never,
502 pe_discover_exclusive,
503 };
504
505
506 enum pe_ordering {
507 pe_order_none = 0x0,
508 pe_order_optional = 0x1,
509 pe_order_apply_first_non_migratable = 0x2,
510
511 pe_order_implies_first = 0x10,
512 pe_order_implies_then = 0x20,
513 pe_order_promoted_implies_first = 0x40,
514
515
516 pe_order_implies_first_migratable = 0x80,
517
518 pe_order_runnable_left = 0x100,
519
520 pe_order_pseudo_left = 0x200,
521 pe_order_implies_then_on_node = 0x400,
522
523
524
525 pe_order_probe = 0x800,
526
527
528
529
530 pe_order_restart = 0x1000,
531 pe_order_stonith_stop = 0x2000,
532 pe_order_serialize_only = 0x4000,
533 pe_order_same_node = 0x8000,
534
535 pe_order_implies_first_printed = 0x10000,
536 pe_order_implies_then_printed = 0x20000,
537
538 pe_order_asymmetrical = 0x100000,
539 pe_order_load = 0x200000,
540 pe_order_one_or_more = 0x400000,
541 pe_order_anti_colocation = 0x800000,
542
543 pe_order_preserve = 0x1000000,
544 pe_order_then_cancels_first = 0x2000000,
545 pe_order_trace = 0x4000000,
546
547 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
548
549 pe_order_implies_first_master = pe_order_promoted_implies_first,
550 #endif
551 };
552
553
554 typedef struct pe_action_wrapper_s {
555 enum pe_ordering type;
556 enum pe_link_state state;
557 pe_action_t *action;
558 } pe_action_wrapper_t;
559
560 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
561 #include <crm/pengine/pe_types_compat.h>
562 #endif
563
564 #ifdef __cplusplus
565 }
566 #endif
567
568 #endif