pacemaker  2.1.1-52dc28db4
Scalable High-Availability cluster resource manager
common.h
Go to the documentation of this file.
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  */
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 
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  */
57 
59 };
60 
61 /* the "done" action must be the "pre" action +1 */
77 };
78 
83 };
84 
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 
92 enum rsc_role_e {
98 
99 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
102 
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 
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),
125  pe_print_details = (1 << 5),
126  pe_print_max_details = (1 << 6),
127  pe_print_rsconly = (1 << 7),
128  pe_print_ops = (1 << 8),
130  pe_print_xml = (1 << 10),
131  pe_print_brief = (1 << 11),
132  pe_print_pending = (1 << 12),
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 void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index);
146 
147 static inline const char *
148 recovery2text(enum rsc_recovery_type type)
149 {
150  switch (type) {
151  case recovery_stop_only:
152  return "shutting it down";
153  case recovery_stop_start:
154  return "attempting recovery";
155  case recovery_block:
156  return "waiting for an administrator";
157  }
158  return "Unknown";
159 }
160 
161 typedef struct pe_re_match_data {
162  char *string;
163  int nregs;
164  regmatch_t *pmatch;
166 
167 typedef struct pe_match_data {
169  GHashTable *params;
170  GHashTable *meta;
172 
173 typedef struct pe_rsc_eval_data {
174  const char *standard;
175  const char *provider;
176  const char *agent;
178 
179 typedef struct pe_op_eval_data {
180  const char *op_name;
181  guint interval;
183 
184 typedef struct pe_rule_eval_data {
185  GHashTable *node_hash;
192 
193 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
195 #endif
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 
201 #endif
const char * task2text(enum action_tasks task)
Definition: common.c:406
const char * provider
Definition: common.h:175
struct crm_time_s crm_time_t
Definition: iso8601.h:32
struct pe_rule_eval_data pe_rule_eval_data_t
pe_re_match_data_t * re
Definition: common.h:168
Deprecated Pacemaker scheduler utilities.
enum action_tasks text2task(const char *task)
Definition: common.c:354
const char * pe_pref(GHashTable *options, const char *name)
Definition: common.c:308
Ignored.
Definition: common.h:125
enum crm_ais_msg_types type
Definition: cpg.c:48
struct pe_re_match_data pe_re_match_data_t
action_fail_response
Definition: common.h:34
const char * role2text(enum rsc_role_e role)
Definition: common.c:459
rsc_recovery_type
Definition: common.h:79
guint interval
Definition: common.h:181
pe_match_data_t * match_data
Definition: common.h:188
pe_op_eval_data_t * op_data
Definition: common.h:190
void calculate_active_ops(GList *sorted_op_list, int *start_index, int *stop_index)
Definition: unpack.c:2253
struct pe_rsc_eval_data pe_rsc_eval_data_t
const char * op_name
Definition: common.h:180
ISO_8601 Date handling.
struct pe_match_data pe_match_data_t
rsc_start_requirement
Definition: common.h:85
GHashTable * meta
Definition: common.h:170
pe_print_options
Deprecated.
Definition: common.h:119
enum rsc_role_e text2role(const char *role)
Definition: common.c:488
pe_rsc_eval_data_t * rsc_data
Definition: common.h:189
const char * agent
Definition: common.h:176
GHashTable * params
Definition: common.h:169
const char * fail2text(enum action_fail_response fail)
Definition: common.c:314
const char * standard
Definition: common.h:174
crm_time_t * now
Definition: common.h:187
GHashTable * node_hash
Definition: common.h:185
regmatch_t * pmatch
Definition: common.h:164
struct pe_op_eval_data pe_op_eval_data_t
rsc_role_e
Possible roles that a resource can be in.
Definition: common.h:92
Ignored.
Definition: common.h:127
gboolean was_processing_error
Definition: common.c:20
char * name
Definition: pcmk_fence.c:31
gboolean was_processing_warning
Definition: common.c:21
enum rsc_role_e role
Definition: common.h:186
char * string
Definition: common.h:162
action_tasks
Definition: common.h:62