1
2
3
4
5
6
7
8 #include <stdint.h>
9 #include <crm/common/mainloop.h>
10
11
12
13
14
15
16
17
18
19
20
21 gboolean stonith_check_fence_tolerance(int tolerance, const char *target, const char *action);
22
23 typedef struct stonith_device_s {
24 char *id;
25 char *agent;
26 char *namespace;
27
28
29 char *on_target_actions;
30 GList *targets;
31 time_t targets_age;
32 gboolean has_attr_map;
33
34 gboolean include_nodeid;
35
36 gboolean automatic_unfencing;
37 guint priority;
38
39 uint32_t flags;
40
41 GHashTable *params;
42 GHashTable *aliases;
43 GList *pending_ops;
44 mainloop_timer_t *timer;
45 crm_trigger_t *work;
46 xmlNode *agent_metadata;
47
48
49
50 gboolean verified;
51
52 gboolean cib_registered;
53 gboolean api_registered;
54 gboolean dirty;
55 } stonith_device_t;
56
57
58
59
60
61
62 enum st_remap_phase {
63 st_phase_requested = 0,
64 st_phase_off = 1,
65 st_phase_on = 2,
66 st_phase_max = 3
67 };
68
69
70
71
72 enum st_replay_option {
73 st_reply_opt_none = 0x00000000,
74 st_reply_opt_merged = 0x00000001,
75 };
76
77 typedef struct remote_fencing_op_s {
78
79 char *id;
80
81 char *target;
82
83 char *action;
84
85
86 time_t created;
87
88
89 gboolean notify_sent;
90
91 guint replies;
92
93 guint replies_expected;
94
95 gboolean owner;
96
97 guint op_timer_total;
98
99
100 guint op_timer_one;
101
102
103 guint query_timer;
104
105
106 gint base_timeout;
107
108
109
110 gint total_timeout;
111
112
113
114 int delay;
115
116
117
118
119
120 char *delegate;
121
122 time_t completed;
123
124 uint32_t call_options;
125
126
127
128 enum op_state state;
129
130 char *originator;
131
132 char *client_id;
133
134 int client_callid;
135
136 char *client_name;
137
138 GList *query_results;
139
140 xmlNode *request;
141
142
143 guint level;
144
145 enum st_remap_phase phase;
146
147
148 GList *automatic_list;
149
150 GList *devices_list;
151
152 GList *devices;
153
154
155
156 GList *duplicates;
157
158 } remote_fencing_op_t;
159
160
161
162
163
164
165
166 void stonith_bcast_result_to_peers(remote_fencing_op_t * op, int rc, gboolean op_merged);
167
168
169 enum st_client_flags {
170 st_callback_unknown = UINT64_C(0),
171 st_callback_notify_fence = (UINT64_C(1) << 0),
172 st_callback_device_add = (UINT64_C(1) << 2),
173 st_callback_device_del = (UINT64_C(1) << 4),
174 st_callback_notify_history = (UINT64_C(1) << 5),
175 st_callback_notify_history_synced = (UINT64_C(1) << 6)
176 };
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192 typedef struct stonith_topology_s {
193 int kind;
194
195
196 char *target;
197 char *target_value;
198 char *target_pattern;
199 char *target_attribute;
200
201
202 GList *levels[ST_LEVEL_MAX];
203
204 } stonith_topology_t;
205
206 void init_device_list(void);
207 void free_device_list(void);
208 void init_topology_list(void);
209 void free_topology_list(void);
210 void free_stonith_remote_op_list(void);
211 void init_stonith_remote_op_hash_table(GHashTable **table);
212 void free_metadata_cache(void);
213
214 uint64_t get_stonith_flag(const char *name);
215
216 void stonith_command(pcmk__client_t *client, uint32_t id, uint32_t flags,
217 xmlNode *op_request, const char *remote_peer);
218
219 int stonith_device_register(xmlNode * msg, const char **desc, gboolean from_cib);
220
221 int stonith_device_remove(const char *id, gboolean from_cib);
222
223 char *stonith_level_key(xmlNode * msg, int mode);
224 int stonith_level_kind(xmlNode * msg);
225 int stonith_level_register(xmlNode * msg, char **desc);
226
227 int stonith_level_remove(xmlNode * msg, char **desc);
228
229 stonith_topology_t *find_topology_for_host(const char *host);
230
231 void do_local_reply(xmlNode * notify_src, const char *client_id, gboolean sync_reply,
232 gboolean from_peer);
233
234 xmlNode *stonith_construct_reply(xmlNode * request, const char *output, xmlNode * data,
235 int rc);
236
237 void
238 do_stonith_async_timeout_update(const char *client, const char *call_id, int timeout);
239
240 void do_stonith_notify(int options, const char *type, int result, xmlNode * data);
241 void do_stonith_notify_device(int options, const char *op, int rc, const char *desc);
242 void do_stonith_notify_level(int options, const char *op, int rc, const char *desc);
243
244 remote_fencing_op_t *initiate_remote_stonith_op(pcmk__client_t *client,
245 xmlNode *request,
246 gboolean manual_ack);
247
248 int process_remote_stonith_exec(xmlNode * msg);
249
250 int process_remote_stonith_query(xmlNode * msg);
251
252 void *create_remote_stonith_op(const char *client, xmlNode * request, gboolean peer);
253
254 int stonith_fence_history(xmlNode *msg, xmlNode **output,
255 const char *remote_peer, int options);
256
257 void stonith_fence_history_trim(void);
258
259 bool fencing_peer_active(crm_node_t *peer);
260
261 int stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op);
262
263 gboolean string_in_list(GList *list, const char *item);
264
265 gboolean node_has_attr(const char *node, const char *name, const char *value);
266
267 extern char *stonith_our_uname;
268 extern gboolean stand_alone;
269 extern GHashTable *device_list;
270 extern GHashTable *topology;
271 extern long stonith_watchdog_timeout_ms;
272
273 extern GHashTable *stonith_remote_op_list;