root/include/crm/pengine/internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pe__rsc_bool_str
  2. pe__current_node
  3. pe_base_name_eq
  4. pe__health_strategy
  5. pe__health_score
  6. pe__node_name
  7. pe__same_node
  8. pe__xe_history_key

   1 /*
   2  * Copyright 2004-2023 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   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/msg_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 
  35 #  define pe_rsc_info(rsc, fmt, args...)  crm_log_tag(LOG_INFO,  rsc ? rsc->id : "<NULL>", fmt, ##args)
  36 #  define pe_rsc_debug(rsc, fmt, args...) crm_log_tag(LOG_DEBUG, rsc ? rsc->id : "<NULL>", fmt, ##args)
  37 #  define pe_rsc_trace(rsc, fmt, args...) crm_log_tag(LOG_TRACE, rsc ? rsc->id : "<NULL>", fmt, ##args)
  38 
  39 #  define pe_err(fmt...) do {           \
  40         was_processing_error = TRUE;    \
  41         pcmk__config_err(fmt);          \
  42     } while (0)
  43 
  44 #  define pe_warn(fmt...) do {          \
  45         was_processing_warning = TRUE;  \
  46         pcmk__config_warn(fmt);         \
  47     } while (0)
  48 
  49 #  define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); }
  50 #  define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); }
  51 
  52 #define pe__set_working_set_flags(scheduler, flags_to_set) do {             \
  53         (scheduler)->flags = pcmk__set_flags_as(__func__, __LINE__,         \
  54             LOG_TRACE, "Scheduler", crm_system_name,                        \
  55             (scheduler)->flags, (flags_to_set), #flags_to_set);             \
  56     } while (0)
  57 
  58 #define pe__clear_working_set_flags(scheduler, flags_to_clear) do {         \
  59         (scheduler)->flags = pcmk__clear_flags_as(__func__, __LINE__,       \
  60             LOG_TRACE, "Scheduler", crm_system_name,                        \
  61             (scheduler)->flags, (flags_to_clear), #flags_to_clear);         \
  62     } while (0)
  63 
  64 #define pe__set_resource_flags(resource, flags_to_set) do {                 \
  65         (resource)->flags = pcmk__set_flags_as(__func__, __LINE__,          \
  66             LOG_TRACE, "Resource", (resource)->id, (resource)->flags,       \
  67             (flags_to_set), #flags_to_set);                                 \
  68     } while (0)
  69 
  70 #define pe__clear_resource_flags(resource, flags_to_clear) do {             \
  71         (resource)->flags = pcmk__clear_flags_as(__func__, __LINE__,        \
  72             LOG_TRACE, "Resource", (resource)->id, (resource)->flags,       \
  73             (flags_to_clear), #flags_to_clear);                             \
  74     } while (0)
  75 
  76 #define pe__set_action_flags(action, flags_to_set) do {                     \
  77         (action)->flags = pcmk__set_flags_as(__func__, __LINE__,            \
  78                                              LOG_TRACE,                     \
  79                                              "Action", (action)->uuid,      \
  80                                              (action)->flags,               \
  81                                              (flags_to_set),                \
  82                                              #flags_to_set);                \
  83     } while (0)
  84 
  85 #define pe__clear_action_flags(action, flags_to_clear) do {                 \
  86         (action)->flags = pcmk__clear_flags_as(__func__, __LINE__,          \
  87                                                LOG_TRACE,                   \
  88                                                "Action", (action)->uuid,    \
  89                                                (action)->flags,             \
  90                                                (flags_to_clear),            \
  91                                                #flags_to_clear);            \
  92     } while (0)
  93 
  94 #define pe__set_raw_action_flags(action_flags, action_name, flags_to_set) do { \
  95         action_flags = pcmk__set_flags_as(__func__, __LINE__,               \
  96                                           LOG_TRACE, "Action", action_name, \
  97                                           (action_flags),                   \
  98                                           (flags_to_set), #flags_to_set);   \
  99     } while (0)
 100 
 101 #define pe__clear_raw_action_flags(action_flags, action_name, flags_to_clear) do { \
 102         action_flags = pcmk__clear_flags_as(__func__, __LINE__,             \
 103                                             LOG_TRACE,                      \
 104                                             "Action", action_name,          \
 105                                             (action_flags),                 \
 106                                             (flags_to_clear),               \
 107                                             #flags_to_clear);               \
 108     } while (0)
 109 
 110 #define pe__set_action_flags_as(function, line, action, flags_to_set) do {  \
 111         (action)->flags = pcmk__set_flags_as((function), (line),            \
 112                                              LOG_TRACE,                     \
 113                                              "Action", (action)->uuid,      \
 114                                              (action)->flags,               \
 115                                              (flags_to_set),                \
 116                                              #flags_to_set);                \
 117     } while (0)
 118 
 119 #define pe__clear_action_flags_as(function, line, action, flags_to_clear) do { \
 120         (action)->flags = pcmk__clear_flags_as((function), (line),          \
 121                                                LOG_TRACE,                   \
 122                                                "Action", (action)->uuid,    \
 123                                                (action)->flags,             \
 124                                                (flags_to_clear),            \
 125                                                #flags_to_clear);            \
 126     } while (0)
 127 
 128 #define pe__set_order_flags(order_flags, flags_to_set) do {                 \
 129         order_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,     \
 130                                          "Ordering", "constraint",          \
 131                                          order_flags, (flags_to_set),       \
 132                                          #flags_to_set);                    \
 133     } while (0)
 134 
 135 #define pe__clear_order_flags(order_flags, flags_to_clear) do {               \
 136         order_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE,     \
 137                                            "Ordering", "constraint",          \
 138                                            order_flags, (flags_to_clear),     \
 139                                            #flags_to_clear);                  \
 140     } while (0)
 141 
 142 #define pe_warn_once(pe_wo_bit, fmt...) do {    \
 143         if (!pcmk_is_set(pcmk__warnings, pe_wo_bit)) {  \
 144             if (pe_wo_bit == pcmk__wo_blind) {  \
 145                 crm_warn(fmt);                  \
 146             } else {                            \
 147                 pe_warn(fmt);                   \
 148             }                                   \
 149             pcmk__warnings = pcmk__set_flags_as(__func__, __LINE__,         \
 150                                                LOG_TRACE,                   \
 151                                                "Warn-once", "logging",      \
 152                                                pcmk__warnings,              \
 153                                                (pe_wo_bit), #pe_wo_bit);    \
 154         }                                                                   \
 155     } while (0);
 156 
 157 
 158 typedef struct pe__location_constraint_s {
 159     char *id;                           // Constraint XML ID
 160     pcmk_resource_t *rsc_lh;            // Resource being located
 161     enum rsc_role_e role_filter;        // Role to locate
 162     enum pe_discover_e discover_mode;   // Resource discovery
 163     GList *node_list_rh;                // List of pcmk_node_t*
 164 } pe__location_t;
 165 
 166 typedef struct pe__order_constraint_s {
 167     int id;
 168     uint32_t flags; // Group of enum pcmk__action_relation_flags
 169 
 170     void *lh_opaque;
 171     pcmk_resource_t *lh_rsc;
 172     pcmk_action_t *lh_action;
 173     char *lh_action_task;
 174 
 175     void *rh_opaque;
 176     pcmk_resource_t *rh_rsc;
 177     pcmk_action_t *rh_action;
 178     char *rh_action_task;
 179 } pe__ordering_t;
 180 
 181 const pcmk_resource_t *pe__const_top_resource(const pcmk_resource_t *rsc,
 182                                               bool include_bundle);
 183 
 184 int pe__clone_max(const pcmk_resource_t *clone);
 185 int pe__clone_node_max(const pcmk_resource_t *clone);
 186 int pe__clone_promoted_max(const pcmk_resource_t *clone);
 187 int pe__clone_promoted_node_max(const pcmk_resource_t *clone);
 188 void pe__create_clone_notifications(pcmk_resource_t *clone);
 189 void pe__free_clone_notification_data(pcmk_resource_t *clone);
 190 void pe__create_clone_notif_pseudo_ops(pcmk_resource_t *clone,
 191                                        pcmk_action_t *start,
 192                                        pcmk_action_t *started,
 193                                        pcmk_action_t *stop,
 194                                        pcmk_action_t *stopped);
 195 
 196 pcmk_action_t *pe__new_rsc_pseudo_action(pcmk_resource_t *rsc, const char *task,
 197                                          bool optional, bool runnable);
 198 
 199 void pe__create_promotable_pseudo_ops(pcmk_resource_t *clone,
 200                                       bool any_promoting, bool any_demoting);
 201 
 202 bool pe_can_fence(const pcmk_scheduler_t *scheduler, const pcmk_node_t *node);
 203 
 204 void add_hash_param(GHashTable * hash, const char *name, const char *value);
 205 
 206 char *native_parameter(pcmk_resource_t *rsc, pcmk_node_t *node, gboolean create,
 207                        const char *name, pcmk_scheduler_t *scheduler);
 208 pcmk_node_t *native_location(const pcmk_resource_t *rsc, GList **list,
 209                              int current);
 210 
 211 void pe_metadata(pcmk__output_t *out);
 212 void verify_pe_options(GHashTable * options);
 213 
 214 void native_add_running(pcmk_resource_t *rsc, pcmk_node_t *node,
 215                         pcmk_scheduler_t *scheduler, gboolean failed);
 216 
 217 gboolean native_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
 218 gboolean group_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
 219 gboolean clone_unpack(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
 220 gboolean pe__unpack_bundle(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler);
 221 
 222 pcmk_resource_t *native_find_rsc(pcmk_resource_t *rsc, const char *id,
 223                                  const pcmk_node_t *node, int flags);
 224 
 225 gboolean native_active(pcmk_resource_t *rsc, gboolean all);
 226 gboolean group_active(pcmk_resource_t *rsc, gboolean all);
 227 gboolean clone_active(pcmk_resource_t *rsc, gboolean all);
 228 gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all);
 229 
 230 //! \deprecated This function will be removed in a future release
 231 void native_print(pcmk_resource_t *rsc, const char *pre_text, long options,
 232                   void *print_data);
 233 
 234 //! \deprecated This function will be removed in a future release
 235 void group_print(pcmk_resource_t *rsc, const char *pre_text, long options,
 236                  void *print_data);
 237 
 238 //! \deprecated This function will be removed in a future release
 239 void clone_print(pcmk_resource_t *rsc, const char *pre_text, long options,
 240                  void *print_data);
 241 
 242 //! \deprecated This function will be removed in a future release
 243 void pe__print_bundle(pcmk_resource_t *rsc, const char *pre_text, long options,
 244                       void *print_data);
 245 
 246 gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name,
 247                                   const pcmk_node_t *node, uint32_t show_opts,
 248                                   const char *target_role, bool show_nodes);
 249 
 250 int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name
 251                          , size_t pairs_count, ...);
 252 char *pe__node_display_name(pcmk_node_t *node, bool print_detail);
 253 
 254 
 255 // Clone notifications (pe_notif.c)
 256 void pe__order_notifs_after_fencing(const pcmk_action_t *action,
 257                                     pcmk_resource_t *rsc,
 258                                     pcmk_action_t *stonith_op);
 259 
 260 
 261 static inline const char *
 262 pe__rsc_bool_str(const pcmk_resource_t *rsc, uint64_t rsc_flag)
     /* [previous][next][first][last][top][bottom][index][help] */
 263 {
 264     return pcmk__btoa(pcmk_is_set(rsc->flags, rsc_flag));
 265 }
 266 
 267 int pe__clone_xml(pcmk__output_t *out, va_list args);
 268 int pe__clone_default(pcmk__output_t *out, va_list args);
 269 int pe__group_xml(pcmk__output_t *out, va_list args);
 270 int pe__group_default(pcmk__output_t *out, va_list args);
 271 int pe__bundle_xml(pcmk__output_t *out, va_list args);
 272 int pe__bundle_html(pcmk__output_t *out, va_list args);
 273 int pe__bundle_text(pcmk__output_t *out, va_list args);
 274 int pe__node_html(pcmk__output_t *out, va_list args);
 275 int pe__node_text(pcmk__output_t *out, va_list args);
 276 int pe__node_xml(pcmk__output_t *out, va_list args);
 277 int pe__resource_xml(pcmk__output_t *out, va_list args);
 278 int pe__resource_html(pcmk__output_t *out, va_list args);
 279 int pe__resource_text(pcmk__output_t *out, va_list args);
 280 
 281 void native_free(pcmk_resource_t *rsc);
 282 void group_free(pcmk_resource_t *rsc);
 283 void clone_free(pcmk_resource_t *rsc);
 284 void pe__free_bundle(pcmk_resource_t *rsc);
 285 
 286 enum rsc_role_e native_resource_state(const pcmk_resource_t *rsc,
 287                                       gboolean current);
 288 enum rsc_role_e group_resource_state(const pcmk_resource_t *rsc,
 289                                      gboolean current);
 290 enum rsc_role_e clone_resource_state(const pcmk_resource_t *rsc,
 291                                      gboolean current);
 292 enum rsc_role_e pe__bundle_resource_state(const pcmk_resource_t *rsc,
 293                                           gboolean current);
 294 
 295 void pe__count_common(pcmk_resource_t *rsc);
 296 void pe__count_bundle(pcmk_resource_t *rsc);
 297 
 298 void common_free(pcmk_resource_t *rsc);
 299 
 300 pcmk_node_t *pe__copy_node(const pcmk_node_t *this_node);
 301 time_t get_effective_time(pcmk_scheduler_t *scheduler);
 302 
 303 /* Failure handling utilities (from failcounts.c) */
 304 
 305 int pe_get_failcount(const pcmk_node_t *node, pcmk_resource_t *rsc,
 306                      time_t *last_failure, uint32_t flags,
 307                      const xmlNode *xml_op);
 308 
 309 pcmk_action_t *pe__clear_failcount(pcmk_resource_t *rsc,
 310                                    const pcmk_node_t *node, const char *reason,
 311                                    pcmk_scheduler_t *scheduler);
 312 
 313 /* Functions for finding/counting a resource's active nodes */
 314 
 315 bool pe__count_active_node(const pcmk_resource_t *rsc, pcmk_node_t *node,
 316                            pcmk_node_t **active, unsigned int *count_all,
 317                            unsigned int *count_clean);
 318 
 319 pcmk_node_t *pe__find_active_requires(const pcmk_resource_t *rsc,
 320                                     unsigned int *count);
 321 
 322 static inline pcmk_node_t *
 323 pe__current_node(const pcmk_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
 324 {
 325     return (rsc == NULL)? NULL : rsc->fns->active_node(rsc, NULL, NULL);
 326 }
 327 
 328 
 329 /* Binary like operators for lists of nodes */
 330 GHashTable *pe__node_list2table(const GList *list);
 331 
 332 pcmk_action_t *get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler);
 333 gboolean order_actions(pcmk_action_t *lh_action, pcmk_action_t *rh_action,
 334                        uint32_t flags);
 335 
 336 void pe__show_node_scores_as(const char *file, const char *function,
 337                              int line, bool to_log, const pcmk_resource_t *rsc,
 338                              const char *comment, GHashTable *nodes,
 339                              pcmk_scheduler_t *scheduler);
 340 
 341 #define pe__show_node_scores(level, rsc, text, nodes, scheduler)    \
 342         pe__show_node_scores_as(__FILE__, __func__, __LINE__,      \
 343                                 (level), (rsc), (text), (nodes), (scheduler))
 344 
 345 GHashTable *pcmk__unpack_action_meta(pcmk_resource_t *rsc,
 346                                      const pcmk_node_t *node,
 347                                      const char *action_name, guint interval_ms,
 348                                      const xmlNode *action_config);
 349 GHashTable *pcmk__unpack_action_rsc_params(const xmlNode *action_xml,
 350                                            GHashTable *node_attrs,
 351                                            pcmk_scheduler_t *data_set);
 352 xmlNode *pcmk__find_action_config(const pcmk_resource_t *rsc,
 353                                   const char *action_name, guint interval_ms,
 354                                   bool include_disabled);
 355 
 356 enum rsc_start_requirement pcmk__action_requires(const pcmk_resource_t *rsc,
 357                                                  const char *action_name);
 358 
 359 enum action_fail_response pcmk__parse_on_fail(const pcmk_resource_t *rsc,
 360                                               const char *action_name,
 361                                               guint interval_ms,
 362                                               const char *value);
 363 
 364 enum rsc_role_e pcmk__role_after_failure(const pcmk_resource_t *rsc,
 365                                          const char *action_name,
 366                                          enum action_fail_response on_fail,
 367                                          GHashTable *meta);
 368 
 369 pcmk_action_t *custom_action(pcmk_resource_t *rsc, char *key, const char *task,
 370                              const pcmk_node_t *on_node, gboolean optional,
 371                              pcmk_scheduler_t *scheduler);
 372 
 373 #  define delete_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_DELETE, 0)
 374 #  define delete_action(rsc, node, optional) custom_action(             \
 375                 rsc, delete_key(rsc), PCMK_ACTION_DELETE, node, \
 376                 optional, rsc->cluster);
 377 
 378 #  define stop_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_STOP, 0)
 379 #  define stop_action(rsc, node, optional) custom_action(                       \
 380                 rsc, stop_key(rsc), PCMK_ACTION_STOP, node,             \
 381                 optional, rsc->cluster);
 382 
 383 #  define reload_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_RELOAD_AGENT, 0)
 384 #  define start_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_START, 0)
 385 #  define start_action(rsc, node, optional) custom_action(              \
 386                 rsc, start_key(rsc), PCMK_ACTION_START, node,           \
 387                 optional, rsc->cluster)
 388 
 389 #  define promote_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_PROMOTE, 0)
 390 #  define promote_action(rsc, node, optional) custom_action(            \
 391                 rsc, promote_key(rsc), PCMK_ACTION_PROMOTE, node,       \
 392                 optional, rsc->cluster)
 393 
 394 #  define demote_key(rsc) pcmk__op_key(rsc->id, PCMK_ACTION_DEMOTE, 0)
 395 #  define demote_action(rsc, node, optional) custom_action(             \
 396                 rsc, demote_key(rsc), PCMK_ACTION_DEMOTE, node, \
 397                 optional, rsc->cluster)
 398 
 399 extern int pe_get_configured_timeout(pcmk_resource_t *rsc, const char *action,
 400                                      pcmk_scheduler_t *scheduler);
 401 
 402 pcmk_action_t *find_first_action(const GList *input, const char *uuid,
 403                                  const char *task, const pcmk_node_t *on_node);
 404 
 405 enum action_tasks get_complex_task(const pcmk_resource_t *rsc,
 406                                    const char *name);
 407 
 408 GList *find_actions(GList *input, const char *key, const pcmk_node_t *on_node);
 409 GList *find_actions_exact(GList *input, const char *key,
 410                           const pcmk_node_t *on_node);
 411 GList *pe__resource_actions(const pcmk_resource_t *rsc, const pcmk_node_t *node,
 412                             const char *task, bool require_node);
 413 
 414 extern void pe_free_action(pcmk_action_t *action);
 415 
 416 void resource_location(pcmk_resource_t *rsc, const pcmk_node_t *node, int score,
 417                        const char *tag, pcmk_scheduler_t *scheduler);
 418 
 419 extern int pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
 420                            bool same_node_default);
 421 extern gint sort_op_by_callid(gconstpointer a, gconstpointer b);
 422 gboolean get_target_role(const pcmk_resource_t *rsc, enum rsc_role_e *role);
 423 void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role,
 424                        const char *why);
 425 
 426 pcmk_resource_t *find_clone_instance(const pcmk_resource_t *rsc,
 427                                      const char *sub_id);
 428 
 429 extern void destroy_ticket(gpointer data);
 430 pcmk_ticket_t *ticket_new(const char *ticket_id, pcmk_scheduler_t *scheduler);
 431 
 432 // Resources for manipulating resource names
 433 const char *pe_base_name_end(const char *id);
 434 char *clone_strip(const char *last_rsc_id);
 435 char *clone_zero(const char *last_rsc_id);
 436 
 437 static inline bool
 438 pe_base_name_eq(const pcmk_resource_t *rsc, const char *id)
     /* [previous][next][first][last][top][bottom][index][help] */
 439 {
 440     if (id && rsc && rsc->id) {
 441         // Number of characters in rsc->id before any clone suffix
 442         size_t base_len = pe_base_name_end(rsc->id) - rsc->id + 1;
 443 
 444         return (strlen(id) == base_len) && !strncmp(id, rsc->id, base_len);
 445     }
 446     return false;
 447 }
 448 
 449 int pe__target_rc_from_xml(const xmlNode *xml_op);
 450 
 451 gint pe__cmp_node_name(gconstpointer a, gconstpointer b);
 452 bool is_set_recursive(const pcmk_resource_t *rsc, long long flag, bool any);
 453 
 454 typedef struct op_digest_cache_s {
 455     enum pcmk__digest_result rc;
 456     xmlNode *params_all;
 457     xmlNode *params_secure;
 458     xmlNode *params_restart;
 459     char *digest_all_calc;
 460     char *digest_secure_calc;
 461     char *digest_restart_calc;
 462 } op_digest_cache_t;
 463 
 464 op_digest_cache_t *pe__calculate_digests(pcmk_resource_t *rsc, const char *task,
 465                                          guint *interval_ms,
 466                                          const pcmk_node_t *node,
 467                                          const xmlNode *xml_op,
 468                                          GHashTable *overrides,
 469                                          bool calc_secure,
 470                                          pcmk_scheduler_t *scheduler);
 471 
 472 void pe__free_digests(gpointer ptr);
 473 
 474 op_digest_cache_t *rsc_action_digest_cmp(pcmk_resource_t *rsc,
 475                                          const xmlNode *xml_op,
 476                                          pcmk_node_t *node,
 477                                          pcmk_scheduler_t *scheduler);
 478 
 479 pcmk_action_t *pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
 480                            const char *reason, bool priority_delay,
 481                            pcmk_scheduler_t *scheduler);
 482 void trigger_unfencing(pcmk_resource_t *rsc, pcmk_node_t *node,
 483                        const char *reason, pcmk_action_t *dependency,
 484                        pcmk_scheduler_t *scheduler);
 485 
 486 char *pe__action2reason(const pcmk_action_t *action, enum pe_action_flags flag);
 487 void pe_action_set_reason(pcmk_action_t *action, const char *reason,
 488                           bool overwrite);
 489 void pe__add_action_expected_result(pcmk_action_t *action, int expected_result);
 490 
 491 void pe__set_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags);
 492 void pe__clear_resource_flags_recursive(pcmk_resource_t *rsc, uint64_t flags);
 493 void pe__clear_resource_flags_on_all(pcmk_scheduler_t *scheduler,
 494                                      uint64_t flag);
 495 
 496 gboolean add_tag_ref(GHashTable * tags, const char * tag_name,  const char * obj_ref);
 497 
 498 //! \deprecated This function will be removed in a future release
 499 void print_rscs_brief(GList *rsc_list, const char * pre_text, long options,
 500                       void * print_data, gboolean print_all);
 501 int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options);
 502 void pe_fence_node(pcmk_scheduler_t *scheduler, pcmk_node_t *node,
 503                    const char *reason, bool priority_delay);
 504 
 505 pcmk_node_t *pe_create_node(const char *id, const char *uname, const char *type,
 506                             const char *score, pcmk_scheduler_t *scheduler);
 507 
 508 //! \deprecated This function will be removed in a future release
 509 void common_print(pcmk_resource_t *rsc, const char *pre_text, const char *name,
 510                   const pcmk_node_t *node, long options, void *print_data);
 511 int pe__common_output_text(pcmk__output_t *out, const pcmk_resource_t *rsc,
 512                            const char *name, const pcmk_node_t *node,
 513                            unsigned int options);
 514 int pe__common_output_html(pcmk__output_t *out, const pcmk_resource_t *rsc,
 515                            const char *name, const pcmk_node_t *node,
 516                            unsigned int options);
 517 
 518 //! A single instance of a bundle
 519 typedef struct {
 520     int offset;                 //!< 0-origin index of this instance in bundle
 521     char *ipaddr;               //!< IP address associated with this instance
 522     pcmk_node_t *node;          //!< Node created for this instance
 523     pcmk_resource_t *ip;        //!< IP address resource for ipaddr
 524     pcmk_resource_t *child;     //!< Instance of bundled resource
 525     pcmk_resource_t *container; //!< Container associated with this instance
 526     pcmk_resource_t *remote;    //!< Pacemaker Remote connection into container
 527 } pe__bundle_replica_t;
 528 
 529 GList *pe__bundle_containers(const pcmk_resource_t *bundle);
 530 
 531 int pe__bundle_max(const pcmk_resource_t *rsc);
 532 bool pe__node_is_bundle_instance(const pcmk_resource_t *bundle,
 533                                  const pcmk_node_t *node);
 534 pcmk_resource_t *pe__bundled_resource(const pcmk_resource_t *rsc);
 535 const pcmk_resource_t *pe__get_rsc_in_container(const pcmk_resource_t *instance);
 536 pcmk_resource_t *pe__first_container(const pcmk_resource_t *bundle);
 537 void pe__foreach_bundle_replica(pcmk_resource_t *bundle,
 538                                 bool (*fn)(pe__bundle_replica_t *, void *),
 539                                 void *user_data);
 540 void pe__foreach_const_bundle_replica(const pcmk_resource_t *bundle,
 541                                       bool (*fn)(const pe__bundle_replica_t *,
 542                                                  void *),
 543                                       void *user_data);
 544 pcmk_resource_t *pe__find_bundle_replica(const pcmk_resource_t *bundle,
 545                                          const pcmk_node_t *node);
 546 bool pe__bundle_needs_remote_name(pcmk_resource_t *rsc);
 547 const char *pe__add_bundle_remote_name(pcmk_resource_t *rsc,
 548                                        pcmk_scheduler_t *scheduler,
 549                                        xmlNode *xml, const char *field);
 550 
 551 const char *pe__node_attribute_calculated(const pcmk_node_t *node,
 552                                           const char *name,
 553                                           const pcmk_resource_t *rsc,
 554                                           enum pcmk__rsc_node node_type,
 555                                           bool force_host);
 556 const char *pe_node_attribute_raw(const pcmk_node_t *node, const char *name);
 557 bool pe__is_universal_clone(const pcmk_resource_t *rsc,
 558                             const pcmk_scheduler_t *scheduler);
 559 void pe__add_param_check(const xmlNode *rsc_op, pcmk_resource_t *rsc,
 560                          pcmk_node_t *node, enum pcmk__check_parameters,
 561                          pcmk_scheduler_t *scheduler);
 562 void pe__foreach_param_check(pcmk_scheduler_t *scheduler,
 563                              void (*cb)(pcmk_resource_t*, pcmk_node_t*,
 564                                         const xmlNode*,
 565                                         enum pcmk__check_parameters));
 566 void pe__free_param_checks(pcmk_scheduler_t *scheduler);
 567 
 568 bool pe__shutdown_requested(const pcmk_node_t *node);
 569 void pe__update_recheck_time(time_t recheck, pcmk_scheduler_t *scheduler,
 570                              const char *reason);
 571 
 572 /*!
 573  * \internal
 574  * \brief Register xml formatting message functions.
 575  *
 576  * \param[in,out] out  Output object to register messages with
 577  */
 578 void pe__register_messages(pcmk__output_t *out);
 579 
 580 void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name,
 581                                 const pe_rule_eval_data_t *rule_data,
 582                                 GHashTable *hash, const char *always_first,
 583                                 gboolean overwrite,
 584                                 pcmk_scheduler_t *scheduler);
 585 
 586 bool pe__resource_is_disabled(const pcmk_resource_t *rsc);
 587 void pe__clear_resource_history(pcmk_resource_t *rsc, const pcmk_node_t *node);
 588 
 589 GList *pe__rscs_with_tag(pcmk_scheduler_t *scheduler, const char *tag_name);
 590 GList *pe__unames_with_tag(pcmk_scheduler_t *scheduler, const char *tag_name);
 591 bool pe__rsc_has_tag(pcmk_scheduler_t *scheduler, const char *rsc,
 592                      const char *tag);
 593 bool pe__uname_has_tag(pcmk_scheduler_t *scheduler, const char *node,
 594                        const char *tag);
 595 
 596 bool pe__rsc_running_on_only(const pcmk_resource_t *rsc,
 597                              const pcmk_node_t *node);
 598 bool pe__rsc_running_on_any(pcmk_resource_t *rsc, GList *node_list);
 599 GList *pe__filter_rsc_list(GList *rscs, GList *filter);
 600 GList * pe__build_node_name_list(pcmk_scheduler_t *scheduler, const char *s);
 601 GList * pe__build_rsc_list(pcmk_scheduler_t *scheduler, const char *s);
 602 
 603 bool pcmk__rsc_filtered_by_node(pcmk_resource_t *rsc, GList *only_node);
 604 
 605 gboolean pe__bundle_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
 606                                 gboolean check_parent);
 607 gboolean pe__clone_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
 608                                gboolean check_parent);
 609 gboolean pe__group_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
 610                                gboolean check_parent);
 611 gboolean pe__native_is_filtered(const pcmk_resource_t *rsc, GList *only_rsc,
 612                                 gboolean check_parent);
 613 
 614 xmlNode *pe__failed_probe_for_rsc(const pcmk_resource_t *rsc, const char *name);
 615 
 616 const char *pe__clone_child_id(const pcmk_resource_t *rsc);
 617 
 618 int pe__sum_node_health_scores(const pcmk_node_t *node, int base_health);
 619 int pe__node_health(pcmk_node_t *node);
 620 
 621 static inline enum pcmk__health_strategy
 622 pe__health_strategy(pcmk_scheduler_t *scheduler)
     /* [previous][next][first][last][top][bottom][index][help] */
 623 {
 624     return pcmk__parse_health_strategy(pe_pref(scheduler->config_hash,
 625                                                PCMK__OPT_NODE_HEALTH_STRATEGY));
 626 }
 627 
 628 static inline int
 629 pe__health_score(const char *option, pcmk_scheduler_t *scheduler)
     /* [previous][next][first][last][top][bottom][index][help] */
 630 {
 631     return char2score(pe_pref(scheduler->config_hash, option));
 632 }
 633 
 634 /*!
 635  * \internal
 636  * \brief Return a string suitable for logging as a node name
 637  *
 638  * \param[in] node  Node to return a node name string for
 639  *
 640  * \return Node name if available, otherwise node ID if available,
 641  *         otherwise "unspecified node" if node is NULL or "unidentified node"
 642  *         if node has neither a name nor ID.
 643  */
 644 static inline const char *
 645 pe__node_name(const pcmk_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
 646 {
 647     if (node == NULL) {
 648         return "unspecified node";
 649 
 650     } else if (node->details->uname != NULL) {
 651         return node->details->uname;
 652 
 653     } else if (node->details->id != NULL) {
 654         return node->details->id;
 655 
 656     } else {
 657         return "unidentified node";
 658     }
 659 }
 660 
 661 /*!
 662  * \internal
 663  * \brief Check whether two node objects refer to the same node
 664  *
 665  * \param[in] node1  First node object to compare
 666  * \param[in] node2  Second node object to compare
 667  *
 668  * \return true if \p node1 and \p node2 refer to the same node
 669  */
 670 static inline bool
 671 pe__same_node(const pcmk_node_t *node1, const pcmk_node_t *node2)
     /* [previous][next][first][last][top][bottom][index][help] */
 672 {
 673     return (node1 != NULL) && (node2 != NULL)
 674            && (node1->details == node2->details);
 675 }
 676 
 677 /*!
 678  * \internal
 679  * \brief Get the operation key from an action history entry
 680  *
 681  * \param[in] xml  Action history entry
 682  *
 683  * \return Entry's operation key
 684  */
 685 static inline const char *
 686 pe__xe_history_key(const xmlNode *xml)
     /* [previous][next][first][last][top][bottom][index][help] */
 687 {
 688     if (xml == NULL) {
 689         return NULL;
 690     } else {
 691         /* @COMPAT Pacemaker <= 1.1.5 did not add the key, and used the ID
 692          * instead. Checking for that allows us to process old saved CIBs,
 693          * including some regression tests.
 694          */
 695         const char *key = crm_element_value(xml, XML_LRM_ATTR_TASK_KEY);
 696 
 697         return pcmk__str_empty(key)? ID(xml) : key;
 698     }
 699 }
 700 
 701 #endif

/* [previous][next][first][last][top][bottom][index][help] */