This source file includes following definitions.
- lrmd_event_type2str
1
2
3
4
5
6
7
8
9
10 #ifndef LRMD__H
11 # define LRMD__H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17
18
19
20
21
22 #include <stdbool.h>
23 #include <glib.h>
24 #include <crm_config.h>
25 #include <crm/services.h>
26
27 typedef struct lrmd_s lrmd_t;
28 typedef struct lrmd_key_value_s {
29 char *key;
30 char *value;
31 struct lrmd_key_value_s *next;
32 } lrmd_key_value_t;
33
34
35
36
37 #define LRMD_PROTOCOL_VERSION "1.1"
38
39
40
41
42
43
44
45 #define LRMD_MIN_PROTOCOL_VERSION "1.0"
46
47
48 #define DEFAULT_REMOTE_KEY_LOCATION PACEMAKER_CONFIG_DIR "/authkey"
49 #define ALT_REMOTE_KEY_LOCATION "/etc/corosync/authkey"
50 #define DEFAULT_REMOTE_PORT 3121
51 #define DEFAULT_REMOTE_USERNAME "lrmd"
52
53 #define F_LRMD_OPERATION "lrmd_op"
54 #define F_LRMD_CLIENTNAME "lrmd_clientname"
55 #define F_LRMD_IS_IPC_PROVIDER "lrmd_is_ipc_provider"
56 #define F_LRMD_CLIENTID "lrmd_clientid"
57 #define F_LRMD_PROTOCOL_VERSION "lrmd_protocol_version"
58 #define F_LRMD_REMOTE_MSG_TYPE "lrmd_remote_msg_type"
59 #define F_LRMD_REMOTE_MSG_ID "lrmd_remote_msg_id"
60 #define F_LRMD_CALLBACK_TOKEN "lrmd_async_id"
61 #define F_LRMD_CALLID "lrmd_callid"
62 #define F_LRMD_CALLOPTS "lrmd_callopt"
63 #define F_LRMD_CALLDATA "lrmd_calldata"
64 #define F_LRMD_RC "lrmd_rc"
65 #define F_LRMD_EXEC_RC "lrmd_exec_rc"
66 #define F_LRMD_OP_STATUS "lrmd_exec_op_status"
67 #define F_LRMD_TIMEOUT "lrmd_timeout"
68 #define F_LRMD_WATCHDOG "lrmd_watchdog"
69 #define F_LRMD_CLASS "lrmd_class"
70 #define F_LRMD_PROVIDER "lrmd_provider"
71 #define F_LRMD_TYPE "lrmd_type"
72 #define F_LRMD_ORIGIN "lrmd_origin"
73
74 #define F_LRMD_RSC_RUN_TIME "lrmd_run_time"
75 #define F_LRMD_RSC_RCCHANGE_TIME "lrmd_rcchange_time"
76 #define F_LRMD_RSC_EXEC_TIME "lrmd_exec_time"
77 #define F_LRMD_RSC_QUEUE_TIME "lrmd_queue_time"
78
79 #define F_LRMD_RSC_ID "lrmd_rsc_id"
80 #define F_LRMD_RSC_ACTION "lrmd_rsc_action"
81 #define F_LRMD_RSC_USERDATA_STR "lrmd_rsc_userdata_str"
82 #define F_LRMD_RSC_OUTPUT "lrmd_rsc_output"
83 #define F_LRMD_RSC_EXIT_REASON "lrmd_rsc_exit_reason"
84 #define F_LRMD_RSC_START_DELAY "lrmd_rsc_start_delay"
85 #define F_LRMD_RSC_INTERVAL "lrmd_rsc_interval"
86 #define F_LRMD_RSC_DELETED "lrmd_rsc_deleted"
87 #define F_LRMD_RSC "lrmd_rsc"
88
89 #define F_LRMD_ALERT_ID "lrmd_alert_id"
90 #define F_LRMD_ALERT_PATH "lrmd_alert_path"
91 #define F_LRMD_ALERT "lrmd_alert"
92
93 #define LRMD_OP_RSC_REG "lrmd_rsc_register"
94 #define LRMD_OP_RSC_EXEC "lrmd_rsc_exec"
95 #define LRMD_OP_RSC_CANCEL "lrmd_rsc_cancel"
96 #define LRMD_OP_RSC_UNREG "lrmd_rsc_unregister"
97 #define LRMD_OP_RSC_INFO "lrmd_rsc_info"
98 #define LRMD_OP_RSC_METADATA "lrmd_rsc_metadata"
99 #define LRMD_OP_POKE "lrmd_rsc_poke"
100 #define LRMD_OP_NEW_CLIENT "lrmd_rsc_new_client"
101 #define LRMD_OP_CHECK "lrmd_check"
102 #define LRMD_OP_ALERT_EXEC "lrmd_alert_exec"
103 #define LRMD_OP_GET_RECURRING "lrmd_get_recurring"
104
105 #define LRMD_IPC_OP_NEW "new"
106 #define LRMD_IPC_OP_DESTROY "destroy"
107 #define LRMD_IPC_OP_EVENT "event"
108 #define LRMD_IPC_OP_REQUEST "request"
109 #define LRMD_IPC_OP_RESPONSE "response"
110 #define LRMD_IPC_OP_SHUTDOWN_REQ "shutdown_req"
111 #define LRMD_IPC_OP_SHUTDOWN_ACK "shutdown_ack"
112 #define LRMD_IPC_OP_SHUTDOWN_NACK "shutdown_nack"
113
114 #define F_LRMD_IPC_OP "lrmd_ipc_op"
115 #define F_LRMD_IPC_IPC_SERVER "lrmd_ipc_server"
116 #define F_LRMD_IPC_SESSION "lrmd_ipc_session"
117 #define F_LRMD_IPC_CLIENT "lrmd_ipc_client"
118 #define F_LRMD_IPC_USER "lrmd_ipc_user"
119 #define F_LRMD_IPC_MSG "lrmd_ipc_msg"
120 #define F_LRMD_IPC_MSG_ID "lrmd_ipc_msg_id"
121 #define F_LRMD_IPC_MSG_FLAGS "lrmd_ipc_msg_flags"
122
123 #define T_LRMD "lrmd"
124 #define T_LRMD_REPLY "lrmd_reply"
125 #define T_LRMD_NOTIFY "lrmd_notify"
126 #define T_LRMD_IPC_PROXY "lrmd_ipc_proxy"
127 #define T_LRMD_RSC_OP "lrmd_rsc_op"
128
129
130
131
132
133 lrmd_t *lrmd_api_new(void);
134
135
136
137
138
139
140
141
142
143
144 lrmd_t *lrmd_remote_api_new(const char *nodename, const char *server, int port);
145
146
147
148
149
150
151
152
153 bool lrmd_dispatch(lrmd_t * lrmd);
154
155
156
157
158
159
160
161
162 int lrmd_poll(lrmd_t * lrmd, int timeout);
163
164
165
166
167 void lrmd_api_delete(lrmd_t * lrmd);
168 lrmd_key_value_t *lrmd_key_value_add(lrmd_key_value_t * kvp, const char *key, const char *value);
169
170
171
172 enum lrmd_call_options {
173 lrmd_opt_none = 0x00000000,
174
175
176 lrmd_opt_notify_orig_only = 0x00000002,
177
178
179
180
181 lrmd_opt_drop_recurring = 0x00000003,
182
183 lrmd_opt_notify_changes_only = 0x00000004,
184 };
185
186 enum lrmd_callback_event {
187 lrmd_event_register,
188 lrmd_event_unregister,
189 lrmd_event_exec_complete,
190 lrmd_event_disconnect,
191 lrmd_event_connect,
192 lrmd_event_poke,
193 lrmd_event_new_client,
194 };
195
196
197
198 typedef struct lrmd_event_data_s {
199
200 enum lrmd_callback_event type;
201
202
203 const char *rsc_id;
204
205 const char *op_type;
206
207 const char *user_data;
208
209
210 int call_id;
211
212 int timeout;
213
214 guint interval_ms;
215
216 int start_delay;
217
218 int rsc_deleted;
219
220
221 enum ocf_exitcode rc;
222
223 int op_status;
224
225 const char *output;
226
227 unsigned int t_run;
228
229 unsigned int t_rcchange;
230
231 unsigned int exec_time;
232
233 unsigned int queue_time;
234
235
236 int connection_rc;
237
238
239
240 void *params;
241
242
243
244
245 const char *remote_nodename;
246
247
248 const char *exit_reason;
249 } lrmd_event_data_t;
250
251 lrmd_event_data_t *lrmd_new_event(const char *rsc_id, const char *task,
252 guint interval_ms);
253 lrmd_event_data_t *lrmd_copy_event(lrmd_event_data_t * event);
254 void lrmd_free_event(lrmd_event_data_t * event);
255
256 typedef struct lrmd_rsc_info_s {
257 char *id;
258 char *type;
259 char *standard;
260 char *provider;
261 } lrmd_rsc_info_t;
262
263 typedef struct lrmd_op_info_s {
264 char *rsc_id;
265 char *action;
266 char *interval_ms_s;
267 char *timeout_ms_s;
268 } lrmd_op_info_t;
269
270 lrmd_rsc_info_t *lrmd_new_rsc_info(const char *rsc_id, const char *standard,
271 const char *provider, const char *type);
272 lrmd_rsc_info_t *lrmd_copy_rsc_info(lrmd_rsc_info_t * rsc_info);
273 void lrmd_free_rsc_info(lrmd_rsc_info_t * rsc_info);
274 void lrmd_free_op_info(lrmd_op_info_t *op_info);
275
276 typedef void (*lrmd_event_callback) (lrmd_event_data_t * event);
277
278 typedef struct lrmd_list_s {
279 const char *val;
280 struct lrmd_list_s *next;
281 } lrmd_list_t;
282
283 void lrmd_list_freeall(lrmd_list_t * head);
284 void lrmd_key_value_freeall(lrmd_key_value_t * head);
285
286 typedef struct lrmd_api_operations_s {
287
288
289
290
291
292 int (*connect) (lrmd_t * lrmd, const char *client_name, int *fd);
293
294
295
296
297
298
299
300
301 int (*connect_async) (lrmd_t * lrmd, const char *client_name, int timeout );
302
303
304
305
306
307
308
309 int (*is_connected) (lrmd_t * lrmd);
310
311
312
313
314
315
316
317
318 int (*poke_connection) (lrmd_t * lrmd);
319
320
321
322
323
324
325 int (*disconnect) (lrmd_t * lrmd);
326
327
328
329
330
331
332
333
334 int (*register_rsc) (lrmd_t * lrmd,
335 const char *rsc_id,
336 const char *standard,
337 const char *provider, const char *agent, enum lrmd_call_options options);
338
339
340
341
342
343
344
345 lrmd_rsc_info_t *(*get_rsc_info) (lrmd_t * lrmd,
346 const char *rsc_id, enum lrmd_call_options options);
347
348
349
350
351
352
353 int (*get_recurring_ops) (lrmd_t *lrmd, const char *rsc_id, int timeout_ms,
354 enum lrmd_call_options options, GList **output);
355
356
357
358
359
360
361
362
363
364
365
366
367
368 int (*unregister_rsc) (lrmd_t * lrmd, const char *rsc_id, enum lrmd_call_options options);
369
370
371
372
373 void (*set_callback) (lrmd_t * lrmd, lrmd_event_callback callback);
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388 int (*exec) (lrmd_t * lrmd, const char *rsc_id, const char *action, const char *userdata,
389 guint interval_ms,
390 int timeout,
391 int start_delay,
392 enum lrmd_call_options options, lrmd_key_value_t * params);
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407 int (*cancel) (lrmd_t *lrmd, const char *rsc_id, const char *action,
408 guint interval_ms);
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432 int (*get_metadata) (lrmd_t * lrmd,
433 const char *standard,
434 const char *provider,
435 const char *agent, char **output, enum lrmd_call_options options);
436
437
438
439
440
441
442
443
444
445
446 int (*list_agents) (lrmd_t * lrmd, lrmd_list_t ** agents,
447 const char *standard, const char *provider);
448
449
450
451
452
453
454
455
456
457
458
459 int (*list_ocf_providers) (lrmd_t * lrmd, const char *agent, lrmd_list_t ** providers);
460
461
462
463
464
465
466
467
468
469 int (*list_standards) (lrmd_t * lrmd, lrmd_list_t ** standards);
470
471
472
473
474
475
476
477
478
479
480
481
482 int (*exec_alert) (lrmd_t *lrmd, const char *alert_id,
483 const char *alert_path, int timeout,
484 lrmd_key_value_t *params);
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503 int (*get_metadata_params) (lrmd_t *lrmd, const char *standard,
504 const char *provider, const char *agent,
505 char **output, enum lrmd_call_options options,
506 lrmd_key_value_t *params);
507
508 } lrmd_api_operations_t;
509
510 struct lrmd_s {
511 lrmd_api_operations_t *cmds;
512 void *lrmd_private;
513 };
514
515 static inline const char *
516 lrmd_event_type2str(enum lrmd_callback_event type)
517 {
518 switch (type) {
519 case lrmd_event_register:
520 return "register";
521 case lrmd_event_unregister:
522 return "unregister";
523 case lrmd_event_exec_complete:
524 return "exec_complete";
525 case lrmd_event_disconnect:
526 return "disconnect";
527 case lrmd_event_connect:
528 return "connect";
529 case lrmd_event_poke:
530 return "poke";
531 case lrmd_event_new_client:
532 return "new_client";
533 }
534 return "unknown";
535 }
536
537 #ifdef __cplusplus
538 }
539 #endif
540
541 #endif