This source file includes following definitions.
- pe_base_name_eq
- pe__health_strategy
- pe__health_score
1
2
3
4
5
6
7
8
9
10 #ifndef PE_INTERNAL__H
11 # define PE_INTERNAL__H
12
13 # include <stdbool.h>
14 # include <stdint.h>
15 # include <string.h>
16 # include <crm/common/xml.h>
17 # include <crm/pengine/status.h>
18 # include <crm/pengine/remote_internal.h>
19 # include <crm/common/internal.h>
20 # include <crm/common/options_internal.h>
21 # include <crm/common/output_internal.h>
22 # include <crm/common/scheduler_internal.h>
23
24 const char *pe__resource_description(const pcmk_resource_t *rsc,
25 uint32_t show_opts);
26
27 bool pe__clone_is_ordered(const pcmk_resource_t *clone);
28 int pe__set_clone_flag(pcmk_resource_t *clone, enum pcmk__clone_flags flag);
29 bool pe__clone_flag_is_set(const pcmk_resource_t *clone, uint32_t flags);
30
31 bool pe__group_flag_is_set(const pcmk_resource_t *group, uint32_t flags);
32 pcmk_resource_t *pe__last_group_member(const pcmk_resource_t *group);
33
34 const pcmk_resource_t *pe__const_top_resource(const pcmk_resource_t *rsc,
35 bool include_bundle);
36
37 int pe__clone_max(const pcmk_resource_t *clone);
38 int pe__clone_node_max(const pcmk_resource_t *clone);
39 int pe__clone_promoted_max(const pcmk_resource_t *clone);
40 int pe__clone_promoted_node_max(const pcmk_resource_t *clone);
41 void pe__create_clone_notifications(pcmk_resource_t *clone);
42 void pe__free_clone_notification_data(pcmk_resource_t *clone);
43 void pe__create_clone_notif_pseudo_ops(pcmk_resource_t *clone,
44 pcmk_action_t *start,
45 pcmk_action_t *started,
46 pcmk_action_t *stop,
47 pcmk_action_t *stopped);
48
49 pcmk_action_t *pe__new_rsc_pseudo_action(pcmk_resource_t *rsc, const char *task,
50 bool optional, bool runnable);
51
52 void pe__create_promotable_pseudo_ops(pcmk_resource_t *clone,
53 bool any_promoting, bool any_demoting);
54
55 bool pe_can_fence(const pcmk_scheduler_t *scheduler, const pcmk_node_t *node);
56
57 char *native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create,
58 const char *name, pcmk_scheduler_t *scheduler);
59 pcmk_node_t *native_location(const pcmk_resource_t *rsc, GList **list,
60 int current);
61 void native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node,
62 pcmk_scheduler_t *scheduler, gboolean failed);
63
64 gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
65 gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
66 gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
67 gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
68
69 pcmk_resource_t *native_find_rsc(pcmk_resource_t *rsc, const char *id,
70 const pcmk_node_t *node, int flags);
71
72 gboolean native_active(pcmk_resource_t *rsc, gboolean all);
73 gboolean group_active(pcmk_resource_t *rsc, gboolean all);
74 gboolean clone_active(pcmk_resource_t *rsc, gboolean all);
75 gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all);
76
77
78 void native_print(pcmk_resource_t *rsc, const char *pre_text, long options,
79 void *print_data);
80
81
82 void group_print(pcmk_resource_t *rsc, const char *pre_text, long options,
83 void *print_data);
84
85
86 void clone_print(pcmk_resource_t *rsc, const char *pre_text, long options,
87 void *print_data);
88
89
90 void pe__print_bundle(pcmk_resource_t *rsc, const char *pre_text, long options,
91 void *print_data);
92
93 gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name,
94 const pcmk_node_t *node, uint32_t show_opts,
95 const char *target_role, bool show_nodes);
96
97 int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name,
98 ...) G_GNUC_NULL_TERMINATED;
99 char *pe__node_display_name(pcmk_node_t *node, bool print_detail);
100
101
102
103 void pe__order_notifs_after_fencing(const pcmk_action_t *action,
104 pcmk_resource_t *rsc,
105 pcmk_action_t *stonith_op);
106
107
108
109 int pe__clone_xml(pcmk__output_t *out, va_list args);
110 int pe__clone_default(pcmk__output_t *out, va_list args);
111 int pe__group_xml(pcmk__output_t *out, va_list args);
112 int pe__group_default(pcmk__output_t *out, va_list args);
113 int pe__bundle_xml(pcmk__output_t *out, va_list args);
114 int pe__bundle_html(pcmk__output_t *out, va_list args);
115 int pe__bundle_text(pcmk__output_t *out, va_list args);
116 int pe__node_html(pcmk__output_t *out, va_list args);
117 int pe__node_text(pcmk__output_t *out, va_list args);
118 int pe__node_xml(pcmk__output_t *out, va_list args);
119 int pe__resource_xml(pcmk__output_t *out, va_list args);
120 int pe__resource_html(pcmk__output_t *out, va_list args);
121 int pe__resource_text(pcmk__output_t *out, va_list args);
122
123 void native_free(pcmk_resource_t *rsc);
124 void group_free(pcmk_resource_t *rsc);
125 void clone_free(pcmk_resource_t *rsc);
126 void pe__free_bundle(pcmk_resource_t *rsc);
127
128 enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc,
129 gboolean current);
130 enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc,
131 gboolean current);
132 enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc,
133 gboolean current);
134 enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc,
135 gboolean current);
136
137 void pe__count_common(pcmk_resource_t *rsc);
138 void pe__count_bundle(pcmk_resource_t *rsc);
139
140 void common_free(pcmk_resource_t *rsc);
141
142 pcmk_node_t *pe__copy_node(const pcmk_node_t *this_node);
143 time_t get_effective_time(pcmk_scheduler_t *scheduler);
144
145
146
147 int pe_get_failcount(const pcmk_node_t *node, pcmk_resource_t *rsc,
148 time_t *last_failure, uint32_t flags,
149 const xmlNode *xml_op);
150
151 pcmk_action_t *pe__clear_failcount(pcmk_resource_t *rsc,
152 const pcmk_node_t *node, const char *reason,
153 pcmk_scheduler_t *scheduler);
154
155
156
157 bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node,
158 pcmk_node_t **active, unsigned int *count_all,
159 unsigned int *count_clean);
160
161 pcmk_node_t *pe__find_active_requires(const pcmk_resource_t *rsc,
162 unsigned int *count);
163
164
165 GHashTable *pe__node_list2table(const GList *list);
166
167 pcmk_action_t *get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler);
168 gboolean order_actions(pcmk_action_t *lh_action, pcmk_action_t *rh_action,
169 uint32_t flags);
170
171 void pe__show_node_scores_as(const char *file, const char *function,
172 int line, bool to_log, const pcmk_resource_t *rsc,
173 const char *comment, GHashTable *nodes,
174 pcmk_scheduler_t *scheduler);
175
176 #define pe__show_node_scores(level, rsc, text, nodes, scheduler) \
177 pe__show_node_scores_as(__FILE__, __func__, __LINE__, \
178 (level), (rsc), (text), (nodes), (scheduler))
179
180 GHashTable *pcmk__unpack_action_meta(pcmk_resource_t *rsc,
181 const pcmk_node_t *node,
182 const char *action_name, guint interval_ms,
183 const xmlNode *action_config);
184 GHashTable *pcmk__unpack_action_rsc_params(const xmlNode *action_xml,
185 GHashTable *node_attrs,
186 pcmk_scheduler_t *data_set);
187 xmlNode *pcmk__find_action_config(const pcmk_resource_t *rsc,
188 const char *action_name, guint interval_ms,
189 bool include_disabled);
190
191 enum rsc_start_requirement pcmk__action_requires(const pcmk_resource_t *rsc,
192 const char *action_name);
193
194 enum action_fail_response pcmk__parse_on_fail(const pcmk_resource_t *rsc,
195 const char *action_name,
196 guint interval_ms,
197 const char *value);
198
199 enum rsc_role_e pcmk__role_after_failure(const pcmk_resource_t *rsc,
200 const char *action_name,
201 enum action_fail_response on_fail,
202 GHashTable *meta);
203
204 pcmk_action_t *custom_action(pcmk_resource_t *rsc, char *key, const char *task,
205 const pcmk_node_t *on_node, gboolean optional,
206 pcmk_scheduler_t *scheduler);
207
208 # define delete_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_DELETE, 0)
209 # define delete_action(rsc, node, optional) custom_action( \
210 rsc, delete_key(rsc), PCMK_ACTION_DELETE, node, \
211 optional, rsc->cluster);
212
213 # define stop_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_STOP, 0)
214 # define stop_action(rsc, node, optional) custom_action( \
215 rsc, stop_key(rsc), PCMK_ACTION_STOP, node, \
216 optional, rsc->cluster);
217
218 # define reload_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_RELOAD_AGENT, 0)
219 # define start_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_START, 0)
220 # define start_action(rsc, node, optional) custom_action( \
221 rsc, start_key(rsc), PCMK_ACTION_START, node, \
222 optional, rsc->cluster)
223
224 # define promote_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_PROMOTE, 0)
225 # define promote_action(rsc, node, optional) custom_action( \
226 rsc, promote_key(rsc), PCMK_ACTION_PROMOTE, node, \
227 optional, rsc->cluster)
228
229 # define demote_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_DEMOTE, 0)
230 # define demote_action(rsc, node, optional) custom_action( \
231 rsc, demote_key(rsc), PCMK_ACTION_DEMOTE, node, \
232 optional, rsc->cluster)
233
234 pcmk_action_t *find_first_action(const GList *input, const char *uuid,
235 const char *task, const pcmk_node_t *on_node);
236
237 enum action_tasks get_complex_task(const pcmk_resource_t *rsc,
238 const char *name);
239
240 GList *find_actions(GList *input, const char *key, const pcmk_node_t *on_node);
241 GList *find_actions_exact(GList *input, const char *key,
242 const pcmk_node_t *on_node);
243 GList *pe__resource_actions(const pcmk_resource_t *rsc, const pcmk_node_t *node,
244 const char *task, bool require_node);
245
246 extern void pe_free_action(pcmk_action_t *action);
247
248 void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score,
249 const char *tag, pcmk_scheduler_t *scheduler);
250
251 extern int pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
252 bool same_node_default);
253 extern gint sort_op_by_callid(gconstpointer a, gconstpointer b);
254 gboolean get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role);
255 void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role,
256 const char *why);
257
258 pcmk_resource_t *find_clone_instance(const pcmk_resource_t *rsc,
259 const char *sub_id);
260
261 extern void destroy_ticket(gpointer data);
262 pcmk_ticket_t *ticket_new(const char *ticket_id, pcmk_scheduler_t *scheduler);
263
264
265 const char *pe_base_name_end(const char *id);
266 char *clone_strip(const char *last_rsc_id);
267 char *clone_zero(const char *last_rsc_id);
268
269 static inline bool
270 pe_base_name_eq(const pcmk_resource_t *rsc, const char *id)
271 {
272 if (id && rsc && rsc->id) {
273
274 size_t base_len = pe_base_name_end(rsc->id) - rsc->id + 1;
275
276 return (strlen(id) == base_len) && !strncmp(id, rsc->id, base_len);
277 }
278 return false;
279 }
280
281 int pe__target_rc_from_xml(const xmlNode *xml_op);
282
283 gint pe__cmp_node_name(gconstpointer a, gconstpointer b);
284 bool is_set_recursive(const pcmk_resource_t *rsc, long long flag, bool any);
285
286 pcmk__op_digest_t *pe__calculate_digests(pcmk_resource_t *rsc, const char *task,
287 guint *interval_ms,
288 const pcmk_node_t *node,
289 const xmlNode *xml_op,
290 GHashTable *overrides,
291 bool calc_secure,
292 pcmk_scheduler_t *scheduler);
293
294 void pe__free_digests(gpointer ptr);
295
296 pcmk__op_digest_t *rsc_action_digest_cmp(pcmk_resource_t *rsc,
297 const xmlNode *xml_op,
298 pcmk_node_t *node,
299 pcmk_scheduler_t *scheduler);
300
301 pcmk_action_t *pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
302 const char *reason, bool priority_delay,
303 pcmk_scheduler_t *scheduler);
304 void trigger_unfencing(pcmk_resource_t *rsc, pcmk_node_t *node,
305 const char *reason, pcmk_action_t *dependency,
306 pcmk_scheduler_t *scheduler);
307
308 char *pe__action2reason(const pcmk_action_t *action, enum pe_action_flags flag);
309 void pe_action_set_reason(pcmk_action_t *action, const char *reason,
310 bool overwrite);
311 void pe__add_action_expected_result(pcmk_action_t *action, int expected_result);
312
313 void pe__set_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags);
314 void pe__clear_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags);
315 void pe__clear_resource_flags_on_all(pcmk_scheduler_t *scheduler,
316 uint64_t flag);
317
318 gboolean add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref);
319
320
321 void print_rscs_brief(GList *rsc_list, const char * pre_text, long options,
322 void * print_data, gboolean print_all);
323 int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options);
324 void pe_fence_node(pcmk_scheduler_t *scheduler, pcmk_node_t *node,
325 const char *reason, bool priority_delay);
326
327 pcmk_node_t *pe_create_node(const char *id, const char *uname, const char *type,
328 const char *score, pcmk_scheduler_t *scheduler);
329
330
331 void common_print(pcmk_resource_t *rsc, const char *pre_text, const char *name,
332 const pcmk_node_t *node, long options, void *print_data);
333 int pe__common_output_text(pcmk__output_t *out, const pcmk_resource_t *rsc,
334 const char *name, const pcmk_node_t *node,
335 unsigned int options);
336 int pe__common_output_html(pcmk__output_t *out, const pcmk_resource_t *rsc,
337 const char *name, const pcmk_node_t *node,
338 unsigned int options);
339
340 GList *pe__bundle_containers(const pcmk_resource_t *bundle);
341
342 int pe__bundle_max(const pcmk_resource_t *rsc);
343 bool pe__node_is_bundle_instance(const pcmk_resource_t *bundle,
344 const pcmk_node_t *node);
345 pcmk_resource_t *pe__bundled_resource(const pcmk_resource_t *rsc);
346 const pcmk_resource_t *pe__get_rsc_in_container(const pcmk_resource_t *instance);
347 pcmk_resource_t *pe__first_container(const pcmk_resource_t *bundle);
348 void pe__foreach_bundle_replica(pcmk_resource_t *bundle,
349 bool (*fn)(pcmk__bundle_replica_t *, void *),
350 void *user_data);
351 void pe__foreach_const_bundle_replica(const pcmk_resource_t *bundle,
352 bool (*fn)(const pcmk__bundle_replica_t *,
353 void *),
354 void *user_data);
355 pcmk_resource_t *pe__find_bundle_replica(const pcmk_resource_t *bundle,
356 const pcmk_node_t *node);
357 bool pe__bundle_needs_remote_name(pcmk_resource_t *rsc);
358 const char *pe__add_bundle_remote_name(pcmk_resource_t *rsc, xmlNode *xml,
359 const char *field);
360 bool pe__is_universal_clone(const pcmk_resource_t *rsc,
361 const pcmk_scheduler_t *scheduler);
362 void pe__add_param_check(const xmlNode *rsc_op, pcmk_resource_t *rsc,
363 pcmk_node_t *node, enum pcmk__check_parameters,
364 pcmk_scheduler_t *scheduler);
365 void pe__foreach_param_check(pcmk_scheduler_t *scheduler,
366 void (*cb)(pcmk_resource_t*, pcmk_node_t*,
367 const xmlNode*,
368 enum pcmk__check_parameters));
369 void pe__free_param_checks(pcmk_scheduler_t *scheduler);
370
371 bool pe__shutdown_requested(const pcmk_node_t *node);
372 void pe__update_recheck_time(time_t recheck, pcmk_scheduler_t *scheduler,
373 const char *reason);
374
375
376
377
378
379
380
381 void pe__register_messages(pcmk__output_t *out);
382
383 void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name,
384 const pe_rule_eval_data_t *rule_data,
385 GHashTable *hash, const char *always_first,
386 gboolean overwrite,
387 pcmk_scheduler_t *scheduler);
388
389 bool pe__resource_is_disabled(const pcmk_resource_t *rsc);
390 void pe__clear_resource_history(pcmk_resource_t *rsc, const pcmk_node_t *node);
391
392 GList *pe__rscs_with_tag(pcmk_scheduler_t *scheduler, const char *tag_name);
393 GList *pe__unames_with_tag(pcmk_scheduler_t *scheduler, const char *tag_name);
394 bool pe__rsc_has_tag(pcmk_scheduler_t *scheduler, const char *rsc,
395 const char *tag);
396 bool pe__uname_has_tag(pcmk_scheduler_t *scheduler, const char *node,
397 const char *tag);
398
399 bool pe__rsc_running_on_only(const pcmk_resource_t *rsc,
400 const pcmk_node_t *node);
401 bool pe__rsc_running_on_any(pcmk_resource_t *rsc, GList *node_list);
402 GList *pe__filter_rsc_list(GList *rscs, GList *filter);
403 GList * pe__build_node_name_list(pcmk_scheduler_t *scheduler, const char *s);
404 GList * pe__build_rsc_list(pcmk_scheduler_t *scheduler, const char *s);
405
406 bool pcmk__rsc_filtered_by_node(pcmk_resource_t *rsc, GList *only_node);
407
408 gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
409 gboolean check_parent);
410 gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
411 gboolean check_parent);
412 gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
413 gboolean check_parent);
414 gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
415 gboolean check_parent);
416
417 xmlNode *pe__failed_probe_for_rsc(const pcmk_resource_t *rsc, const char *name);
418
419 const char *pe__clone_child_id(const pcmk_resource_t *rsc);
420
421 int pe__sum_node_health_scores(const pcmk_node_t *node, int base_health);
422 int pe__node_health(pcmk_node_t *node);
423
424 static inline enum pcmk__health_strategy
425 pe__health_strategy(pcmk_scheduler_t *scheduler)
426 {
427 const char *strategy = pcmk__cluster_option(scheduler->config_hash,
428 PCMK_OPT_NODE_HEALTH_STRATEGY);
429
430 return pcmk__parse_health_strategy(strategy);
431 }
432
433 static inline int
434 pe__health_score(const char *option, pcmk_scheduler_t *scheduler)
435 {
436 const char *value = pcmk__cluster_option(scheduler->config_hash, option);
437
438 return char2score(value);
439 }
440
441 #endif