pacemaker  1.1.12-561c4cf
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef PE_INTERNAL__H
19 # define PE_INTERNAL__H
20 # include <crm/pengine/status.h>
21 
22 # define pe_rsc_info(rsc, fmt, args...) crm_log_tag(LOG_INFO, rsc ? rsc->id : "<NULL>", fmt, ##args)
23 # define pe_rsc_debug(rsc, fmt, args...) crm_log_tag(LOG_DEBUG, rsc ? rsc->id : "<NULL>", fmt, ##args)
24 # define pe_rsc_trace(rsc, fmt, args...) crm_log_tag(LOG_TRACE, rsc ? rsc->id : "<NULL>", fmt, ##args)
25 
26 # define pe_err(fmt...) { was_processing_error = TRUE; crm_config_error = TRUE; crm_err(fmt); }
27 # define pe_warn(fmt...) { was_processing_warning = TRUE; crm_config_warning = TRUE; crm_warn(fmt); }
28 # define pe_proc_err(fmt...) { was_processing_error = TRUE; crm_err(fmt); }
29 # define pe_proc_warn(fmt...) { was_processing_warning = TRUE; crm_warn(fmt); }
30 # define pe_set_action_bit(action, bit) action->flags = crm_set_bit(__FUNCTION__, action->uuid, action->flags, bit)
31 # define pe_clear_action_bit(action, bit) action->flags = crm_clear_bit(__FUNCTION__, action->uuid, action->flags, bit)
32 
33 typedef struct notify_data_s {
34  GHashTable *keys;
35 
36  const char *action;
37 
42 
43  GListPtr active; /* notify_entry_t* */
44  GListPtr inactive; /* notify_entry_t* */
45  GListPtr start; /* notify_entry_t* */
46  GListPtr stop; /* notify_entry_t* */
47  GListPtr demote; /* notify_entry_t* */
48  GListPtr promote; /* notify_entry_t* */
49  GListPtr master; /* notify_entry_t* */
50  GListPtr slave; /* notify_entry_t* */
51 
53 
54 bool pe_can_fence(pe_working_set_t *data_set, node_t *node);
55 
56 int merge_weights(int w1, int w2);
57 void add_hash_param(GHashTable * hash, const char *name, const char *value);
58 void append_hashtable(gpointer key, gpointer value, gpointer user_data);
59 
60 char *native_parameter(resource_t * rsc, node_t * node, gboolean create, const char *name,
61  pe_working_set_t * data_set);
62 node_t *native_location(resource_t * rsc, GListPtr * list, gboolean current);
63 
64 void pe_metadata(void);
65 void verify_pe_options(GHashTable * options);
66 
67 void common_update_score(resource_t * rsc, const char *id, int score);
68 void native_add_running(resource_t * rsc, node_t * node, pe_working_set_t * data_set);
69 node_t *rsc_known_on(resource_t * rsc, GListPtr * list);
70 
71 gboolean native_unpack(resource_t * rsc, pe_working_set_t * data_set);
72 gboolean group_unpack(resource_t * rsc, pe_working_set_t * data_set);
73 gboolean clone_unpack(resource_t * rsc, pe_working_set_t * data_set);
74 gboolean master_unpack(resource_t * rsc, pe_working_set_t * data_set);
75 
76 resource_t *native_find_rsc(resource_t * rsc, const char *id, node_t * node, int flags);
77 
78 gboolean native_active(resource_t * rsc, gboolean all);
79 gboolean group_active(resource_t * rsc, gboolean all);
80 gboolean clone_active(resource_t * rsc, gboolean all);
81 gboolean master_active(resource_t * rsc, gboolean all);
82 
83 void native_print(resource_t * rsc, const char *pre_text, long options, void *print_data);
84 void group_print(resource_t * rsc, const char *pre_text, long options, void *print_data);
85 void clone_print(resource_t * rsc, const char *pre_text, long options, void *print_data);
86 void master_print(resource_t * rsc, const char *pre_text, long options, void *print_data);
87 
88 void native_free(resource_t * rsc);
89 void group_free(resource_t * rsc);
90 void clone_free(resource_t * rsc);
91 void master_free(resource_t * rsc);
92 
93 enum rsc_role_e native_resource_state(const resource_t * rsc, gboolean current);
94 enum rsc_role_e group_resource_state(const resource_t * rsc, gboolean current);
95 enum rsc_role_e clone_resource_state(const resource_t * rsc, gboolean current);
96 enum rsc_role_e master_resource_state(const resource_t * rsc, gboolean current);
97 
98 gboolean common_unpack(xmlNode * xml_obj, resource_t ** rsc, resource_t * parent,
99  pe_working_set_t * data_set);
100 void common_print(resource_t * rsc, const char *pre_text, long options, void *print_data);
101 void common_free(resource_t * rsc);
102 
104 
105 extern node_t *node_copy(node_t * this_node);
106 extern time_t get_effective_time(pe_working_set_t * data_set);
107 extern int get_failcount(node_t * node, resource_t * rsc, time_t *last_failure,
108  pe_working_set_t * data_set);
109 extern int get_failcount_full(node_t * node, resource_t * rsc, time_t *last_failure,
110  bool effective, xmlNode * xml_op, pe_working_set_t * data_set);
111 extern int get_failcount_all(node_t * node, resource_t * rsc, time_t *last_failure,
112  pe_working_set_t * data_set);
113 
114 /* Binary like operators for lists of nodes */
115 extern void node_list_exclude(GHashTable * list, GListPtr list2, gboolean merge_scores);
116 extern GListPtr node_list_dup(GListPtr list, gboolean reset, gboolean filter);
117 extern GListPtr node_list_from_hash(GHashTable * hash, gboolean reset, gboolean filter);
118 
119 extern GHashTable *node_hash_from_list(GListPtr list);
120 static inline gpointer
121 pe_hash_table_lookup(GHashTable * hash, gconstpointer key)
122 {
123  if (hash) {
124  return g_hash_table_lookup(hash, key);
125  }
126  return NULL;
127 }
128 
129 extern action_t *get_pseudo_op(const char *name, pe_working_set_t * data_set);
130 extern gboolean order_actions(action_t * lh_action, action_t * rh_action, enum pe_ordering order);
131 
132 GHashTable *node_hash_dup(GHashTable * hash);
133 extern GListPtr node_list_and(GListPtr list1, GListPtr list2, gboolean filter);
134 
135 extern GListPtr node_list_xor(GListPtr list1, GListPtr list2, gboolean filter);
136 
137 extern GListPtr node_list_minus(GListPtr list1, GListPtr list2, gboolean filter);
138 
139 extern void pe_free_shallow(GListPtr alist);
140 extern void pe_free_shallow_adv(GListPtr alist, gboolean with_data);
141 
142 /* Printing functions for debug */
143 extern void print_node(const char *pre_text, node_t * node, gboolean details);
144 
145 extern void print_resource(int log_level, const char *pre_text, resource_t * rsc, gboolean details);
146 
147 extern void dump_node_scores_worker(int level, const char *file, const char *function, int line,
148  resource_t * rsc, const char *comment, GHashTable * nodes);
149 
150 extern void dump_node_capacity(int level, const char *comment, node_t * node);
151 extern void dump_rsc_utilization(int level, const char *comment, resource_t * rsc, node_t * node);
152 
153 # define dump_node_scores(level, rsc, text, nodes) do { \
154  dump_node_scores_worker(level, __FILE__, __FUNCTION__, __LINE__, rsc, text, nodes); \
155  } while(0)
156 
157 /* Sorting functions */
158 extern gint sort_rsc_priority(gconstpointer a, gconstpointer b);
159 extern gint sort_rsc_index(gconstpointer a, gconstpointer b);
160 
161 extern xmlNode *find_rsc_op_entry(resource_t * rsc, const char *key);
162 
163 extern action_t *custom_action(resource_t * rsc, char *key, const char *task, node_t * on_node,
164  gboolean optional, gboolean foo, pe_working_set_t * data_set);
165 
166 # define delete_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_DELETE, 0)
167 # define delete_action(rsc, node, optional) custom_action( \
168  rsc, delete_key(rsc), CRMD_ACTION_DELETE, node, \
169  optional, TRUE, data_set);
170 
171 # define stopped_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_STOPPED, 0)
172 # define stopped_action(rsc, node, optional) custom_action( \
173  rsc, stopped_key(rsc), CRMD_ACTION_STOPPED, node, \
174  optional, TRUE, data_set);
175 
176 # define stop_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_STOP, 0)
177 # define stop_action(rsc, node, optional) custom_action( \
178  rsc, stop_key(rsc), CRMD_ACTION_STOP, node, \
179  optional, TRUE, data_set);
180 
181 # define start_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_START, 0)
182 # define start_action(rsc, node, optional) custom_action( \
183  rsc, start_key(rsc), CRMD_ACTION_START, node, \
184  optional, TRUE, data_set)
185 
186 # define started_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_STARTED, 0)
187 # define started_action(rsc, node, optional) custom_action( \
188  rsc, started_key(rsc), CRMD_ACTION_STARTED, node, \
189  optional, TRUE, data_set)
190 
191 # define promote_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_PROMOTE, 0)
192 # define promote_action(rsc, node, optional) custom_action( \
193  rsc, promote_key(rsc), CRMD_ACTION_PROMOTE, node, \
194  optional, TRUE, data_set)
195 
196 # define promoted_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_PROMOTED, 0)
197 # define promoted_action(rsc, node, optional) custom_action( \
198  rsc, promoted_key(rsc), CRMD_ACTION_PROMOTED, node, \
199  optional, TRUE, data_set)
200 
201 # define demote_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_DEMOTE, 0)
202 # define demote_action(rsc, node, optional) custom_action( \
203  rsc, demote_key(rsc), CRMD_ACTION_DEMOTE, node, \
204  optional, TRUE, data_set)
205 
206 # define demoted_key(rsc) generate_op_key(rsc->id, CRMD_ACTION_DEMOTED, 0)
207 # define demoted_action(rsc, node, optional) custom_action( \
208  rsc, demoted_key(rsc), CRMD_ACTION_DEMOTED, node, \
209  optional, TRUE, data_set)
210 
211 extern action_t *find_first_action(GListPtr input, const char *uuid, const char *task,
212  node_t * on_node);
213 extern enum action_tasks get_complex_task(resource_t * rsc, const char *name,
214  gboolean allow_non_atomic);
215 
216 extern GListPtr find_actions(GListPtr input, const char *key, node_t * on_node);
217 extern GListPtr find_actions_exact(GListPtr input, const char *key, node_t * on_node);
218 extern GListPtr find_recurring_actions(GListPtr input, node_t * not_on_node);
219 
220 extern void pe_free_action(action_t * action);
221 
222 extern void resource_location(resource_t * rsc, node_t * node, int score, const char *tag,
223  pe_working_set_t * data_set);
224 
225 extern gint sort_op_by_callid(gconstpointer a, gconstpointer b);
226 extern gboolean get_target_role(resource_t * rsc, enum rsc_role_e *role);
227 
228 extern resource_t *find_clone_instance(resource_t * rsc, const char *sub_id,
229  pe_working_set_t * data_set);
230 
231 extern void destroy_ticket(gpointer data);
232 extern ticket_t *ticket_new(const char *ticket_id, pe_working_set_t * data_set);
233 
234 char *clone_strip(const char *last_rsc_id);
235 char *clone_zero(const char *last_rsc_id);
236 
237 int get_target_rc(xmlNode * xml_op);
238 
239 gint sort_node_uname(gconstpointer a, gconstpointer b);
240 bool is_set_recursive(resource_t * rsc, long long flag, bool any);
241 
252 };
253 
254 typedef struct op_digest_cache_s {
256  xmlNode *params_all;
257  xmlNode *params_restart;
261 
262 op_digest_cache_t *rsc_action_digest_cmp(resource_t * rsc, xmlNode * xml_op, node_t * node,
263  pe_working_set_t * data_set);
264 
265 action_t *pe_fence_op(node_t * node, const char *op, bool optional, pe_working_set_t * data_set);
266 void trigger_unfencing(
267  resource_t * rsc, node_t *node, const char *reason, action_t *dependancy, pe_working_set_t * data_set);
268 
269 void set_bit_recursive(resource_t * rsc, unsigned long long flag);
270 void clear_bit_recursive(resource_t * rsc, unsigned long long flag);
271 gboolean xml_contains_remote_node(xmlNode *xml);
272 gboolean is_baremetal_remote_node(node_t *node);
273 gboolean is_container_remote_node(node_t *node);
274 gboolean is_remote_node(node_t *node);
276 
277 gboolean add_tag_ref(GHashTable * tags, const char * tag_name, const char * obj_ref);
278 
279 void print_rscs_brief(GListPtr rsc_list, const char * pre_text, long options,
280  void * print_data, gboolean print_all);
281 void pe_fence_node(pe_working_set_t * data_set, node_t * node, const char *reason);
282 
283 #endif
void verify_pe_options(GHashTable *options)
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
action_t * pre_done
Definition: internal.h:40
void group_free(resource_t *rsc)
void dump_rsc_utilization(int level, const char *comment, resource_t *rsc, node_t *node)
gint sort_rsc_priority(gconstpointer a, gconstpointer b)
gboolean is_baremetal_remote_node(node_t *node)
gint sort_rsc_index(gconstpointer a, gconstpointer b)
gboolean get_target_role(resource_t *rsc, enum rsc_role_e *role)
void pe_metadata(void)
action_t * post_done
Definition: internal.h:41
GListPtr node_list_dup(GListPtr list, gboolean reset, gboolean filter)
resource_t * rsc_contains_remote_node(pe_working_set_t *data_set, resource_t *rsc)
gboolean is_remote_node(node_t *node)
action_t * post
Definition: internal.h:39
bool pe_can_fence(pe_working_set_t *data_set, node_t *node)
enum action_tasks get_complex_task(resource_t *rsc, const char *name, gboolean allow_non_atomic)
struct op_digest_cache_s op_digest_cache_t
enum rsc_role_e master_resource_state(const resource_t *rsc, gboolean current)
GListPtr slave
Definition: internal.h:50
char * native_parameter(resource_t *rsc, node_t *node, gboolean create, const char *name, pe_working_set_t *data_set)
GListPtr find_actions_exact(GListPtr input, const char *key, node_t *on_node)
GHashTable * keys
Definition: internal.h:34
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
void common_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
void common_update_score(resource_t *rsc, const char *id, int score)
void common_free(resource_t *rsc)
void print_node(const char *pre_text, node_t *node, gboolean details)
gint sort_op_by_callid(gconstpointer a, gconstpointer b)
node_t * node_copy(node_t *this_node)
time_t get_effective_time(pe_working_set_t *data_set)
GListPtr node_list_and(GListPtr list1, GListPtr list2, gboolean filter)
gboolean master_active(resource_t *rsc, gboolean all)
xmlNode * params_restart
Definition: internal.h:257
void set_bit_recursive(resource_t *rsc, unsigned long long flag)
action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
int get_target_rc(xmlNode *xml_op)
int get_failcount(node_t *node, resource_t *rsc, time_t *last_failure, pe_working_set_t *data_set)
void trigger_unfencing(resource_t *rsc, node_t *node, const char *reason, action_t *dependancy, pe_working_set_t *data_set)
GListPtr node_list_xor(GListPtr list1, GListPtr list2, gboolean filter)
void native_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
void print_rscs_brief(GListPtr rsc_list, const char *pre_text, long options, void *print_data, gboolean print_all)
GListPtr find_recurring_actions(GListPtr input, node_t *not_on_node)
void clone_free(resource_t *rsc)
enum rsc_role_e group_resource_state(const resource_t *rsc, gboolean current)
void master_free(resource_t *rsc)
GListPtr stop
Definition: internal.h:46
void native_add_running(resource_t *rsc, node_t *node, pe_working_set_t *data_set)
void append_hashtable(gpointer key, gpointer value, gpointer user_data)
int get_failcount_full(node_t *node, resource_t *rsc, time_t *last_failure, bool effective, xmlNode *xml_op, pe_working_set_t *data_set)
char * digest_all_calc
Definition: internal.h:258
char * clone_strip(const char *last_rsc_id)
pe_working_set_t * pe_dataset
enum rsc_digest_cmp_val rc
Definition: internal.h:255
action_t * find_first_action(GListPtr input, const char *uuid, const char *task, node_t *on_node)
GListPtr master
Definition: internal.h:49
void pe_fence_node(pe_working_set_t *data_set, node_t *node, const char *reason)
gboolean xml_contains_remote_node(xmlNode *xml)
gboolean add_tag_ref(GHashTable *tags, const char *tag_name, const char *obj_ref)
action_t * custom_action(resource_t *rsc, char *key, const char *task, node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
void pe_free_shallow_adv(GListPtr alist, gboolean with_data)
enum rsc_role_e native_resource_state(const resource_t *rsc, gboolean current)
void group_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
xmlNode * find_rsc_op_entry(resource_t *rsc, const char *key)
gboolean native_active(resource_t *rsc, gboolean all)
GHashTable * node_hash_dup(GHashTable *hash)
node_t * native_location(resource_t *rsc, GListPtr *list, gboolean current)
GListPtr node_list_from_hash(GHashTable *hash, gboolean reset, gboolean filter)
GListPtr find_actions(GListPtr input, const char *key, node_t *on_node)
xmlNode * params_all
Definition: internal.h:256
action_t * pe_fence_op(node_t *node, const char *op, bool optional, pe_working_set_t *data_set)
GListPtr active
Definition: internal.h:43
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
GListPtr node_list_minus(GListPtr list1, GListPtr list2, gboolean filter)
pe_ordering
Definition: status.h:339
GHashTable * node_hash_from_list(GListPtr list)
gboolean clone_active(resource_t *rsc, gboolean all)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
GListPtr demote
Definition: internal.h:47
void resource_location(resource_t *rsc, node_t *node, int score, const char *tag, pe_working_set_t *data_set)
void node_list_exclude(GHashTable *list, GListPtr list2, gboolean merge_scores)
int get_failcount_all(node_t *node, resource_t *rsc, time_t *last_failure, pe_working_set_t *data_set)
ticket_t * ticket_new(const char *ticket_id, pe_working_set_t *data_set)
gboolean group_active(resource_t *rsc, gboolean all)
char * clone_zero(const char *last_rsc_id)
GListPtr inactive
Definition: internal.h:44
void dump_node_capacity(int level, const char *comment, node_t *node)
int merge_weights(int w1, int w2)
char data[0]
Definition: internal.h:58
action_t * pre
Definition: internal.h:38
gboolean is_container_remote_node(node_t *node)
rsc_role_e
Definition: common.h:70
void native_free(resource_t *rsc)
void dump_node_scores_worker(int level, const char *file, const char *function, int line, resource_t *rsc, const char *comment, GHashTable *nodes)
gboolean native_unpack(resource_t *rsc, pe_working_set_t *data_set)
void pe_free_action(action_t *action)
void clear_bit_recursive(resource_t *rsc, unsigned long long flag)
void destroy_ticket(gpointer data)
void pe_free_shallow(GListPtr alist)
Definition: status.h:156
GListPtr promote
Definition: internal.h:48
struct notify_data_s notify_data_t
void print_resource(int log_level, const char *pre_text, resource_t *rsc, gboolean details)
GListPtr start
Definition: internal.h:45
gboolean order_actions(action_t *lh_action, action_t *rh_action, enum pe_ordering order)
op_digest_cache_t * rsc_action_digest_cmp(resource_t *rsc, xmlNode *xml_op, node_t *node, pe_working_set_t *data_set)
const char * action
Definition: internal.h:36
resource_t * find_clone_instance(resource_t *rsc, const char *sub_id, pe_working_set_t *data_set)
gboolean group_unpack(resource_t *rsc, pe_working_set_t *data_set)
gint sort_node_uname(gconstpointer a, gconstpointer b)
GList * GListPtr
Definition: crm.h:189
bool is_set_recursive(resource_t *rsc, long long flag, bool any)
char * digest_restart_calc
Definition: internal.h:259
node_t * rsc_known_on(resource_t *rsc, GListPtr *list)
resource_t * native_find_rsc(resource_t *rsc, const char *id, node_t *node, int flags)
void master_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
action_tasks
Definition: common.h:41
rsc_digest_cmp_val
Definition: internal.h:242
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
gboolean master_unpack(resource_t *rsc, pe_working_set_t *data_set)