pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2022 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 
27 };
28 
29 #define stonith__set_device_flags(device_flags, device_id, flags_to_set) do { \
30  device_flags = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
31  "Fence device", device_id, \
32  (device_flags), (flags_to_set), \
33  #flags_to_set); \
34  } while (0)
35 
36 #define stonith__set_call_options(st_call_opts, call_for, flags_to_set) do { \
37  st_call_opts = pcmk__set_flags_as(__func__, __LINE__, LOG_TRACE, \
38  "Fencer call", (call_for), \
39  (st_call_opts), (flags_to_set), \
40  #flags_to_set); \
41  } while (0)
42 
43 #define stonith__clear_call_options(st_call_opts, call_for, flags_to_clear) do { \
44  st_call_opts = pcmk__clear_flags_as(__func__, __LINE__, LOG_TRACE, \
45  "Fencer call", (call_for), \
46  (st_call_opts), (flags_to_clear), \
47  #flags_to_clear); \
48  } while (0)
49 
50 struct stonith_action_s;
51 typedef struct stonith_action_s stonith_action_t;
52 
53 stonith_action_t *stonith__action_create(const char *agent,
54  const char *action_name,
55  const char *target,
56  uint32_t target_nodeid,
57  int timeout_sec,
58  GHashTable *device_args,
59  GHashTable *port_map,
60  const char *host_arg);
64 void stonith__xe_set_result(xmlNode *xml, const pcmk__action_result_t *result);
65 void stonith__xe_get_result(const xmlNode *xml, pcmk__action_result_t *result);
66 xmlNode *stonith__find_xe_with_result(xmlNode *xml);
67 
69  void (*done) (int pid,
71  void *user_data),
72  void (*fork_cb) (int pid, void *user_data));
73 
74 int stonith__metadata_async(const char *agent, int timeout_sec,
75  void (*callback)(int pid,
77  void *user_data),
78  void *user_data);
79 
80 xmlNode *create_level_registration_xml(const char *node, const char *pattern,
81  const char *attr, const char *value,
82  int level,
83  const stonith_key_value_t *device_list);
84 
85 xmlNode *create_device_registration_xml(const char *id,
86  enum stonith_namespace namespace,
87  const char *agent,
88  const stonith_key_value_t *params,
89  const char *rsc_provides);
90 
92 
93 GList *stonith__parse_targets(const char *hosts);
94 
95 const char *stonith__later_succeeded(const stonith_history_t *event,
96  const stonith_history_t *top_history);
98 
99 void stonith__device_parameter_flags(uint32_t *device_flags,
100  const char *device_name,
101  xmlNode *metadata);
102 
103 # define ST_LEVEL_MAX 10
104 
105 # define F_STONITH_CLIENTID "st_clientid"
106 # define F_STONITH_CALLOPTS "st_callopt"
107 # define F_STONITH_CALLID "st_callid"
108 # define F_STONITH_CALLDATA "st_calldata"
109 # define F_STONITH_OPERATION "st_op"
110 # define F_STONITH_TARGET "st_target"
111 # define F_STONITH_REMOTE_OP_ID "st_remote_op"
112 # define F_STONITH_REMOTE_OP_ID_RELAY "st_remote_op_relay"
113 # define F_STONITH_RC "st_rc"
114 # define F_STONITH_OUTPUT "st_output"
115 
116 # define F_STONITH_TIMEOUT "st_timeout"
117 # define F_STONITH_TOLERANCE "st_tolerance"
118 # define F_STONITH_DELAY "st_delay"
119 
120 # define F_STONITH_ACTION_TIMEOUT "st_action_timeout"
121 
122 # define F_STONITH_ACTION_DISALLOWED "st_action_disallowed"
123 
124 # define F_STONITH_DELAY_MAX "st_delay_max"
125 
126 # define F_STONITH_DELAY_BASE "st_delay_base"
127 
129 # define F_STONITH_DEVICE_VERIFIED "st_monitor_verified"
130 
131 # define F_STONITH_DEVICE_REQUIRED "st_required"
132 
133 # define F_STONITH_AVAILABLE_DEVICES "st-available-devices"
134 # define F_STONITH_CALLBACK_TOKEN "st_async_id"
135 # define F_STONITH_CLIENTNAME "st_clientname"
136 # define F_STONITH_CLIENTNODE "st_clientnode"
137 # define F_STONITH_NOTIFY_ACTIVATE "st_notify_activate"
138 # define F_STONITH_NOTIFY_DEACTIVATE "st_notify_deactivate"
139 # define F_STONITH_DELEGATE "st_delegate"
140 # define F_STONITH_DEVICE_SUPPORT_FLAGS "st_device_support_flags"
141 
145 # define F_STONITH_ORIGIN "st_origin"
146 # define F_STONITH_HISTORY_LIST "st_history"
147 # define F_STONITH_DATE "st_date"
148 # define F_STONITH_DATE_NSEC "st_date_nsec"
149 # define F_STONITH_STATE "st_state"
150 # define F_STONITH_ACTIVE "st_active"
151 # define F_STONITH_DIFFERENTIAL "st_differential"
152 
153 # define F_STONITH_DEVICE "st_device_id"
154 # define F_STONITH_ACTION "st_device_action"
155 # define F_STONITH_MERGED "st_op_merged"
156 
157 # define T_STONITH_NG "stonith-ng"
158 # define T_STONITH_REPLY "st-reply"
159 
162 # define T_STONITH_TIMEOUT_VALUE "st-async-timeout-value"
163 # define T_STONITH_NOTIFY "st_notify"
164 
165 # define STONITH_ATTR_ACTION_OP "action"
166 
167 # define STONITH_OP_EXEC "st_execute"
168 # define STONITH_OP_TIMEOUT_UPDATE "st_timeout_update"
169 # define STONITH_OP_QUERY "st_query"
170 # define STONITH_OP_FENCE "st_fence"
171 # define STONITH_OP_RELAY "st_relay"
172 # define STONITH_OP_DEVICE_ADD "st_device_register"
173 # define STONITH_OP_DEVICE_DEL "st_device_remove"
174 # define STONITH_OP_FENCE_HISTORY "st_fence_history"
175 # define STONITH_OP_LEVEL_ADD "st_level_add"
176 # define STONITH_OP_LEVEL_DEL "st_level_remove"
177 
178 # define STONITH_WATCHDOG_AGENT "fence_watchdog"
179 /* Don't change 2 below as it would break rolling upgrade */
180 # define STONITH_WATCHDOG_AGENT_INTERNAL "#watchdog"
181 # define STONITH_WATCHDOG_ID "watchdog"
182 
184  bool (*matching_fn)(stonith_history_t *, void *),
185  void *user_data);
186 bool stonith__event_state_pending(stonith_history_t *history, void *user_data);
187 bool stonith__event_state_eq(stonith_history_t *history, void *user_data);
188 bool stonith__event_state_neq(stonith_history_t *history, void *user_data);
189 
190 int stonith__legacy2status(int rc);
191 
195 
198 const char *stonith__event_exit_reason(const stonith_event_t *event);
199 char *stonith__event_description(const stonith_event_t *event);
201  bool full_history,
202  const char *later_succeeded,
203  uint32_t show_opts);
204 
213 static inline bool
214 stonith__op_state_pending(enum op_state state)
215 {
216  return state != st_failed && state != st_done;
217 }
218 
219 gboolean stonith__watchdog_fencing_enabled_for_node(const char *node);
220 gboolean stonith__watchdog_fencing_enabled_for_node_api(stonith_t *st, const char *node);
221 
222 #endif
void stonith__destroy_action(stonith_action_t *action)
Definition: st_actions.c:217
struct stonith_action_s stonith_action_t
Definition: internal.h:51
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:2368
char data[0]
Definition: cpg.c:55
int stonith__legacy2status(int rc)
Definition: st_actions.c:404
void stonith__register_messages(pcmk__output_t *out)
Definition: st_output.c:598
int stonith__event_execution_status(const stonith_event_t *event)
Definition: st_client.c:2602
stonith_history_t * stonith__sort_history(stonith_history_t *history)
Definition: st_client.c:2301
int stonith__result2rc(const pcmk__action_result_t *result)
Definition: st_actions.c:330
int stonith__exit_status(const stonith_callback_data_t *data)
Definition: st_client.c:2531
int stonith__execution_status(const stonith_callback_data_t *data)
Definition: st_client.c:2548
xmlNode * create_device_registration_xml(const char *id, enum stonith_namespace namespace, const char *agent, const stonith_key_value_t *params, const char *rsc_provides)
Definition: st_client.c:293
stonith_namespace
Definition: stonith-ng.h:81
gboolean stonith__watchdog_fencing_enabled_for_node_api(stonith_t *st, const char *node)
Definition: st_client.c:172
const char * stonith__event_exit_reason(const stonith_event_t *event)
Definition: st_client.c:2622
const char * action
Definition: pcmk_fence.c:30
bool stonith__event_state_pending(stonith_history_t *history, void *user_data)
Definition: st_client.c:2382
GList * stonith__parse_targets(const char *hosts)
Definition: st_client.c:2217
st_device_flags
Definition: internal.h:19
Formatted output for pacemaker tools.
stonith_t * st
Definition: pcmk_fence.c:28
uint32_t pid
Definition: cpg.c:46
char * stonith__event_description(const stonith_event_t *event)
Definition: st_client.c:2644
void stonith__device_parameter_flags(uint32_t *device_flags, const char *device_name, xmlNode *metadata)
Definition: st_client.c:2400
const char * stonith__later_succeeded(const stonith_history_t *event, const stonith_history_t *top_history)
Definition: st_client.c:2261
pcmk__action_result_t * stonith__action_result(stonith_action_t *action)
Definition: st_actions.c:242
op_state
Definition: stonith-ng.h:71
Wrappers for and extensions to libxml2.
void stonith__xe_get_result(const xmlNode *xml, pcmk__action_result_t *result)
Definition: st_actions.c:494
xmlNode * create_level_registration_xml(const char *node, const char *pattern, const char *attr, const char *value, int level, const stonith_key_value_t *device_list)
Definition: st_client.c:415
gchar * stonith__history_description(const stonith_history_t *event, bool full_history, const char *later_succeeded, uint32_t show_opts)
Definition: st_output.c:90
void stonith__xe_set_result(xmlNode *xml, const pcmk__action_result_t *result)
Definition: st_actions.c:434
const char * target
Definition: pcmk_fence.c:29
pcmk__action_result_t result
Definition: pcmk_fence.c:35
gboolean stonith__watchdog_fencing_enabled_for_node(const char *node)
Definition: st_client.c:231
xmlNode * stonith__find_xe_with_result(xmlNode *xml)
Definition: st_actions.c:473
Fencing aka. STONITH.
This structure contains everything that makes up a single output formatter.
stonith_action_t * stonith__action_create(const char *agent, const char *action_name, const char *target, uint32_t target_nodeid, int timeout_sec, GHashTable *device_args, GHashTable *port_map, const char *host_arg)
Definition: st_actions.c:265
IPC interface to Pacemaker daemons.
const char * stonith__exit_reason(const stonith_callback_data_t *data)
Definition: st_client.c:2565
bool stonith__event_state_eq(stonith_history_t *history, void *user_data)
Definition: st_client.c:2388
int stonith__execute_async(stonith_action_t *action, void *userdata, void(*done)(int pid, const pcmk__action_result_t *result, void *user_data), void(*fork_cb)(int pid, void *user_data))
Definition: st_actions.c:671
int stonith__event_exit_status(const stonith_event_t *event)
Definition: st_client.c:2582
int stonith__metadata_async(const char *agent, int timeout_sec, void(*callback)(int pid, const pcmk__action_result_t *result, void *user_data), void *user_data)
Definition: st_client.c:2461
bool stonith__event_state_neq(stonith_history_t *history, void *user_data)
Definition: st_client.c:2394