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_hash_table_lookup
  4. pe_base_name_eq
  5. pe__health_strategy
  6. pe__health_score
  7. pe__node_name
  8. pe__same_node

   1 /*
   2  * Copyright 2004-2022 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 <stdint.h>
  14 #  include <string.h>
  15 #  include <crm/pengine/status.h>
  16 #  include <crm/pengine/remote_internal.h>
  17 #  include <crm/common/internal.h>
  18 #  include <crm/common/options_internal.h>
  19 #  include <crm/common/output_internal.h>
  20 
  21 enum pe__clone_flags {
  22     // Whether instances should be started sequentially
  23     pe__clone_ordered               = (1 << 0),
  24 
  25     // Whether promotion scores have been added
  26     pe__clone_promotion_added       = (1 << 1),
  27 
  28     // Whether promotion constraints have been added
  29     pe__clone_promotion_constrained = (1 << 2),
  30 };
  31 
  32 bool pe__clone_is_ordered(pe_resource_t *clone);
  33 int pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag);
  34 
  35 
  36 enum pe__group_flags {
  37     pe__group_ordered       = (1 << 0), // Members start sequentially
  38     pe__group_colocated     = (1 << 1), // Members must be on same node
  39 };
  40 
  41 bool pe__group_flag_is_set(const pe_resource_t *group, uint32_t flags);
  42 pe_resource_t *pe__last_group_member(const pe_resource_t *group);
  43 
  44 
  45 #  define pe_rsc_info(rsc, fmt, args...)  crm_log_tag(LOG_INFO,  rsc ? rsc->id : "<NULL>", fmt, ##args)
  46 #  define pe_rsc_debug(rsc, fmt, args...) crm_log_tag(LOG_DEBUG, rsc ? rsc->id : "<NULL>", fmt, ##args)
  47 #  define pe_rsc_trace(rsc, fmt, args...) crm_log_tag(LOG_TRACE, rsc ? rsc->id : "<NULL>", fmt, ##args)
  48 
  49 #  define pe_err(fmt...) do {           \
  50         was_processing_error = TRUE;    \
  51         pcmk__config_err(fmt);          \
  52     } while (0)
  53 
  54 #  define pe_warn(fmt...) do {          \
  55         was_processing_warning = TRUE;  \
  56         pcmk__config_warn(fmt);         \
  57     } while (0)
  58 
  59 #  define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); }
  60 #  define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); }
  61 
  62 #define pe__set_working_set_flags(working_set, flags_to_set) do {           \
  63         (working_set)->flags = pcmk__set_flags_as(__func__, __LINE__,       \
  64             LOG_TRACE, "Working set", crm_system_name,                      \
  65             (working_set)->flags, (flags_to_set), #flags_to_set);           \
  66     } while (0)
  67 
  68 #define pe__clear_working_set_flags(working_set, flags_to_clear) do {       \
  69         (working_set)->flags = pcmk__clear_flags_as(__func__, __LINE__,     \
  70             LOG_TRACE, "Working set", crm_system_name,                      \
  71             (working_set)->flags, (flags_to_clear), #flags_to_clear);       \
  72     } while (0)
  73 
  74 #define pe__set_resource_flags(resource, flags_to_set) do {                 \
  75         (resource)->flags = pcmk__set_flags_as(__func__, __LINE__,          \
  76             LOG_TRACE, "Resource", (resource)->id, (resource)->flags,       \
  77             (flags_to_set), #flags_to_set);                                 \
  78     } while (0)
  79 
  80 #define pe__clear_resource_flags(resource, flags_to_clear) do {             \
  81         (resource)->flags = pcmk__clear_flags_as(__func__, __LINE__,        \
  82             LOG_TRACE, "Resource", (resource)->id, (resource)->flags,       \
  83             (flags_to_clear), #flags_to_clear);                             \
  84     } while (0)
  85 
  86 #define pe__set_action_flags(action, flags_to_set) do {                     \
  87         (action)->flags = pcmk__set_flags_as(__func__, __LINE__,            \
  88                                              LOG_TRACE,                     \
  89                                              "Action", (action)->uuid,      \
  90                                              (action)->flags,               \
  91                                              (flags_to_set),                \
  92                                              #flags_to_set);                \
  93     } while (0)
  94 
  95 #define pe__clear_action_flags(action, flags_to_clear) do {                 \
  96         (action)->flags = pcmk__clear_flags_as(__func__, __LINE__,          \
  97                                                LOG_TRACE,                   \
  98                                                "Action", (action)->uuid,    \
  99                                                (action)->flags,             \
 100                                                (flags_to_clear),            \
 101                                                #flags_to_clear);            \
 102     } while (0)
 103 
 104 #define pe__set_raw_action_flags(action_flags, action_name, flags_to_set) do { \
 105         action_flags = pcmk__set_flags_as(__func__, __LINE__,               \
 106                                           LOG_TRACE, "Action", action_name, \
 107                                           (action_flags),                   \
 108                                           (flags_to_set), #flags_to_set);   \
 109     } while (0)
 110 
 111 #define pe__clear_raw_action_flags(action_flags, action_name, flags_to_clear) do { \
 112         action_flags = pcmk__clear_flags_as(__func__, __LINE__,             \
 113                                             LOG_TRACE,                      \
 114                                             "Action", action_name,          \
 115                                             (action_flags),                 \
 116                                             (flags_to_clear),               \
 117                                             #flags_to_clear);               \
 118     } while (0)
 119 
 120 #define pe__set_action_flags_as(function, line, action, flags_to_set) do {  \
 121         (action)->flags = pcmk__set_flags_as((function), (line),            \
 122                                              LOG_TRACE,                     \
 123                                              "Action", (action)->uuid,      \
 124                                              (action)->flags,               \
 125                                              (flags_to_set),                \
 126                                              #flags_to_set);                \
 127     } while (0)
 128 
 129 #define pe__clear_action_flags_as(function, line, action, flags_to_clear) do { \
 130         (action)->flags = pcmk__clear_flags_as((function), (line),          \
 131                                                LOG_TRACE,                   \
 132                                                "Action", (action)->uuid,    \
 133                                                (action)->flags,             \
 134                                                (flags_to_clear),            \
 135                                                #flags_to_clear);            \
 136     } while (0)
 137 
 138 #define pe__set_order_flags(order_flags, flags_to_set) do {                 \
 139         order_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,     \
 140                                          "Ordering", "constraint",          \
 141                                          order_flags, (flags_to_set),       \
 142                                          #flags_to_set);                    \
 143     } while (0)
 144 
 145 #define pe__clear_order_flags(order_flags, flags_to_clear) do {               \
 146         order_flags = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE,     \
 147                                            "Ordering", "constraint",          \
 148                                            order_flags, (flags_to_clear),     \
 149                                            #flags_to_clear);                  \
 150     } while (0)
 151 
 152 // Some warnings we don't want to print every transition
 153 
 154 enum pe_warn_once_e {
 155     pe_wo_blind         = (1 << 0),
 156     pe_wo_restart_type  = (1 << 1),
 157     pe_wo_role_after    = (1 << 2),
 158     pe_wo_poweroff      = (1 << 3),
 159     pe_wo_require_all   = (1 << 4),
 160     pe_wo_order_score   = (1 << 5),
 161     pe_wo_neg_threshold = (1 << 6),
 162     pe_wo_remove_after  = (1 << 7),
 163     pe_wo_ping_node     = (1 << 8),
 164     pe_wo_order_inst    = (1 << 9),
 165     pe_wo_coloc_inst    = (1 << 10),
 166     pe_wo_group_order   = (1 << 11),
 167     pe_wo_group_coloc   = (1 << 12),
 168 };
 169 
 170 extern uint32_t pe_wo;
 171 
 172 #define pe_warn_once(pe_wo_bit, fmt...) do {    \
 173         if (!pcmk_is_set(pe_wo, pe_wo_bit)) {  \
 174             if (pe_wo_bit == pe_wo_blind) {     \
 175                 crm_warn(fmt);                  \
 176             } else {                            \
 177                 pe_warn(fmt);                   \
 178             }                                   \
 179             pe_wo = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE,       \
 180                                       "Warn-once", "logging", pe_wo,        \
 181                                       (pe_wo_bit), #pe_wo_bit);             \
 182         }                                       \
 183     } while (0);
 184 
 185 
 186 typedef struct pe__location_constraint_s {
 187     char *id;                           // Constraint XML ID
 188     pe_resource_t *rsc_lh;              // Resource being located
 189     enum rsc_role_e role_filter;        // Role to locate
 190     enum pe_discover_e discover_mode;   // Resource discovery
 191     GList *node_list_rh;              // List of pe_node_t*
 192 } pe__location_t;
 193 
 194 typedef struct pe__order_constraint_s {
 195     int id;
 196     uint32_t flags; // Group of enum pe_ordering flags
 197 
 198     void *lh_opaque;
 199     pe_resource_t *lh_rsc;
 200     pe_action_t *lh_action;
 201     char *lh_action_task;
 202 
 203     void *rh_opaque;
 204     pe_resource_t *rh_rsc;
 205     pe_action_t *rh_action;
 206     char *rh_action_task;
 207 } pe__ordering_t;
 208 
 209 typedef struct notify_data_s {
 210     GSList *keys;               // Environment variable name/value pairs
 211 
 212     const char *action;
 213 
 214     pe_action_t *pre;
 215     pe_action_t *post;
 216     pe_action_t *pre_done;
 217     pe_action_t *post_done;
 218 
 219     GList *active;            /* notify_entry_t*  */
 220     GList *inactive;          /* notify_entry_t*  */
 221     GList *start;             /* notify_entry_t*  */
 222     GList *stop;              /* notify_entry_t*  */
 223     GList *demote;            /* notify_entry_t*  */
 224     GList *promote;           /* notify_entry_t*  */
 225     GList *promoted;          /* notify_entry_t*  */
 226     GList *unpromoted;        /* notify_entry_t*  */
 227     GHashTable *allowed_nodes;
 228 
 229 } notify_data_t;
 230 
 231 int pe__clone_promoted_max(pe_resource_t *clone);
 232 int pe__clone_promoted_node_max(pe_resource_t *clone);
 233 
 234 pe_action_t *pe__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task,
 235                                        bool optional, bool runnable);
 236 
 237 void pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting,
 238                                       bool any_demoting);
 239 
 240 bool pe_can_fence(pe_working_set_t *data_set, pe_node_t *node);
 241 
 242 void add_hash_param(GHashTable * hash, const char *name, const char *value);
 243 
 244 char *native_parameter(pe_resource_t * rsc, pe_node_t * node, gboolean create, const char *name,
 245                        pe_working_set_t * data_set);
 246 pe_node_t *native_location(const pe_resource_t *rsc, GList **list, int current);
 247 
 248 void pe_metadata(pcmk__output_t *out);
 249 void verify_pe_options(GHashTable * options);
 250 
 251 void common_update_score(pe_resource_t * rsc, const char *id, int score);
 252 void native_add_running(pe_resource_t * rsc, pe_node_t * node, pe_working_set_t * data_set, gboolean failed);
 253 
 254 gboolean native_unpack(pe_resource_t * rsc, pe_working_set_t * data_set);
 255 gboolean group_unpack(pe_resource_t * rsc, pe_working_set_t * data_set);
 256 gboolean clone_unpack(pe_resource_t * rsc, pe_working_set_t * data_set);
 257 gboolean pe__unpack_bundle(pe_resource_t *rsc, pe_working_set_t *data_set);
 258 
 259 pe_resource_t *native_find_rsc(pe_resource_t *rsc, const char *id, const pe_node_t *node,
 260                                int flags);
 261 
 262 gboolean native_active(pe_resource_t * rsc, gboolean all);
 263 gboolean group_active(pe_resource_t * rsc, gboolean all);
 264 gboolean clone_active(pe_resource_t * rsc, gboolean all);
 265 gboolean pe__bundle_active(pe_resource_t *rsc, gboolean all);
 266 
 267 //! \deprecated This function will be removed in a future release
 268 void native_print(pe_resource_t *rsc, const char *pre_text, long options,
 269                   void *print_data);
 270 
 271 //! \deprecated This function will be removed in a future release
 272 void group_print(pe_resource_t *rsc, const char *pre_text, long options,
 273                  void *print_data);
 274 
 275 //! \deprecated This function will be removed in a future release
 276 void clone_print(pe_resource_t *rsc, const char *pre_text, long options,
 277                  void *print_data);
 278 
 279 //! \deprecated This function will be removed in a future release
 280 void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options,
 281                       void *print_data);
 282 
 283 gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node,
 284                                    uint32_t show_opts, const char *target_role, bool show_nodes);
 285 
 286 int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name
 287                          , size_t pairs_count, ...);
 288 char *pe__node_display_name(pe_node_t *node, bool print_detail);
 289 
 290 
 291 // Clone notifications (pe_notif.c)
 292 void pe__create_notifications(pe_resource_t *rsc, notify_data_t *n_data);
 293 notify_data_t *pe__clone_notif_pseudo_ops(pe_resource_t *rsc, const char *task,
 294                                           pe_action_t *action,
 295                                           pe_action_t *complete);
 296 void pe__free_notification_data(notify_data_t *n_data);
 297 void pe__order_notifs_after_fencing(pe_action_t *action, pe_resource_t *rsc,
 298                                     pe_action_t *stonith_op);
 299 
 300 
 301 static inline const char *
 302 pe__rsc_bool_str(const pe_resource_t *rsc, uint64_t rsc_flag)
     /* [previous][next][first][last][top][bottom][index][help] */
 303 {
 304     return pcmk__btoa(pcmk_is_set(rsc->flags, rsc_flag));
 305 }
 306 
 307 int pe__clone_xml(pcmk__output_t *out, va_list args);
 308 int pe__clone_default(pcmk__output_t *out, va_list args);
 309 int pe__group_xml(pcmk__output_t *out, va_list args);
 310 int pe__group_default(pcmk__output_t *out, va_list args);
 311 int pe__bundle_xml(pcmk__output_t *out, va_list args);
 312 int pe__bundle_html(pcmk__output_t *out, va_list args);
 313 int pe__bundle_text(pcmk__output_t *out, va_list args);
 314 int pe__node_html(pcmk__output_t *out, va_list args);
 315 int pe__node_text(pcmk__output_t *out, va_list args);
 316 int pe__node_xml(pcmk__output_t *out, va_list args);
 317 int pe__resource_xml(pcmk__output_t *out, va_list args);
 318 int pe__resource_html(pcmk__output_t *out, va_list args);
 319 int pe__resource_text(pcmk__output_t *out, va_list args);
 320 
 321 void native_free(pe_resource_t * rsc);
 322 void group_free(pe_resource_t * rsc);
 323 void clone_free(pe_resource_t * rsc);
 324 void pe__free_bundle(pe_resource_t *rsc);
 325 
 326 enum rsc_role_e native_resource_state(const pe_resource_t * rsc, gboolean current);
 327 enum rsc_role_e group_resource_state(const pe_resource_t * rsc, gboolean current);
 328 enum rsc_role_e clone_resource_state(const pe_resource_t * rsc, gboolean current);
 329 enum rsc_role_e pe__bundle_resource_state(const pe_resource_t *rsc,
 330                                           gboolean current);
 331 
 332 void pe__count_common(pe_resource_t *rsc);
 333 void pe__count_bundle(pe_resource_t *rsc);
 334 
 335 void common_free(pe_resource_t * rsc);
 336 
 337 pe_node_t *pe__copy_node(const pe_node_t *this_node);
 338 extern time_t get_effective_time(pe_working_set_t * data_set);
 339 
 340 /* Failure handling utilities (from failcounts.c) */
 341 
 342 // bit flags for fail count handling options
 343 enum pe_fc_flags_e {
 344     pe_fc_default   = (1 << 0),
 345     pe_fc_effective = (1 << 1), // don't count expired failures
 346     pe_fc_fillers   = (1 << 2), // if container, include filler failures in count
 347 };
 348 
 349 int pe_get_failcount(pe_node_t *node, pe_resource_t *rsc, time_t *last_failure,
 350                      uint32_t flags, xmlNode *xml_op,
 351                      pe_working_set_t *data_set);
 352 
 353 pe_action_t *pe__clear_failcount(pe_resource_t *rsc, pe_node_t *node,
 354                                  const char *reason,
 355                                  pe_working_set_t *data_set);
 356 
 357 /* Functions for finding/counting a resource's active nodes */
 358 
 359 pe_node_t *pe__find_active_on(const pe_resource_t *rsc,
 360                               unsigned int *count_all,
 361                               unsigned int *count_clean);
 362 pe_node_t *pe__find_active_requires(const pe_resource_t *rsc,
 363                                     unsigned int *count);
 364 
 365 static inline pe_node_t *
 366 pe__current_node(const pe_resource_t *rsc)
     /* [previous][next][first][last][top][bottom][index][help] */
 367 {
 368     return pe__find_active_on(rsc, NULL, NULL);
 369 }
 370 
 371 
 372 /* Binary like operators for lists of nodes */
 373 extern void node_list_exclude(GHashTable * list, GList *list2, gboolean merge_scores);
 374 
 375 GHashTable *pe__node_list2table(GList *list);
 376 
 377 static inline gpointer
 378 pe_hash_table_lookup(GHashTable * hash, gconstpointer key)
     /* [previous][next][first][last][top][bottom][index][help] */
 379 {
 380     if (hash) {
 381         return g_hash_table_lookup(hash, key);
 382     }
 383     return NULL;
 384 }
 385 
 386 extern pe_action_t *get_pseudo_op(const char *name, pe_working_set_t * data_set);
 387 extern gboolean order_actions(pe_action_t * lh_action, pe_action_t * rh_action, enum pe_ordering order);
 388 
 389 void pe__show_node_weights_as(const char *file, const char *function,
 390                               int line, bool to_log, pe_resource_t *rsc,
 391                               const char *comment, GHashTable *nodes,
 392                               pe_working_set_t *data_set);
 393 
 394 #define pe__show_node_weights(level, rsc, text, nodes, data_set)    \
 395         pe__show_node_weights_as(__FILE__, __func__, __LINE__,      \
 396                                  (level), (rsc), (text), (nodes), (data_set))
 397 
 398 xmlNode *find_rsc_op_entry(const pe_resource_t *rsc, const char *key);
 399 
 400 pe_action_t *custom_action(pe_resource_t *rsc, char *key, const char *task,
 401                            const pe_node_t *on_node, gboolean optional,
 402                            gboolean foo, pe_working_set_t *data_set);
 403 
 404 #  define delete_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DELETE, 0)
 405 #  define delete_action(rsc, node, optional) custom_action(             \
 406                 rsc, delete_key(rsc), CRMD_ACTION_DELETE, node,         \
 407                 optional, TRUE, rsc->cluster);
 408 
 409 #  define stopped_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STOPPED, 0)
 410 #  define stopped_action(rsc, node, optional) custom_action(            \
 411                 rsc, stopped_key(rsc), CRMD_ACTION_STOPPED, node,       \
 412                 optional, TRUE, rsc->cluster);
 413 
 414 #  define stop_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STOP, 0)
 415 #  define stop_action(rsc, node, optional) custom_action(                       \
 416                 rsc, stop_key(rsc), CRMD_ACTION_STOP, node,             \
 417                 optional, TRUE, rsc->cluster);
 418 
 419 #  define reload_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_RELOAD_AGENT, 0)
 420 #  define start_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_START, 0)
 421 #  define start_action(rsc, node, optional) custom_action(              \
 422                 rsc, start_key(rsc), CRMD_ACTION_START, node,           \
 423                 optional, TRUE, rsc->cluster)
 424 
 425 #  define started_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_STARTED, 0)
 426 #  define started_action(rsc, node, optional) custom_action(            \
 427                 rsc, started_key(rsc), CRMD_ACTION_STARTED, node,       \
 428                 optional, TRUE, rsc->cluster)
 429 
 430 #  define promote_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_PROMOTE, 0)
 431 #  define promote_action(rsc, node, optional) custom_action(            \
 432                 rsc, promote_key(rsc), CRMD_ACTION_PROMOTE, node,       \
 433                 optional, TRUE, rsc->cluster)
 434 
 435 #  define promoted_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_PROMOTED, 0)
 436 #  define promoted_action(rsc, node, optional) custom_action(           \
 437                 rsc, promoted_key(rsc), CRMD_ACTION_PROMOTED, node,     \
 438                 optional, TRUE, rsc->cluster)
 439 
 440 #  define demote_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DEMOTE, 0)
 441 #  define demote_action(rsc, node, optional) custom_action(             \
 442                 rsc, demote_key(rsc), CRMD_ACTION_DEMOTE, node,         \
 443                 optional, TRUE, rsc->cluster)
 444 
 445 #  define demoted_key(rsc) pcmk__op_key(rsc->id, CRMD_ACTION_DEMOTED, 0)
 446 #  define demoted_action(rsc, node, optional) custom_action(            \
 447                 rsc, demoted_key(rsc), CRMD_ACTION_DEMOTED, node,       \
 448                 optional, TRUE, rsc->cluster)
 449 
 450 extern int pe_get_configured_timeout(pe_resource_t *rsc, const char *action,
 451                                      pe_working_set_t *data_set);
 452 
 453 pe_action_t *find_first_action(const GList *input, const char *uuid,
 454                                const char *task, const pe_node_t *on_node);
 455 extern enum action_tasks get_complex_task(pe_resource_t * rsc, const char *name,
 456                                           gboolean allow_non_atomic);
 457 
 458 extern GList *find_actions(GList *input, const char *key, const pe_node_t *on_node);
 459 GList *find_actions_exact(GList *input, const char *key,
 460                           const pe_node_t *on_node);
 461 GList *pe__resource_actions(const pe_resource_t *rsc, const pe_node_t *node,
 462                             const char *task, bool require_node);
 463 
 464 extern void pe_free_action(pe_action_t * action);
 465 
 466 extern void resource_location(pe_resource_t * rsc, pe_node_t * node, int score, const char *tag,
 467                               pe_working_set_t * data_set);
 468 
 469 extern int pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
 470                            bool same_node_default);
 471 extern gint sort_op_by_callid(gconstpointer a, gconstpointer b);
 472 extern gboolean get_target_role(pe_resource_t * rsc, enum rsc_role_e *role);
 473 void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role,
 474                        const char *why);
 475 
 476 extern pe_resource_t *find_clone_instance(pe_resource_t * rsc, const char *sub_id,
 477                                           pe_working_set_t * data_set);
 478 
 479 extern void destroy_ticket(gpointer data);
 480 extern pe_ticket_t *ticket_new(const char *ticket_id, pe_working_set_t * data_set);
 481 
 482 // Resources for manipulating resource names
 483 const char *pe_base_name_end(const char *id);
 484 char *clone_strip(const char *last_rsc_id);
 485 char *clone_zero(const char *last_rsc_id);
 486 
 487 static inline bool
 488 pe_base_name_eq(pe_resource_t *rsc, const char *id)
     /* [previous][next][first][last][top][bottom][index][help] */
 489 {
 490     if (id && rsc && rsc->id) {
 491         // Number of characters in rsc->id before any clone suffix
 492         size_t base_len = pe_base_name_end(rsc->id) - rsc->id + 1;
 493 
 494         return (strlen(id) == base_len) && !strncmp(id, rsc->id, base_len);
 495     }
 496     return false;
 497 }
 498 
 499 int pe__target_rc_from_xml(xmlNode *xml_op);
 500 
 501 gint pe__cmp_node_name(gconstpointer a, gconstpointer b);
 502 bool is_set_recursive(const pe_resource_t *rsc, long long flag, bool any);
 503 
 504 enum rsc_digest_cmp_val {
 505     /*! Digests are the same */
 506     RSC_DIGEST_MATCH = 0,
 507     /*! Params that require a restart changed */
 508     RSC_DIGEST_RESTART,
 509     /*! Some parameter changed.  */
 510     RSC_DIGEST_ALL,
 511     /*! rsc op didn't have a digest associated with it, so
 512      *  it is unknown if parameters changed or not. */
 513     RSC_DIGEST_UNKNOWN,
 514 };
 515 
 516 typedef struct op_digest_cache_s {
 517     enum rsc_digest_cmp_val rc;
 518     xmlNode *params_all;
 519     xmlNode *params_secure;
 520     xmlNode *params_restart;
 521     char *digest_all_calc;
 522     char *digest_secure_calc;
 523     char *digest_restart_calc;
 524 } op_digest_cache_t;
 525 
 526 op_digest_cache_t *pe__calculate_digests(pe_resource_t *rsc, const char *task,
 527                                          guint *interval_ms, pe_node_t *node,
 528                                          xmlNode *xml_op, GHashTable *overrides,
 529                                          bool calc_secure,
 530                                          pe_working_set_t *data_set);
 531 
 532 void pe__free_digests(gpointer ptr);
 533 
 534 op_digest_cache_t *rsc_action_digest_cmp(pe_resource_t * rsc, xmlNode * xml_op, pe_node_t * node,
 535                                          pe_working_set_t * data_set);
 536 
 537 pe_action_t *pe_fence_op(pe_node_t * node, const char *op, bool optional, const char *reason, bool priority_delay, pe_working_set_t * data_set);
 538 void trigger_unfencing(
 539     pe_resource_t * rsc, pe_node_t *node, const char *reason, pe_action_t *dependency, pe_working_set_t * data_set);
 540 
 541 char *pe__action2reason(pe_action_t *action, enum pe_action_flags flag);
 542 void pe_action_set_reason(pe_action_t *action, const char *reason, bool overwrite);
 543 void pe__add_action_expected_result(pe_action_t *action, int expected_result);
 544 
 545 void pe__set_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags);
 546 void pe__clear_resource_flags_recursive(pe_resource_t *rsc, uint64_t flags);
 547 void pe__clear_resource_flags_on_all(pe_working_set_t *data_set, uint64_t flag);
 548 
 549 gboolean add_tag_ref(GHashTable * tags, const char * tag_name,  const char * obj_ref);
 550 
 551 //! \deprecated This function will be removed in a future release
 552 void print_rscs_brief(GList *rsc_list, const char * pre_text, long options,
 553                       void * print_data, gboolean print_all);
 554 int pe__rscs_brief_output(pcmk__output_t *out, GList *rsc_list, unsigned int options);
 555 void pe_fence_node(pe_working_set_t * data_set, pe_node_t * node, const char *reason, bool priority_delay);
 556 
 557 pe_node_t *pe_create_node(const char *id, const char *uname, const char *type,
 558                           const char *score, pe_working_set_t * data_set);
 559 
 560 //! \deprecated This function will be removed in a future release
 561 void common_print(pe_resource_t *rsc, const char *pre_text, const char *name,
 562                   pe_node_t *node, long options, void *print_data);
 563 int pe__common_output_text(pcmk__output_t *out, pe_resource_t * rsc, const char *name, pe_node_t *node, unsigned int options);
 564 int pe__common_output_html(pcmk__output_t *out, pe_resource_t * rsc, const char *name, pe_node_t *node, unsigned int options);
 565 pe_resource_t *pe__find_bundle_replica(const pe_resource_t *bundle,
 566                                        const pe_node_t *node);
 567 bool pe__bundle_needs_remote_name(pe_resource_t *rsc,
 568                                   pe_working_set_t *data_set);
 569 const char *pe__add_bundle_remote_name(pe_resource_t *rsc,
 570                                        pe_working_set_t *data_set,
 571                                        xmlNode *xml, const char *field);
 572 const char *pe_node_attribute_calculated(const pe_node_t *node,
 573                                          const char *name,
 574                                          const pe_resource_t *rsc);
 575 const char *pe_node_attribute_raw(const pe_node_t *node, const char *name);
 576 bool pe__is_universal_clone(pe_resource_t *rsc,
 577                             pe_working_set_t *data_set);
 578 void pe__add_param_check(xmlNode *rsc_op, pe_resource_t *rsc, pe_node_t *node,
 579                          enum pe_check_parameters, pe_working_set_t *data_set);
 580 void pe__foreach_param_check(pe_working_set_t *data_set,
 581                              void (*cb)(pe_resource_t*, pe_node_t*, xmlNode*,
 582                                         enum pe_check_parameters,
 583                                         pe_working_set_t*));
 584 void pe__free_param_checks(pe_working_set_t *data_set);
 585 
 586 bool pe__shutdown_requested(pe_node_t *node);
 587 void pe__update_recheck_time(time_t recheck, pe_working_set_t *data_set);
 588 
 589 /*!
 590  * \internal
 591  * \brief Register xml formatting message functions.
 592  *
 593  * \param[in,out] out  Output object to register messages with
 594  */
 595 void pe__register_messages(pcmk__output_t *out);
 596 
 597 void pe__unpack_dataset_nvpairs(const xmlNode *xml_obj, const char *set_name,
 598                                 pe_rule_eval_data_t *rule_data, GHashTable *hash,
 599                                 const char *always_first, gboolean overwrite,
 600                                 pe_working_set_t *data_set);
 601 
 602 bool pe__resource_is_disabled(pe_resource_t *rsc);
 603 pe_action_t *pe__clear_resource_history(pe_resource_t *rsc, pe_node_t *node,
 604                                         pe_working_set_t *data_set);
 605 
 606 GList *pe__rscs_with_tag(pe_working_set_t *data_set, const char *tag_name);
 607 GList *pe__unames_with_tag(pe_working_set_t *data_set, const char *tag_name);
 608 bool pe__rsc_has_tag(pe_working_set_t *data_set, const char *rsc, const char *tag);
 609 bool pe__uname_has_tag(pe_working_set_t *data_set, const char *node, const char *tag);
 610 
 611 bool pe__rsc_running_on_any(pe_resource_t *rsc, GList *node_list);
 612 GList *pe__filter_rsc_list(GList *rscs, GList *filter);
 613 GList * pe__build_node_name_list(pe_working_set_t *data_set, const char *s);
 614 GList * pe__build_rsc_list(pe_working_set_t *data_set, const char *s);
 615 
 616 bool pcmk__rsc_filtered_by_node(pe_resource_t *rsc, GList *only_node);
 617 
 618 gboolean pe__bundle_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent);
 619 gboolean pe__clone_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent);
 620 gboolean pe__group_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent);
 621 gboolean pe__native_is_filtered(pe_resource_t *rsc, GList *only_rsc, gboolean check_parent);
 622 
 623 xmlNode *pe__failed_probe_for_rsc(pe_resource_t *rsc, const char *name);
 624 
 625 const char *pe__clone_child_id(pe_resource_t *rsc);
 626 
 627 int pe__sum_node_health_scores(const pe_node_t *node, int base_health);
 628 int pe__node_health(pe_node_t *node);
 629 
 630 static inline enum pcmk__health_strategy
 631 pe__health_strategy(pe_working_set_t *data_set)
     /* [previous][next][first][last][top][bottom][index][help] */
 632 {
 633     return pcmk__parse_health_strategy(pe_pref(data_set->config_hash,
 634                                                PCMK__OPT_NODE_HEALTH_STRATEGY));
 635 }
 636 
 637 static inline int
 638 pe__health_score(const char *option, pe_working_set_t *data_set)
     /* [previous][next][first][last][top][bottom][index][help] */
 639 {
 640     return char2score(pe_pref(data_set->config_hash, option));
 641 }
 642 
 643 /*!
 644  * \internal
 645  * \brief Return a string suitable for logging as a node name
 646  *
 647  * \param[in] node  Node to return a node name string for
 648  *
 649  * \return Node name if available, otherwise node ID if available,
 650  *         otherwise "unspecified node" if node is NULL or "unidentified node"
 651  *         if node has neither a name nor ID.
 652  */
 653 static inline const char *
 654 pe__node_name(const pe_node_t *node)
     /* [previous][next][first][last][top][bottom][index][help] */
 655 {
 656     if (node == NULL) {
 657         return "unspecified node";
 658 
 659     } else if (node->details->uname != NULL) {
 660         return node->details->uname;
 661 
 662     } else if (node->details->id != NULL) {
 663         return node->details->id;
 664 
 665     } else {
 666         return "unidentified node";
 667     }
 668 }
 669 
 670 /*!
 671  * \internal
 672  * \brief Check whether two node objects refer to the same node
 673  *
 674  * \param[in] node1  First node object to compare
 675  * \param[in] node2  Second node object to compare
 676  *
 677  * \return true if \p node1 and \p node2 refer to the same node
 678  */
 679 static inline bool
 680 pe__same_node(const pe_node_t *node1, const pe_node_t *node2)
     /* [previous][next][first][last][top][bottom][index][help] */
 681 {
 682     return (node1 != NULL) && (node2 != NULL)
 683            && (node1->details == node2->details);
 684 }
 685 #endif

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