pacemaker  2.0.5-ba59be7122
Scalable High-Availability cluster resource manager
common.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2020 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 
91 enum rsc_role_e {
97 };
98 
99 # define RSC_ROLE_MAX RSC_ROLE_MASTER+1
100 
101 # define RSC_ROLE_UNKNOWN_S "Unknown"
102 # define RSC_ROLE_STOPPED_S "Stopped"
103 # define RSC_ROLE_STARTED_S "Started"
104 # define RSC_ROLE_SLAVE_S "Slave"
105 # define RSC_ROLE_MASTER_S "Master"
106 
108  pe_print_log = (1 << 0),
109  pe_print_html = (1 << 1),
110  pe_print_ncurses = (1 << 2),
111  pe_print_printf = (1 << 3),
112  pe_print_dev = (1 << 4), // Debugging (@COMPAT probably not useful)
113  pe_print_details = (1 << 5),
115  pe_print_rsconly = (1 << 7),
116  pe_print_ops = (1 << 8),
118  pe_print_xml = (1 << 10),
119  pe_print_brief = (1 << 11),
120  pe_print_pending = (1 << 12),
122  pe_print_clone_active = (1 << 14), // Print clone instances only if active
123  pe_print_implicit = (1 << 15) // Print implicitly created resources
124 };
125 
126 const char *task2text(enum action_tasks task);
127 enum action_tasks text2task(const char *task);
128 enum rsc_role_e text2role(const char *role);
129 const char *role2text(enum rsc_role_e role);
130 const char *fail2text(enum action_fail_response fail);
131 
132 const char *pe_pref(GHashTable * options, const char *name);
133 void calculate_active_ops(GList * sorted_op_list, int *start_index, int *stop_index);
134 
135 static inline const char *
136 recovery2text(enum rsc_recovery_type type)
137 {
138  switch (type) {
139  case recovery_stop_only:
140  return "shutting it down";
141  case recovery_stop_start:
142  return "attempting recovery";
143  case recovery_block:
144  return "waiting for an administrator";
145  }
146  return "Unknown";
147 }
148 
149 typedef struct pe_re_match_data {
150  char *string;
151  int nregs;
152  regmatch_t *pmatch;
154 
155 typedef struct pe_match_data {
157  GHashTable *params;
158  GHashTable *meta;
160 
161 typedef struct pe_rsc_eval_data {
162  const char *standard;
163  const char *provider;
164  const char *agent;
166 
167 typedef struct pe_op_eval_data {
168  const char *op_name;
169  guint interval;
171 
172 typedef struct pe_rule_eval_data {
173  GHashTable *node_hash;
174  enum rsc_role_e role;
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #endif
pe_match_data::re
pe_re_match_data_t * re
Definition: common.h:156
pe_rule_eval_data_t
struct pe_rule_eval_data pe_rule_eval_data_t
pe_rule_eval_data
Definition: common.h:172
action_fail_response
action_fail_response
Definition: common.h:34
pe_re_match_data::nregs
int nregs
Definition: common.h:151
pe_print_log
@ pe_print_log
Definition: common.h:108
pe_print_suppres_nl
@ pe_print_suppres_nl
Definition: common.h:117
action_fail_standby
@ action_fail_standby
Definition: common.h:43
pe_print_xml
@ pe_print_xml
Definition: common.h:118
pe_print_dev
@ pe_print_dev
Definition: common.h:112
pe_re_match_data_t
struct pe_re_match_data pe_re_match_data_t
RSC_ROLE_STOPPED
@ RSC_ROLE_STOPPED
Definition: common.h:93
action_demote
@ action_demote
Definition: common.h:73
action_fail_stop
@ action_fail_stop
Definition: common.h:42
pe_print_max_details
@ pe_print_max_details
Definition: common.h:114
RSC_ROLE_MASTER
@ RSC_ROLE_MASTER
Definition: common.h:96
started_rsc
@ started_rsc
Definition: common.h:68
rsc_req_quorum
@ rsc_req_quorum
Definition: common.h:87
action_fail_demote
@ action_fail_demote
Definition: common.h:58
pe_re_match_data::pmatch
regmatch_t * pmatch
Definition: common.h:152
pe_rule_eval_data::match_data
pe_match_data_t * match_data
Definition: common.h:176
pe_print_clone_active
@ pe_print_clone_active
Definition: common.h:122
pe_op_eval_data::interval
guint interval
Definition: common.h:169
rsc_role_e
rsc_role_e
Definition: common.h:91
stop_rsc
@ stop_rsc
Definition: common.h:65
was_processing_warning
gboolean was_processing_warning
Definition: common.c:21
pe_op_eval_data
Definition: common.h:167
pe_print_brief
@ pe_print_brief
Definition: common.h:119
pe_match_data
Definition: common.h:155
pe_pref
const char * pe_pref(GHashTable *options, const char *name)
Definition: common.c:312
stopped_rsc
@ stopped_rsc
Definition: common.h:66
action_fail_recover
@ action_fail_recover
Definition: common.h:37
type
enum crm_ais_msg_types type
Definition: internal.h:3
pe_print_ncurses
@ pe_print_ncurses
Definition: common.h:110
text2task
enum action_tasks text2task(const char *task)
Definition: common.c:358
action_notify
@ action_notify
Definition: common.h:69
pe_rsc_eval_data::agent
const char * agent
Definition: common.h:164
rsc_start_requirement
rsc_start_requirement
Definition: common.h:85
pe_op_eval_data::op_name
const char * op_name
Definition: common.h:168
pe_rsc_eval_data
Definition: common.h:161
rsc_recovery_type
rsc_recovery_type
Definition: common.h:79
pe_rsc_eval_data_t
struct pe_rsc_eval_data pe_rsc_eval_data_t
pe_rule_eval_data::op_data
pe_op_eval_data_t * op_data
Definition: common.h:178
pe_print_clone_details
@ pe_print_clone_details
Definition: common.h:121
pe_print_ops
@ pe_print_ops
Definition: common.h:116
pe_print_details
@ pe_print_details
Definition: common.h:113
pe_rsc_eval_data::standard
const char * standard
Definition: common.h:162
pe_match_data::meta
GHashTable * meta
Definition: common.h:158
action_fail_block
@ action_fail_block
Definition: common.h:41
RSC_ROLE_SLAVE
@ RSC_ROLE_SLAVE
Definition: common.h:95
pe_rule_eval_data::role
enum rsc_role_e role
Definition: common.h:174
pe_rule_eval_data::node_hash
GHashTable * node_hash
Definition: common.h:173
action_notified
@ action_notified
Definition: common.h:70
action_fail_fence
@ action_fail_fence
Definition: common.h:44
pe_print_html
@ pe_print_html
Definition: common.h:109
pe_print_options
pe_print_options
Definition: common.h:107
pe_rule_eval_data::now
crm_time_t * now
Definition: common.h:175
pe_print_rsconly
@ pe_print_rsconly
Definition: common.h:115
pe_rule_eval_data::rsc_data
pe_rsc_eval_data_t * rsc_data
Definition: common.h:177
action_fail_migrate
@ action_fail_migrate
Definition: common.h:40
action_fail_reset_remote
@ action_fail_reset_remote
Definition: common.h:56
role2text
const char * role2text(enum rsc_role_e role)
Definition: common.c:463
pe_re_match_data
Definition: common.h:149
RSC_ROLE_UNKNOWN
@ RSC_ROLE_UNKNOWN
Definition: common.h:92
action_demoted
@ action_demoted
Definition: common.h:74
rsc_req_stonith
@ rsc_req_stonith
Definition: common.h:88
iso8601.h
ISO_8601 Date handling.
shutdown_crm
@ shutdown_crm
Definition: common.h:75
action_fail_restart_container
@ action_fail_restart_container
Definition: common.h:48
action_promoted
@ action_promoted
Definition: common.h:72
pe_match_data::params
GHashTable * params
Definition: common.h:157
text2role
enum rsc_role_e text2role(const char *role)
Definition: common.c:484
rsc_req_nothing
@ rsc_req_nothing
Definition: common.h:86
recovery_stop_only
@ recovery_stop_only
Definition: common.h:81
action_promote
@ action_promote
Definition: common.h:71
pe_match_data_t
struct pe_match_data pe_match_data_t
pe_print_printf
@ pe_print_printf
Definition: common.h:111
recovery_stop_start
@ recovery_stop_start
Definition: common.h:80
pe_re_match_data::string
char * string
Definition: common.h:150
start_rsc
@ start_rsc
Definition: common.h:67
pe_print_implicit
@ pe_print_implicit
Definition: common.h:123
action_fail_ignore
@ action_fail_ignore
Definition: common.h:35
calculate_active_ops
void calculate_active_ops(GList *sorted_op_list, int *start_index, int *stop_index)
Definition: unpack.c:2191
pe_print_pending
@ pe_print_pending
Definition: common.h:120
pe_rsc_eval_data::provider
const char * provider
Definition: common.h:163
was_processing_error
gboolean was_processing_error
Definition: common.c:20
RSC_ROLE_STARTED
@ RSC_ROLE_STARTED
Definition: common.h:94
stonith_node
@ stonith_node
Definition: common.h:76
pe_op_eval_data_t
struct pe_op_eval_data pe_op_eval_data_t
action_tasks
action_tasks
Definition: common.h:62
recovery_block
@ recovery_block
Definition: common.h:82
name
char * name
Definition: pcmk_fence.c:31
monitor_rsc
@ monitor_rsc
Definition: common.h:64
fail2text
const char * fail2text(enum action_fail_response fail)
Definition: common.c:318
no_action
@ no_action
Definition: common.h:63
crm_time_t
struct crm_time_s crm_time_t
Definition: iso8601.h:32
task2text
const char * task2text(enum action_tasks task)
Definition: common.c:410