pacemaker  2.0.5-ba59be712
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-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 STONITH_NG_INTERNAL__H
11 # define STONITH_NG_INTERNAL__H
12 
13 # include <glib.h>
14 # include <crm/common/ipc.h>
15 # include <crm/common/xml.h>
17 # include <crm/stonith-ng.h>
18 
20 {
26 };
27 
28 #define stonith__set_device_flags(device_flags, device_id, flags_to_set) do { \
29  device_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
30  "Fence device", device_id, \
31  (device_flags), (flags_to_set), \
32  #flags_to_set); \
33  } while (0)
34 
35 #define stonith__set_call_options(st_call_opts, call_for, flags_to_set) do { \
36  st_call_opts = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
37  "Fencer call", (call_for), \
38  (st_call_opts), (flags_to_set), \
39  #flags_to_set); \
40  } while (0)
41 
42 #define stonith__clear_call_options(st_call_opts, call_for, flags_to_clear) do { \
43  st_call_opts = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
44  "Fencer call", (call_for), \
45  (st_call_opts), (flags_to_clear), \
46  #flags_to_clear); \
47  } while (0)
48 
49 struct stonith_action_s;
50 typedef struct stonith_action_s stonith_action_t;
51 
52 stonith_action_t *stonith_action_create(const char *agent,
53  const char *_action,
54  const char *victim,
55  uint32_t victim_nodeid,
56  int timeout,
57  GHashTable * device_args,
58  GHashTable * port_map,
59  const char * host_arg);
61 void stonith__action_result(stonith_action_t *action, int *rc, char **output,
62  char **error_output);
63 
64 int
66  void *userdata,
67  void (*done) (GPid pid, int rc, const char *output,
68  gpointer user_data),
69  void (*fork_cb) (GPid pid, gpointer user_data));
70 
72 
73 xmlNode *create_level_registration_xml(const char *node, const char *pattern,
74  const char *attr, const char *value,
75  int level,
76  stonith_key_value_t *device_list);
77 
78 xmlNode *create_device_registration_xml(const char *id,
79  enum stonith_namespace namespace,
80  const char *agent,
81  stonith_key_value_t *params,
82  const char *rsc_provides);
83 
85 
86 GList *stonith__parse_targets(const char *hosts);
87 
88 gboolean stonith__later_succeeded(stonith_history_t *event, stonith_history_t *top_history);
90 
91 void stonith__device_parameter_flags(uint32_t *device_flags,
92  const char *device_name,
93  xmlNode *metadata);
94 
95 # define ST_LEVEL_MAX 10
96 
97 # define F_STONITH_CLIENTID "st_clientid"
98 # define F_STONITH_CALLOPTS "st_callopt"
99 # define F_STONITH_CALLID "st_callid"
100 # define F_STONITH_CALLDATA "st_calldata"
101 # define F_STONITH_OPERATION "st_op"
102 # define F_STONITH_TARGET "st_target"
103 # define F_STONITH_REMOTE_OP_ID "st_remote_op"
104 # define F_STONITH_REMOTE_OP_ID_RELAY "st_remote_op_relay"
105 # define F_STONITH_RC "st_rc"
106 
107 # define F_STONITH_TIMEOUT "st_timeout"
108 # define F_STONITH_TOLERANCE "st_tolerance"
109 # define F_STONITH_DELAY "st_delay"
110 
111 # define F_STONITH_ACTION_TIMEOUT "st_action_timeout"
112 
113 # define F_STONITH_ACTION_DISALLOWED "st_action_disallowed"
114 
115 # define F_STONITH_DELAY_MAX "st_delay_max"
116 
117 # define F_STONITH_DELAY_BASE "st_delay_base"
118 
120 # define F_STONITH_DEVICE_VERIFIED "st_monitor_verified"
121 
122 # define F_STONITH_DEVICE_REQUIRED "st_required"
123 
124 # define F_STONITH_AVAILABLE_DEVICES "st-available-devices"
125 # define F_STONITH_CALLBACK_TOKEN "st_async_id"
126 # define F_STONITH_CLIENTNAME "st_clientname"
127 # define F_STONITH_CLIENTNODE "st_clientnode"
128 # define F_STONITH_NOTIFY_ACTIVATE "st_notify_activate"
129 # define F_STONITH_NOTIFY_DEACTIVATE "st_notify_deactivate"
130 # define F_STONITH_DELEGATE "st_delegate"
131 
135 # define F_STONITH_ORIGIN "st_origin"
136 # define F_STONITH_HISTORY_LIST "st_history"
137 # define F_STONITH_DATE "st_date"
138 # define F_STONITH_STATE "st_state"
139 # define F_STONITH_ACTIVE "st_active"
140 # define F_STONITH_DIFFERENTIAL "st_differential"
141 
142 # define F_STONITH_DEVICE "st_device_id"
143 # define F_STONITH_ACTION "st_device_action"
144 # define F_STONITH_MODE "st_mode"
145 # define F_STONITH_MERGED "st_op_merged"
146 
147 # define T_STONITH_NG "stonith-ng"
148 # define T_STONITH_REPLY "st-reply"
149 
152 # define T_STONITH_TIMEOUT_VALUE "st-async-timeout-value"
153 # define T_STONITH_NOTIFY "st_notify"
154 
155 # define STONITH_ATTR_HOSTARG "pcmk_host_argument"
156 # define STONITH_ATTR_HOSTMAP "pcmk_host_map"
157 # define STONITH_ATTR_HOSTLIST "pcmk_host_list"
158 # define STONITH_ATTR_HOSTCHECK "pcmk_host_check"
159 # define STONITH_ATTR_DELAY_MAX "pcmk_delay_max"
160 # define STONITH_ATTR_DELAY_BASE "pcmk_delay_base"
161 # define STONITH_ATTR_ACTION_LIMIT "pcmk_action_limit"
162 
163 # define STONITH_ATTR_ACTION_OP "action"
164 
165 # define STONITH_OP_EXEC "st_execute"
166 # define STONITH_OP_TIMEOUT_UPDATE "st_timeout_update"
167 # define STONITH_OP_QUERY "st_query"
168 # define STONITH_OP_FENCE "st_fence"
169 # define STONITH_OP_RELAY "st_relay"
170 # define STONITH_OP_DEVICE_ADD "st_device_register"
171 # define STONITH_OP_DEVICE_DEL "st_device_remove"
172 # define STONITH_OP_FENCE_HISTORY "st_fence_history"
173 # define STONITH_OP_LEVEL_ADD "st_level_add"
174 # define STONITH_OP_LEVEL_DEL "st_level_remove"
175 
176 # define STONITH_WATCHDOG_AGENT "#watchdog"
177 
178 # ifdef HAVE_STONITH_STONITH_H
179 // utilities from st_lha.c
181 int stonith__lha_metadata(const char *agent, int timeout, char **output);
182 bool stonith__agent_is_lha(const char *agent);
183 int stonith__lha_validate(stonith_t *st, int call_options, const char *target,
184  const char *agent, GHashTable *params,
185  int timeout, char **output, char **error_output);
186 # endif
187 
188 // utilities from st_rhcs.c
190 int stonith__rhcs_metadata(const char *agent, int timeout, char **output);
191 bool stonith__agent_is_rhcs(const char *agent);
192 int stonith__rhcs_validate(stonith_t *st, int call_options, const char *target,
193  const char *agent, GHashTable *params, const char *host_arg,
194  int timeout, char **output, char **error_output);
195 
196 int stonith__failed_history(pcmk__output_t *out, va_list args);
197 int stonith__history(pcmk__output_t *out, va_list args);
198 int stonith__full_history(pcmk__output_t *out, va_list args);
199 int stonith__full_history_xml(pcmk__output_t *out, va_list args);
200 int stonith__last_fenced_html(pcmk__output_t *out, va_list args);
201 int stonith__last_fenced_text(pcmk__output_t *out, va_list args);
202 int stonith__last_fenced_xml(pcmk__output_t *out, va_list args);
203 int stonith__pending_actions(pcmk__output_t *out, va_list args);
204 int stonith__event_html(pcmk__output_t *out, va_list args);
205 int stonith__event_text(pcmk__output_t *out, va_list args);
206 int stonith__event_xml(pcmk__output_t *out, va_list args);
207 int stonith__validate_agent_html(pcmk__output_t *out, va_list args);
208 int stonith__validate_agent_text(pcmk__output_t *out, va_list args);
209 int stonith__validate_agent_xml(pcmk__output_t *out, va_list args);
210 
212  bool (*matching_fn)(stonith_history_t *, void *),
213  void *user_data);
214 bool stonith__event_state_pending(stonith_history_t *history, void *user_data);
215 bool stonith__event_state_eq(stonith_history_t *history, void *user_data);
216 bool stonith__event_state_neq(stonith_history_t *history, void *user_data);
217 
218 #endif
int stonith__last_fenced_text(pcmk__output_t *out, va_list args)
Definition: st_output.c:165
void stonith__destroy_action(stonith_action_t *action)
Definition: st_client.c:582
struct stonith_action_s stonith_action_t
Definition: internal.h:50
stonith_history_t * stonith__first_matching_event(stonith_history_t *history, bool(*matching_fn)(stonith_history_t *, void *), void *user_data)
Definition: st_client.c:2616
void stonith__action_result(stonith_action_t *action, int *rc, char **output, char **error_output)
Definition: st_client.c:613
int stonith__event_text(pcmk__output_t *out, va_list args)
Definition: st_output.c:277
int stonith__rhcs_metadata(const char *agent, int timeout, char **output)
Execute RHCS-compatible agent's meta-data action.
Definition: st_rhcs.c:207
void stonith__register_messages(pcmk__output_t *out)
Definition: st_output.c:459
int stonith__execute(stonith_action_t *action)
Definition: st_client.c:897
xmlNode * create_level_registration_xml(const char *node, const char *pattern, const char *attr, const char *value, int level, stonith_key_value_t *device_list)
Definition: st_client.c:394
int stonith__lha_validate(stonith_t *st, int call_options, const char *target, const char *agent, GHashTable *params, int timeout, char **output, char **error_output)
Definition: st_lha.c:274
stonith_history_t * stonith__sort_history(stonith_history_t *history)
Definition: st_client.c:2571
int stonith__full_history(pcmk__output_t *out, va_list args)
Definition: st_output.c:88
int stonith__lha_metadata(const char *agent, int timeout, char **output)
Definition: st_lha.c:175
stonith_action_t * stonith_action_create(const char *agent, const char *_action, const char *victim, uint32_t victim_nodeid, int timeout, GHashTable *device_args, GHashTable *port_map, const char *host_arg)
Definition: st_client.c:642
stonith_namespace
Definition: stonith-ng.h:75
uint32_t pid
Definition: internal.h:81
int stonith__last_fenced_xml(pcmk__output_t *out, va_list args)
Definition: st_output.c:180
int stonith_action_execute_async(stonith_action_t *action, void *userdata, void(*done)(GPid pid, int rc, const char *output, gpointer user_data), void(*fork_cb)(GPid pid, gpointer user_data))
Definition: st_client.c:870
const char * action
Definition: pcmk_fence.c:30
bool stonith__event_state_pending(stonith_history_t *history, void *user_data)
Definition: st_client.c:2630
int stonith__list_lha_agents(stonith_key_value_t **devices)
Definition: st_lha.c:106
GList * stonith__parse_targets(const char *hosts)
Definition: st_client.c:2500
st_device_flags
Definition: internal.h:19
bool stonith__agent_is_rhcs(const char *agent)
Definition: st_rhcs.c:233
Formatted output for pacemaker tools.
stonith_t * st
Definition: pcmk_fence.c:28
int rc
Definition: pcmk_fence.c:35
void stonith__device_parameter_flags(uint32_t *device_flags, const char *device_name, xmlNode *metadata)
Definition: st_client.c:2660
int stonith__validate_agent_xml(pcmk__output_t *out, va_list args)
Definition: st_output.c:414
int stonith__full_history_xml(pcmk__output_t *out, va_list args)
Definition: st_output.c:113
gboolean stonith__later_succeeded(stonith_history_t *event, stonith_history_t *top_history)
Definition: st_client.c:2540
int stonith__validate_agent_html(pcmk__output_t *out, va_list args)
Definition: st_output.c:361
int stonith__event_html(pcmk__output_t *out, va_list args)
Definition: st_output.c:229
Wrappers for and extensions to libxml2.
int stonith__rhcs_validate(stonith_t *st, int call_options, const char *target, const char *agent, GHashTable *params, const char *host_arg, int timeout, char **output, char **error_output)
Definition: st_rhcs.c:244
int stonith__history(pcmk__output_t *out, va_list args)
Definition: st_output.c:62
const char * target
Definition: pcmk_fence.c:29
int stonith__list_rhcs_agents(stonith_key_value_t **devices)
Definition: st_rhcs.c:33
Fencing aka. STONITH.
This structure contains everything that makes up a single output formatter.
int stonith__event_xml(pcmk__output_t *out, va_list args)
Definition: st_output.c:315
int stonith__failed_history(pcmk__output_t *out, va_list args)
Definition: st_output.c:34
int stonith__validate_agent_text(pcmk__output_t *out, va_list args)
Definition: st_output.c:386
IPC interface to Pacemaker daemons.
bool stonith__agent_is_lha(const char *agent)
Determine namespace of a fence agent.
Definition: st_lha.c:79
int stonith__pending_actions(pcmk__output_t *out, va_list args)
Definition: st_output.c:200
bool stonith__event_state_eq(stonith_history_t *history, void *user_data)
Definition: st_client.c:2636
unsigned int timeout
Definition: pcmk_fence.c:32
int stonith__last_fenced_html(pcmk__output_t *out, va_list args)
Definition: st_output.c:149
xmlNode * create_device_registration_xml(const char *id, enum stonith_namespace namespace, const char *agent, stonith_key_value_t *params, const char *rsc_provides)
Definition: st_client.c:274
bool stonith__event_state_neq(stonith_history_t *history, void *user_data)
Definition: st_client.c:2642