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-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 PCMK__CRM_PENGINE_COMMON__H
  11 #  define PCMK__CRM_PENGINE_COMMON__H
  12 
  13 #  include <glib.h>
  14 #  include <regex.h>
  15 #  include <crm/common/iso8601.h>
  16 
  17 #ifdef __cplusplus
  18 extern "C" {
  19 #endif
  20 
  21 extern gboolean was_processing_error;
  22 extern gboolean was_processing_warning;
  23 
  24 /* The order is (partially) significant here; the values from action_fail_ignore
  25  * through action_fail_fence are in order of increasing severity.
  26  *
  27  * @COMPAT The values should be ordered and numbered per the "TODO" comments
  28  *         below, so all values are in order of severity and there is room for
  29  *         future additions, but that would break API compatibility.
  30  * @TODO   For now, we just use a function to compare the values specially, but
  31  *         at the next compatibility break, we should arrange things properly.
  32  */
  33 enum action_fail_response {
  34     action_fail_ignore,     // @TODO = 10
  35     // @TODO action_fail_demote = 20,
  36     action_fail_recover,    // @TODO = 30
  37     // @TODO action_fail_reset_remote = 40,
  38     // @TODO action_fail_restart_container = 50,
  39     action_fail_migrate,    // @TODO = 60
  40     action_fail_block,      // @TODO = 70
  41     action_fail_stop,       // @TODO = 80
  42     action_fail_standby,    // @TODO = 90
  43     action_fail_fence,      // @TODO = 100
  44 
  45     // @COMPAT Values below here are out of order for API compatibility
  46 
  47     action_fail_restart_container,
  48 
  49     /* This is reserved for internal use for remote node connection resources.
  50      * Fence the remote node if stonith is enabled, otherwise attempt to recover
  51      * the connection resource. This allows us to specify types of connection
  52      * resource failures that should result in fencing the remote node
  53      * (for example, recurring monitor failures).
  54      */
  55     action_fail_reset_remote,
  56 
  57     action_fail_demote,
  58 };
  59 
  60 /* the "done" action must be the "pre" action +1 */
  61 enum action_tasks {
  62     no_action,
  63     monitor_rsc,
  64     stop_rsc,
  65     stopped_rsc,
  66     start_rsc,
  67     started_rsc,
  68     action_notify,
  69     action_notified,
  70     action_promote,
  71     action_promoted,
  72     action_demote,
  73     action_demoted,
  74     shutdown_crm,
  75     stonith_node
  76 };
  77 
  78 enum rsc_recovery_type {
  79     recovery_stop_start,
  80     recovery_stop_only,
  81     recovery_block,
  82     recovery_stop_unexpected,
  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 //! Deprecated
 119 enum pe_print_options {
 120     pe_print_log            = (1 << 0),
 121     pe_print_html           = (1 << 1),
 122     pe_print_ncurses        = (1 << 2),
 123     pe_print_printf         = (1 << 3),
 124     pe_print_dev            = (1 << 4),  //! Ignored
 125     pe_print_details        = (1 << 5),  //! Ignored
 126     pe_print_max_details    = (1 << 6),  //! Ignored
 127     pe_print_rsconly        = (1 << 7),
 128     pe_print_ops            = (1 << 8),
 129     pe_print_suppres_nl     = (1 << 9),
 130     pe_print_xml            = (1 << 10),
 131     pe_print_brief          = (1 << 11),
 132     pe_print_pending        = (1 << 12),
 133     pe_print_clone_details  = (1 << 13),
 134     pe_print_clone_active   = (1 << 14), // Print clone instances only if active
 135     pe_print_implicit       = (1 << 15)  // Print implicitly created resources
 136 };
 137 
 138 const char *task2text(enum action_tasks task);
 139 enum action_tasks text2task(const char *task);
 140 enum rsc_role_e text2role(const char *role);
 141 const char *role2text(enum rsc_role_e role);
 142 const char *fail2text(enum action_fail_response fail);
 143 
 144 const char *pe_pref(GHashTable * options, const char *name);
 145 
 146 /*!
 147  * \brief Get readable description of a recovery type
 148  *
 149  * \param[in] type  Recovery type
 150  *
 151  * \return Static string describing \p type
 152  */
 153 static inline const char *
 154 recovery2text(enum rsc_recovery_type type)
     /* [previous][next][first][last][top][bottom][index][help] */
 155 {
 156     switch (type) {
 157         case recovery_stop_only:
 158             return "shutting it down";
 159         case recovery_stop_start:
 160             return "attempting recovery";
 161         case recovery_block:
 162             return "waiting for an administrator";
 163         case recovery_stop_unexpected:
 164             return "stopping unexpected instances";
 165     }
 166     return "Unknown";
 167 }
 168 
 169 typedef struct pe_re_match_data {
 170     char *string;
 171     int nregs;
 172     regmatch_t *pmatch;
 173 } pe_re_match_data_t;
 174 
 175 typedef struct pe_match_data {
 176     pe_re_match_data_t *re;
 177     GHashTable *params;
 178     GHashTable *meta;
 179 } pe_match_data_t;
 180 
 181 typedef struct pe_rsc_eval_data {
 182     const char *standard;
 183     const char *provider;
 184     const char *agent;
 185 } pe_rsc_eval_data_t;
 186 
 187 typedef struct pe_op_eval_data {
 188     const char *op_name;
 189     guint interval;
 190 } pe_op_eval_data_t;
 191 
 192 typedef struct pe_rule_eval_data {
 193     GHashTable *node_hash;          // Only used with g_hash_table_lookup()
 194     enum rsc_role_e role;
 195     crm_time_t *now;                // @COMPAT could be const
 196     pe_match_data_t *match_data;    // @COMPAT could be const
 197     pe_rsc_eval_data_t *rsc_data;   // @COMPAT could be const
 198     pe_op_eval_data_t *op_data;     // @COMPAT could be const
 199 } pe_rule_eval_data_t;
 200 
 201 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
 202 #include <crm/pengine/common_compat.h>
 203 #endif
 204 
 205 #ifdef __cplusplus
 206 }
 207 #endif
 208 
 209 #endif

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