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