pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cib_client.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2018 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This source code is licensed under the GNU Lesser General Public License
5  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
6  */
7 
8 #include <crm_internal.h>
9 #include <unistd.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <stdarg.h>
13 #include <string.h>
14 #include <pwd.h>
15 
16 #include <sys/stat.h>
17 #include <sys/types.h>
18 
19 #include <glib.h>
20 
21 #include <crm/crm.h>
22 #include <crm/cib/internal.h>
23 #include <crm/msg_xml.h>
24 #include <crm/common/xml.h>
25 
26 GHashTable *cib_op_callback_table = NULL;
27 
28 int cib_client_set_op_callback(cib_t * cib, void (*callback) (const xmlNode * msg, int call_id,
29  int rc, xmlNode * output));
30 
31 int cib_client_add_notify_callback(cib_t * cib, const char *event,
32  void (*callback) (const char *event, xmlNode * msg));
33 
34 int cib_client_del_notify_callback(cib_t * cib, const char *event,
35  void (*callback) (const char *event, xmlNode * msg));
36 
37 gint ciblib_GCompareFunc(gconstpointer a, gconstpointer b);
38 
39 #define op_common(cib) do { \
40  if(cib == NULL) { \
41  return -EINVAL; \
42  } else if(cib->delegate_fn == NULL) { \
43  return -EPROTONOSUPPORT; \
44  } \
45  } while(0)
46 
47 static int
48 cib_client_noop(cib_t * cib, int call_options)
49 {
50  op_common(cib);
51  return cib_internal_op(cib, CRM_OP_NOOP, NULL, NULL, NULL, NULL, call_options, NULL);
52 }
53 
54 static int
55 cib_client_ping(cib_t * cib, xmlNode ** output_data, int call_options)
56 {
57  op_common(cib);
58  return cib_internal_op(cib, CRM_OP_PING, NULL, NULL, NULL, output_data, call_options, NULL);
59 }
60 
61 static int
62 cib_client_query(cib_t * cib, const char *section, xmlNode ** output_data, int call_options)
63 {
64  return cib->cmds->query_from(cib, NULL, section, output_data, call_options);
65 }
66 
67 static int
68 cib_client_query_from(cib_t * cib, const char *host, const char *section,
69  xmlNode ** output_data, int call_options)
70 {
71  op_common(cib);
72  return cib_internal_op(cib, CIB_OP_QUERY, host, section, NULL, output_data, call_options, NULL);
73 }
74 
75 static int
76 cib_client_is_master(cib_t * cib)
77 {
78  op_common(cib);
79  return cib_internal_op(cib, CIB_OP_ISMASTER, NULL, NULL, NULL, NULL,
81 }
82 
83 static int
84 cib_client_set_slave(cib_t * cib, int call_options)
85 {
86  op_common(cib);
87  return cib_internal_op(cib, CIB_OP_SLAVE, NULL, NULL, NULL, NULL, call_options, NULL);
88 }
89 
90 static int
91 cib_client_set_slave_all(cib_t * cib, int call_options)
92 {
93  return -EPROTONOSUPPORT;
94 }
95 
96 static int
97 cib_client_set_master(cib_t * cib, int call_options)
98 {
99  op_common(cib);
100  crm_trace("Adding cib_scope_local to options");
101  return cib_internal_op(cib, CIB_OP_MASTER, NULL, NULL, NULL, NULL,
102  call_options | cib_scope_local, NULL);
103 }
104 
105 static int
106 cib_client_bump_epoch(cib_t * cib, int call_options)
107 {
108  op_common(cib);
109  return cib_internal_op(cib, CIB_OP_BUMP, NULL, NULL, NULL, NULL, call_options, NULL);
110 }
111 
112 static int
113 cib_client_upgrade(cib_t * cib, int call_options)
114 {
115  op_common(cib);
116  return cib_internal_op(cib, CIB_OP_UPGRADE, NULL, NULL, NULL, NULL, call_options, NULL);
117 }
118 
119 static int
120 cib_client_sync(cib_t * cib, const char *section, int call_options)
121 {
122  return cib->cmds->sync_from(cib, NULL, section, call_options);
123 }
124 
125 static int
126 cib_client_sync_from(cib_t * cib, const char *host, const char *section, int call_options)
127 {
128  op_common(cib);
129  return cib_internal_op(cib, CIB_OP_SYNC, host, section, NULL, NULL, call_options, NULL);
130 }
131 
132 static int
133 cib_client_create(cib_t * cib, const char *section, xmlNode * data, int call_options)
134 {
135  op_common(cib);
136  return cib_internal_op(cib, CIB_OP_CREATE, NULL, section, data, NULL, call_options, NULL);
137 }
138 
139 static int
140 cib_client_modify(cib_t * cib, const char *section, xmlNode * data, int call_options)
141 {
142  op_common(cib);
143  return cib_internal_op(cib, CIB_OP_MODIFY, NULL, section, data, NULL, call_options, NULL);
144 }
145 
146 static int
147 cib_client_update(cib_t * cib, const char *section, xmlNode * data, int call_options)
148 {
149  op_common(cib);
150  return cib_internal_op(cib, CIB_OP_MODIFY, NULL, section, data, NULL, call_options, NULL);
151 }
152 
153 static int
154 cib_client_replace(cib_t * cib, const char *section, xmlNode * data, int call_options)
155 {
156  op_common(cib);
157  return cib_internal_op(cib, CIB_OP_REPLACE, NULL, section, data, NULL, call_options, NULL);
158 }
159 
160 static int
161 cib_client_delete(cib_t * cib, const char *section, xmlNode * data, int call_options)
162 {
163  op_common(cib);
164  return cib_internal_op(cib, CIB_OP_DELETE, NULL, section, data, NULL, call_options, NULL);
165 }
166 
167 static int
168 cib_client_delete_absolute(cib_t * cib, const char *section, xmlNode * data, int call_options)
169 {
170  op_common(cib);
171  return cib_internal_op(cib, CIB_OP_DELETE_ALT, NULL, section, data, NULL, call_options, NULL);
172 }
173 
174 static int
175 cib_client_erase(cib_t * cib, xmlNode ** output_data, int call_options)
176 {
177  op_common(cib);
178  return cib_internal_op(cib, CIB_OP_ERASE, NULL, NULL, NULL, output_data, call_options, NULL);
179 }
180 
181 static void
182 cib_destroy_op_callback(gpointer data)
183 {
184  cib_callback_client_t *blob = data;
185 
186  if (blob->timer && blob->timer->ref > 0) {
187  g_source_remove(blob->timer->ref);
188  }
189  free(blob->timer);
190 
191  if (blob->user_data && blob->free_func) {
192  blob->free_func(blob->user_data);
193  }
194 
195  free(blob);
196 }
197 
198 static void
199 destroy_op_callback_table()
200 {
201  if (cib_op_callback_table != NULL) {
202  g_hash_table_destroy(cib_op_callback_table);
203  cib_op_callback_table = NULL;
204  }
205 }
206 
207 char *
208 get_shadow_file(const char *suffix)
209 {
210  char *cib_home = NULL;
211  char *fullname = NULL;
212  char *name = crm_concat("shadow", suffix, '.');
213  const char *dir = getenv("CIB_shadow_dir");
214 
215  if (dir == NULL) {
216  uid_t uid = geteuid();
217  struct passwd *pwent = getpwuid(uid);
218  const char *user = NULL;
219 
220  if (pwent) {
221  user = pwent->pw_name;
222  } else {
223  user = getenv("USER");
224  crm_perror(LOG_ERR,
225  "Assuming %s because cannot get user details for user ID %d",
226  (user? user : "unprivileged user"), uid);
227  }
228 
229  if (safe_str_eq(user, "root") || safe_str_eq(user, CRM_DAEMON_USER)) {
230  dir = CRM_CONFIG_DIR;
231 
232  } else {
233  const char *home = NULL;
234 
235  if ((home = getenv("HOME")) == NULL) {
236  if (pwent) {
237  home = pwent->pw_dir;
238  }
239  }
240 
241  dir = crm_get_tmpdir();
242  if (home && home[0] == '/') {
243  int rc = 0;
244 
245  cib_home = crm_concat(home, ".cib", '/');
246 
247  rc = mkdir(cib_home, 0700);
248  if (rc < 0 && errno != EEXIST) {
249  crm_perror(LOG_ERR, "Couldn't create user-specific shadow directory: %s",
250  cib_home);
251  errno = 0;
252 
253  } else {
254  dir = cib_home;
255  }
256  }
257  }
258  }
259 
260  fullname = crm_concat(dir, name, '/');
261  free(cib_home);
262  free(name);
263 
264  return fullname;
265 }
266 
267 cib_t *
268 cib_shadow_new(const char *shadow)
269 {
270  cib_t *new_cib = NULL;
271  char *shadow_file = NULL;
272 
273  CRM_CHECK(shadow != NULL, return NULL);
274 
275  shadow_file = get_shadow_file(shadow);
276  new_cib = cib_file_new(shadow_file);
277  free(shadow_file);
278 
279  return new_cib;
280 }
281 
282 cib_t *
284 {
285  unsetenv("CIB_shadow");
286  return cib_new();
287 }
288 
289 cib_t *
290 cib_new(void)
291 {
292  const char *value = getenv("CIB_shadow");
293 
294  if (value && value[0] != 0) {
295  return cib_shadow_new(value);
296  }
297 
298  value = getenv("CIB_file");
299  if (value) {
300  return cib_file_new(value);
301  }
302 
303  value = getenv("CIB_port");
304  if (value) {
305  gboolean encrypted = TRUE;
306  int port = crm_parse_int(value, NULL);
307  const char *server = getenv("CIB_server");
308  const char *user = getenv("CIB_user");
309  const char *pass = getenv("CIB_passwd");
310 
311  value = getenv("CIB_encrypted");
312  if (value && crm_is_true(value) == FALSE) {
313  crm_info("Disabling TLS");
314  encrypted = FALSE;
315  }
316 
317  if (user == NULL) {
318  user = CRM_DAEMON_USER;
319  crm_info("Defaulting to user: %s", user);
320  }
321 
322  if (server == NULL) {
323  server = "localhost";
324  crm_info("Defaulting to localhost");
325  }
326 
327  return cib_remote_new(server, user, pass, port, encrypted);
328  }
329 
330  return cib_native_new();
331 }
332 
342 cib_t *
344 {
345  cib_t *new_cib = NULL;
346 
347  new_cib = calloc(1, sizeof(cib_t));
348 
349  remove_cib_op_callback(0, TRUE); /* remove all */
350 
351  new_cib->call_id = 1;
352  new_cib->variant = cib_undefined;
353 
354  new_cib->type = cib_no_connection;
355  new_cib->state = cib_disconnected;
356 
357  new_cib->op_callback = NULL;
358  new_cib->variant_opaque = NULL;
359  new_cib->notify_list = NULL;
360 
361  /* the rest will get filled in by the variant constructor */
362  new_cib->cmds = calloc(1, sizeof(cib_api_operations_t));
363 
369 
370  new_cib->cmds->noop = cib_client_noop;
371  new_cib->cmds->ping = cib_client_ping;
372  new_cib->cmds->query = cib_client_query;
373  new_cib->cmds->sync = cib_client_sync;
374 
375  new_cib->cmds->query_from = cib_client_query_from;
376  new_cib->cmds->sync_from = cib_client_sync_from;
377 
378  new_cib->cmds->is_master = cib_client_is_master;
379  new_cib->cmds->set_master = cib_client_set_master;
380  new_cib->cmds->set_slave = cib_client_set_slave;
381  new_cib->cmds->set_slave_all = cib_client_set_slave_all;
382 
383  new_cib->cmds->upgrade = cib_client_upgrade;
384  new_cib->cmds->bump_epoch = cib_client_bump_epoch;
385 
386  new_cib->cmds->create = cib_client_create;
387  new_cib->cmds->modify = cib_client_modify;
388  new_cib->cmds->update = cib_client_update;
389  new_cib->cmds->replace = cib_client_replace;
390  new_cib->cmds->remove = cib_client_delete;
391  new_cib->cmds->erase = cib_client_erase;
392 
393  new_cib->cmds->delete_absolute = cib_client_delete_absolute;
394 
395  return new_cib;
396 }
397 
403 void
405 {
406  if (cib) {
407  GList *list = cib->notify_list;
408 
409  while (list != NULL) {
410  cib_notify_client_t *client = g_list_nth_data(list, 0);
411 
412  list = g_list_remove(list, client);
413  free(client);
414  }
415  cib->notify_list = NULL;
416  }
417  destroy_op_callback_table();
418 }
419 
425 void
427 {
428  cib_free_callbacks(cib);
429  if (cib) {
430  cib->cmds->free(cib);
431  }
432 }
433 
434 int
435 cib_client_set_op_callback(cib_t * cib, void (*callback) (const xmlNode * msg, int call_id,
436  int rc, xmlNode * output))
437 {
438  if (callback == NULL) {
439  crm_info("Un-Setting operation callback");
440 
441  } else {
442  crm_trace("Setting operation callback");
443  }
444  cib->op_callback = callback;
445  return pcmk_ok;
446 }
447 
448 int
449 cib_client_add_notify_callback(cib_t * cib, const char *event,
450  void (*callback) (const char *event, xmlNode * msg))
451 {
452  GList *list_item = NULL;
453  cib_notify_client_t *new_client = NULL;
454 
455  if (cib->variant != cib_native && cib->variant != cib_remote) {
456  return -EPROTONOSUPPORT;
457  }
458 
459  crm_trace("Adding callback for %s events (%d)", event, g_list_length(cib->notify_list));
460 
461  new_client = calloc(1, sizeof(cib_notify_client_t));
462  new_client->event = event;
463  new_client->callback = callback;
464 
465  list_item = g_list_find_custom(cib->notify_list, new_client, ciblib_GCompareFunc);
466 
467  if (list_item != NULL) {
468  crm_warn("Callback already present");
469  free(new_client);
470  return -EINVAL;
471 
472  } else {
473  cib->notify_list = g_list_append(cib->notify_list, new_client);
474 
475  cib->cmds->register_notification(cib, event, 1);
476 
477  crm_trace("Callback added (%d)", g_list_length(cib->notify_list));
478  }
479  return pcmk_ok;
480 }
481 
482 static int
483 get_notify_list_event_count(cib_t * cib, const char *event)
484 {
485  GList *l = NULL;
486  int count = 0;
487 
488  for (l = g_list_first(cib->notify_list); l; l = g_list_next(l)) {
489  cib_notify_client_t *client = (cib_notify_client_t *)l->data;
490 
491  if (strcmp(client->event, event) == 0) {
492  count++;
493  }
494  }
495  crm_trace("event(%s) count : %d", event, count);
496  return count;
497 }
498 
499 int
500 cib_client_del_notify_callback(cib_t * cib, const char *event,
501  void (*callback) (const char *event, xmlNode * msg))
502 {
503  GList *list_item = NULL;
504  cib_notify_client_t *new_client = NULL;
505 
506  if (cib->variant != cib_native && cib->variant != cib_remote) {
507  return -EPROTONOSUPPORT;
508  }
509 
510  if (get_notify_list_event_count(cib, event) == 0) {
511  crm_debug("The callback of the event does not exist(%s)", event);
512  return pcmk_ok;
513  }
514 
515  crm_debug("Removing callback for %s events", event);
516 
517  new_client = calloc(1, sizeof(cib_notify_client_t));
518  new_client->event = event;
519  new_client->callback = callback;
520 
521  list_item = g_list_find_custom(cib->notify_list, new_client, ciblib_GCompareFunc);
522 
523  if (list_item != NULL) {
524  cib_notify_client_t *list_client = list_item->data;
525 
526  cib->notify_list = g_list_remove(cib->notify_list, list_client);
527  free(list_client);
528 
529  crm_trace("Removed callback");
530 
531  } else {
532  crm_trace("Callback not present");
533  }
534 
535  if (get_notify_list_event_count(cib, event) == 0) {
536  /* When there is not the registration of the event, the processing turns off a notice. */
537  cib->cmds->register_notification(cib, event, 0);
538  }
539 
540  free(new_client);
541  return pcmk_ok;
542 }
543 
544 gint
545 ciblib_GCompareFunc(gconstpointer a, gconstpointer b)
546 {
547  int rc = 0;
548  const cib_notify_client_t *a_client = a;
549  const cib_notify_client_t *b_client = b;
550 
551  CRM_CHECK(a_client->event != NULL && b_client->event != NULL, return 0);
552  rc = strcmp(a_client->event, b_client->event);
553  if (rc == 0) {
554  if (a_client->callback == b_client->callback) {
555  return 0;
556  } else if (((long)a_client->callback) < ((long)b_client->callback)) {
557  crm_trace("callbacks for %s are not equal: %p < %p",
558  a_client->event, a_client->callback, b_client->callback);
559  return -1;
560  }
561  crm_trace("callbacks for %s are not equal: %p > %p",
562  a_client->event, a_client->callback, b_client->callback);
563  return 1;
564  }
565  return rc;
566 }
567 
568 static gboolean
569 cib_async_timeout_handler(gpointer data)
570 {
571  struct timer_rec_s *timer = data;
572 
573  crm_debug("Async call %d timed out after %ds", timer->call_id, timer->timeout);
574  cib_native_callback(timer->cib, NULL, timer->call_id, -ETIME);
575 
576  /* Always return TRUE, never remove the handler
577  * We do that in remove_cib_op_callback()
578  */
579  return TRUE;
580 }
581 
582 gboolean
583 cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
584  void *user_data, const char *callback_name,
585  void (*callback) (xmlNode *, int, int, xmlNode *, void *))
586 {
587  return cib_client_register_callback_full(cib, call_id, timeout,
588  only_success, user_data,
589  callback_name, callback, NULL);
590 }
591 
592 gboolean
593 cib_client_register_callback_full(cib_t *cib, int call_id, int timeout,
594  gboolean only_success, void *user_data,
595  const char *callback_name,
596  void (*callback)(xmlNode *, int, int,
597  xmlNode *, void *),
598  void (*free_func)(void *))
599 {
600  cib_callback_client_t *blob = NULL;
601 
602  if (call_id < 0) {
603  if (only_success == FALSE) {
604  callback(NULL, call_id, call_id, NULL, user_data);
605  } else {
606  crm_warn("CIB call failed: %s", pcmk_strerror(call_id));
607  }
608  if (user_data && free_func) {
609  free_func(user_data);
610  }
611  return FALSE;
612  }
613 
614  blob = calloc(1, sizeof(cib_callback_client_t));
615  blob->id = callback_name;
616  blob->only_success = only_success;
617  blob->user_data = user_data;
618  blob->callback = callback;
619  blob->free_func = free_func;
620 
621  if (timeout > 0) {
622  struct timer_rec_s *async_timer = NULL;
623 
624  async_timer = calloc(1, sizeof(struct timer_rec_s));
625  blob->timer = async_timer;
626 
627  async_timer->cib = cib;
628  async_timer->call_id = call_id;
629  async_timer->timeout = timeout * 1000;
630  async_timer->ref =
631  g_timeout_add(async_timer->timeout, cib_async_timeout_handler, async_timer);
632  }
633 
634  crm_trace("Adding callback %s for call %d", callback_name, call_id);
635  g_hash_table_insert(cib_op_callback_table, GINT_TO_POINTER(call_id), blob);
636 
637  return TRUE;
638 }
639 
640 void
641 remove_cib_op_callback(int call_id, gboolean all_callbacks)
642 {
643  if (all_callbacks) {
644  destroy_op_callback_table();
645  cib_op_callback_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
646  NULL, cib_destroy_op_callback);
647  } else {
648  g_hash_table_remove(cib_op_callback_table, GINT_TO_POINTER(call_id));
649  }
650 }
651 
652 int
654 {
655  if (cib_op_callback_table == NULL) {
656  return 0;
657  }
658  return g_hash_table_size(cib_op_callback_table);
659 }
660 
661 static void
662 cib_dump_pending_op(gpointer key, gpointer value, gpointer user_data)
663 {
664  int call = GPOINTER_TO_INT(key);
665  cib_callback_client_t *blob = value;
666 
667  crm_debug("Call %d (%s): pending", call, crm_str(blob->id));
668 }
669 
670 void
672 {
673  if (cib_op_callback_table == NULL) {
674  return;
675  }
676  return g_hash_table_foreach(cib_op_callback_table, cib_dump_pending_op, NULL);
677 }
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:103
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:156
const char * crm_get_tmpdir(void)
Definition: io.c:500
#define CIB_OP_CREATE
Definition: internal.h:23
cib_t * cib_shadow_new(const char *name)
Definition: cib_client.c:268
A dumping ground.
const char * pcmk_strerror(int rc)
Definition: results.c:188
#define ETIME
Definition: portability.h:162
cib_t * cib_remote_new(const char *server, const char *user, const char *passwd, int port, gboolean encrypted)
Definition: cib_remote.c:105
int cib_client_add_notify_callback(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib_client.c:449
cib_t * cib_new(void)
Definition: cib_client.c:290
int(* set_slave)(cib_t *cib, int call_options)
Definition: cib.h:109
gboolean(* register_callback_full)(cib_t *cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void(*callback)(xmlNode *, int, int, xmlNode *, void *), void(*free_func)(void *))
Definition: cib.h:135
gboolean cib_client_register_callback_full(cib_t *cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void(*callback)(xmlNode *, int, int, xmlNode *, void *), void(*free_func)(void *))
Definition: cib_client.c:593
int cib_client_del_notify_callback(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib_client.c:500
int(* free)(cib_t *cib)
Definition: cib.h:85
#define CIB_OP_ISMASTER
Definition: internal.h:20
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
Definition: cib_client.c:641
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
Definition: strings.c:110
AIS_Host host
Definition: internal.h:86
int(* noop)(cib_t *cib, int call_options)
Definition: cib.h:100
int(* set_slave_all)(cib_t *cib, int call_options)
Definition: cib.h:110
int(* set_op_callback)(cib_t *cib, void(*callback)(const xmlNode *msg, int callid, int rc, xmlNode *output))
Definition: cib.h:87
#define CRM_OP_NOOP
Definition: crm.h:102
int(* replace)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:121
int call_id
Definition: internal.h:99
gboolean only_success
Definition: internal.h:93
int(* update)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:120
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:85
char * get_shadow_file(const char *name)
Definition: cib_client.c:208
gboolean(* register_callback)(cib_t *cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void(*callback)(xmlNode *, int, int, xmlNode *, void *))
Definition: cib.h:131
void cib_delete(cib_t *cib)
Free all memory used by CIB connection.
Definition: cib_client.c:426
int(* add_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:90
#define CIB_OP_BUMP
Definition: internal.h:21
int(* bump_epoch)(cib_t *cib, int call_options)
Definition: cib.h:116
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:119
cib_t * cib_new_variant(void)
Definition: cib_client.c:343
int timeout
Definition: internal.h:100
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:90
#define crm_warn(fmt, args...)
Definition: logging.h:241
struct timer_rec_s * timer
Definition: internal.h:94
int(* upgrade)(cib_t *cib, int call_options)
Definition: cib.h:115
#define CIB_OP_SYNC
Definition: internal.h:18
cib_api_operations_t * cmds
Definition: cib.h:157
#define crm_debug(fmt, args...)
Definition: logging.h:245
void cib_free_callbacks(cib_t *cib)
Free all callbacks for a CIB connection.
Definition: cib_client.c:404
int(* ping)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:101
void(* op_callback)(const xmlNode *msg, int call_id, int rc, xmlNode *output)
Definition: cib.h:155
#define CIB_OP_QUERY
Definition: internal.h:22
guint ref
Definition: internal.h:101
#define crm_trace(fmt, args...)
Definition: logging.h:246
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
Definition: cib.h:129
int(* delete_absolute)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:125
int(* erase)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:124
Wrappers for and extensions to libxml2.
const char * event
Definition: internal.h:82
#define CRM_DAEMON_USER
Definition: config.h:32
int(* set_master)(cib_t *cib, int call_options)
Definition: cib.h:108
int(* query_from)(cib_t *cib, const char *host, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:104
int(* sync_from)(cib_t *cib, const char *host, const char *section, int call_options)
Definition: cib.h:113
cib_t * cib_native_new(void)
Definition: cib_native.c:56
int num_cib_op_callbacks(void)
Definition: cib_client.c:653
int(* sync)(cib_t *cib, const char *section, int call_options)
Definition: cib.h:112
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:122
#define op_common(cib)
Definition: cib_client.c:39
#define CRM_CONFIG_DIR
Definition: config.h:20
#define CIB_OP_ERASE
Definition: internal.h:26
void * variant_opaque
Definition: cib.h:151
int(* del_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:93
cib_t * cib_file_new(const char *filename)
Definition: cib_file.c:459
int cib_client_set_op_callback(cib_t *cib, void(*callback)(const xmlNode *msg, int call_id, int rc, xmlNode *output))
Definition: cib_client.c:435
GHashTable * cib_op_callback_table
Definition: cib_client.c:26
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:218
Definition: cib.h:36
const char * id
Definition: internal.h:91
#define CIB_OP_DELETE
Definition: internal.h:25
cib_t * cib
Definition: internal.h:102
#define CIB_OP_MODIFY
Definition: internal.h:24
Definition: cib.h:34
char data[0]
Definition: internal.h:92
#define crm_str(x)
Definition: logging.h:266
enum cib_variant variant
Definition: cib.h:147
void(* free_func)(void *)
Definition: internal.h:95
#define CIB_OP_REPLACE
Definition: internal.h:27
cib_t * cib_new_no_shadow(void)
Definition: cib_client.c:283
#define CIB_OP_MASTER
Definition: internal.h:17
#define pcmk_ok
Definition: results.h:57
int(* is_master)(cib_t *cib)
Definition: cib.h:107
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
Definition: cib_utils.c:547
int call_id
Definition: cib.h:149
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:118
#define CIB_OP_SLAVE
Definition: internal.h:15
gboolean crm_is_true(const char *s)
Definition: strings.c:172
#define CIB_OP_DELETE_ALT
Definition: internal.h:30
#define CRM_OP_PING
Definition: crm.h:108
gboolean cib_client_register_callback(cib_t *cib, int call_id, int timeout, gboolean only_success, void *user_data, const char *callback_name, void(*callback)(xmlNode *, int, int, xmlNode *, void *))
Definition: cib_client.c:583
int cib_internal_op(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options, const char *user_name)
Definition: cib_utils.c:759
#define safe_str_eq(a, b)
Definition: util.h:59
void cib_dump_pending_callbacks(void)
Definition: cib_client.c:671
enum cib_conn_type type
Definition: cib.h:146
enum cib_state state
Definition: cib.h:145
GList * notify_list
Definition: cib.h:154
#define crm_info(fmt, args...)
Definition: logging.h:243
Definition: cib.h:144
gint ciblib_GCompareFunc(gconstpointer a, gconstpointer b)
Definition: cib_client.c:545
#define CIB_OP_UPGRADE
Definition: internal.h:29