root/include/crm/pengine/common.h

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

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. recovery2text

   1 /*
   2  * Copyright 2004-2021 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_COMMON__H
  11 #  define PE_COMMON__H
  12 
  13 #ifdef __cplusplus
  14 extern "C" {
  15 #endif
  16 
  17 #  include <glib.h>
  18 #  include <regex.h>
  19 
  20 #  include <crm/common/iso8601.h>
  21 
  22 extern gboolean was_processing_error;
  23 extern gboolean was_processing_warning;
  24 
  25 /* The order is (partially) significant here; the values from action_fail_ignore
  26  * through action_fail_fence are in order of increasing severity.
  27  *
  28  * @COMPAT The values should be ordered and numbered per the "TODO" comments
  29  *         below, so all values are in order of severity and there is room for
  30  *         future additions, but that would break API compatibility.
  31  * @TODO   For now, we just use a function to compare the values specially, but
  32  *         at the next compatibility break, we should arrange things properly.
  33  */
  34 enum action_fail_response {
  35     action_fail_ignore,     // @TODO = 10
  36     // @TODO action_fail_demote = 20,
  37     action_fail_recover,    // @TODO = 30
  38     // @TODO action_fail_reset_remote = 40,
  39     // @TODO action_fail_restart_container = 50,
  40     action_fail_migrate,    // @TODO = 60
  41     action_fail_block,      // @TODO = 70
  42     action_fail_stop,       // @TODO = 80
  43     action_fail_standby,    // @TODO = 90
  44     action_fail_fence,      // @TODO = 100
  45 
  46     // @COMPAT Values below here are out of order for API compatibility
  47 
  48     action_fail_restart_container,
  49 
  50     /* This is reserved for internal use for remote node connection resources.
  51      * Fence the remote node if stonith is enabled, otherwise attempt to recover
  52      * the connection resource. This allows us to specify types of connection
  53      * resource failures that should result in fencing the remote node
  54      * (for example, recurring monitor failures).
  55      */
  56     action_fail_reset_remote,
  57 
  58     action_fail_demote,
  59 };
  60 
  61 /* the "done" action must be the "pre" action +1 */
  62 enum action_tasks {
  63     no_action,
  64     monitor_rsc,
  65     stop_rsc,
  66     stopped_rsc,
  67     start_rsc,
  68     started_rsc,
  69     action_notify,
  70     action_notified,
  71     action_promote,
  72     action_promoted,
  73     action_demote,
  74     action_demoted,
  75     shutdown_crm,
  76     stonith_node
  77 };
  78 
  79 enum rsc_recovery_type {
  80     recovery_stop_start,
  81     recovery_stop_only,
  82     recovery_block
  83 };
  84 
  85 enum rsc_start_requirement {
  86     rsc_req_nothing,            /* Allowed by custom_action() */
  87     rsc_req_quorum,             /* Enforced by custom_action() */
  88     rsc_req_stonith             /* Enforced by native_start_constraints() */
  89 };
  90 
  91 //! Possible roles that a resource can be in
  92 enum rsc_role_e {
  93     RSC_ROLE_UNKNOWN    = 0,
  94     RSC_ROLE_STOPPED    = 1,
  95     RSC_ROLE_STARTED    = 2,
  96     RSC_ROLE_UNPROMOTED = 3,
  97     RSC_ROLE_PROMOTED   = 4,
  98 
  99 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 100     //! \deprecated Use RSC_ROLE_UNPROMOTED instead
 101     RSC_ROLE_SLAVE      = RSC_ROLE_UNPROMOTED,
 102 
 103     //! \deprecated Use RSC_ROLE_PROMOTED instead
 104     RSC_ROLE_MASTER     = RSC_ROLE_PROMOTED,
 105 #endif
 106 };
 107 
 108 #  define RSC_ROLE_MAX  (RSC_ROLE_PROMOTED + 1)
 109 
 110 #  define RSC_ROLE_UNKNOWN_S "Unknown"
 111 #  define RSC_ROLE_STOPPED_S "Stopped"
 112 #  define RSC_ROLE_STARTED_S "Started"
 113 #  define RSC_ROLE_UNPROMOTED_S         "Unpromoted"
 114 #  define RSC_ROLE_PROMOTED_S           "Promoted"
 115 #  define RSC_ROLE_UNPROMOTED_LEGACY_S  "Slave"
 116 #  define RSC_ROLE_PROMOTED_LEGACY_S    "Master"
 117 
 118 enum pe_print_options {
 119     pe_print_log            = (1 << 0),  //! \deprecated
 120     pe_print_html           = (1 << 1),  //! \deprecated
 121     pe_print_ncurses        = (1 << 2),  //! \deprecated
 122     pe_print_printf         = (1 << 3),  //! \deprecated
 123     pe_print_dev            = (1 << 4),  //! \deprecated Ignored
 124     pe_print_details        = (1 << 5),  //! \deprecated Ignored
 125     pe_print_max_details    = (1 << 6),  //! \deprecated Ignored
 126     pe_print_rsconly        = (1 << 7),
 127     pe_print_ops            = (1 << 8),
 128     pe_print_suppres_nl     = (1 << 9),
 129     pe_print_xml            = (1 << 10), //! \deprecated
 130     pe_print_brief          = (1 << 11),
 131     pe_print_pending        = (1 << 12),
 132     pe_print_clone_details  = (1 << 13),
 133     pe_print_clone_active   = (1 << 14), // Print clone instances only if active
 134     pe_print_implicit       = (1 << 15)  // Print implicitly created resources
 135 };
 136 
 137 const char *task2text(enum action_tasks task);
 138 enum action_tasks text2task(const char *task);
 139 enum rsc_role_e text2role(const char *role);
 140 const char *role2text(enum rsc_role_e role);
 141 const char *fail2text(enum action_fail_response fail);
 142 
 143 const char *pe_pref(GHashTable * options, const char *name);
 144 void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index);
 145 
 146 static inline const char *
 147 recovery2text(enum rsc_recovery_type type)
     /* [previous][next][first][last][top][bottom][index][help] */
 148 {
 149     switch (type) {
 150         case recovery_stop_only:
 151             return "shutting it down";
 152         case recovery_stop_start:
 153             return "attempting recovery";
 154         case recovery_block:
 155             return "waiting for an administrator";
 156     }
 157     return "Unknown";
 158 }
 159 
 160 typedef struct pe_re_match_data {
 161     char *string;
 162     int nregs;
 163     regmatch_t *pmatch;
 164 } pe_re_match_data_t;
 165 
 166 typedef struct pe_match_data {
 167     pe_re_match_data_t *re;
 168     GHashTable *params;
 169     GHashTable *meta;
 170 } pe_match_data_t;
 171 
 172 typedef struct pe_rsc_eval_data {
 173     const char *standard;
 174     const char *provider;
 175     const char *agent;
 176 } pe_rsc_eval_data_t;
 177 
 178 typedef struct pe_op_eval_data {
 179     const char *op_name;
 180     guint interval;
 181 } pe_op_eval_data_t;
 182 
 183 typedef struct pe_rule_eval_data {
 184     GHashTable *node_hash;
 185     enum rsc_role_e role;
 186     crm_time_t *now;
 187     pe_match_data_t *match_data;
 188     pe_rsc_eval_data_t *rsc_data;
 189     pe_op_eval_data_t *op_data;
 190 } pe_rule_eval_data_t;
 191 
 192 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 193 #include <crm/pengine/common_compat.h>
 194 #endif
 195 
 196 #ifdef __cplusplus
 197 }
 198 #endif
 199 
 200 #endif

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