pacemaker  2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
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 {
588  only_success, user_data,
589  callback_name, callback, NULL);
590 }
591 
592 gboolean
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 }
cib_remote_new
cib_t * cib_remote_new(const char *server, const char *user, const char *passwd, int port, gboolean encrypted)
Definition: cib_remote.c:105
cib_api_operations_s
Definition: cib.h:79
cib_api_operations_s::register_callback_full
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:133
CIB_OP_SLAVE
#define CIB_OP_SLAVE
Definition: internal.h:13
CIB_OP_ISMASTER
#define CIB_OP_ISMASTER
Definition: internal.h:18
cib_callback_client_s::only_success
gboolean only_success
Definition: internal.h:91
cib_api_operations_s::sync_from
int(* sync_from)(cib_t *cib, const char *host, const char *section, int call_options)
Definition: cib.h:111
cib_native_new
cib_t * cib_native_new(void)
Definition: cib_native.c:56
CIB_OP_CREATE
#define CIB_OP_CREATE
Definition: internal.h:21
crm_get_tmpdir
const char * crm_get_tmpdir(void)
Definition: io.c:500
cib_s::cmds
cib_api_operations_t * cmds
Definition: cib.h:155
cib_api_operations_s::noop
int(* noop)(cib_t *cib, int call_options)
Definition: cib.h:98
msg_xml.h
cib_notify_client_s::callback
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:83
cib_native
Definition: cib.h:32
cib_api_operations_s::remove
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:120
cib_api_operations_s::free
int(* free)(cib_t *cib)
Definition: cib.h:83
cib_new_variant
cib_t * cib_new_variant(void)
Definition: cib_client.c:343
data
char data[0]
Definition: internal.h:90
cib_api_operations_s::del_notify_callback
int(* del_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:91
CIB_OP_UPGRADE
#define CIB_OP_UPGRADE
Definition: internal.h:27
cib_callback_client_s::timer
struct timer_rec_s * timer
Definition: internal.h:92
cib_disconnected
Definition: cib.h:41
cib_api_operations_s::modify
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:117
cib_no_connection
Definition: cib.h:47
CIB_OP_BUMP
#define CIB_OP_BUMP
Definition: internal.h:19
pcmk_strerror
const char * pcmk_strerror(int rc)
Definition: results.c:184
CRM_CHECK
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:165
cib_api_operations_s::register_notification
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
Definition: cib.h:127
cib_client_register_callback
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
cib_op_callback_table
GHashTable * cib_op_callback_table
Definition: cib_client.c:26
crm_trace
#define crm_trace(fmt, args...)
Definition: logging.h:255
safe_str_eq
#define safe_str_eq(a, b)
Definition: util.h:54
cib_api_operations_s::set_op_callback
int(* set_op_callback)(cib_t *cib, void(*callback)(const xmlNode *msg, int callid, int rc, xmlNode *output))
Definition: cib.h:85
crm_warn
#define crm_warn(fmt, args...)
Definition: logging.h:250
cib_client_del_notify_callback
int cib_client_del_notify_callback(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib_client.c:500
cib_remote
Definition: cib.h:34
cib_api_operations_s::sync
int(* sync)(cib_t *cib, const char *section, int call_options)
Definition: cib.h:110
xml.h
Wrappers for and extensions to libxml2.
cib_api_operations_s::erase
int(* erase)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:122
crm_is_true
gboolean crm_is_true(const char *s)
Definition: strings.c:156
cib_callback_client_s::free_func
void(* free_func)(void *)
Definition: internal.h:93
cib_api_operations_s::upgrade
int(* upgrade)(cib_t *cib, int call_options)
Definition: cib.h:113
internal.h
cib_api_operations_s::update
int(* update)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:118
op_common
#define op_common(cib)
Definition: cib_client.c:39
cib_api_operations_s::query_from
int(* query_from)(cib_t *cib, const char *host, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:102
cib_delete
void cib_delete(cib_t *cib)
Free all memory used by CIB connection.
Definition: cib_client.c:426
cib_shadow_new
cib_t * cib_shadow_new(const char *shadow)
Definition: cib_client.c:268
CRM_OP_PING
#define CRM_OP_PING
Definition: crm.h:106
cib_s::variant_opaque
void * variant_opaque
Definition: cib.h:149
crm_info
#define crm_info(fmt, args...)
Definition: logging.h:252
cib_api_operations_s::set_slave_all
int(* set_slave_all)(cib_t *cib, int call_options)
Definition: cib.h:108
timer_rec_s
Definition: internal.h:96
cib_notify_client_s::event
const char * event
Definition: internal.h:80
cib_free_callbacks
void cib_free_callbacks(cib_t *cib)
Free all callbacks for a CIB connection.
Definition: cib_client.c:404
cib_callback_client_s
Definition: internal.h:87
cib_callback_client_s::user_data
void * user_data
Definition: internal.h:90
cib_api_operations_s::create
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:116
crm_debug
#define crm_debug(fmt, args...)
Definition: logging.h:254
cib_callback_client_s::callback
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:88
cib_client_set_op_callback
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
CIB_OP_QUERY
#define CIB_OP_QUERY
Definition: internal.h:20
cib_s::notify_list
GList * notify_list
Definition: cib.h:152
cib_dump_pending_callbacks
void cib_dump_pending_callbacks(void)
Definition: cib_client.c:671
cib_client_register_callback_full
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
CIB_OP_SYNC
#define CIB_OP_SYNC
Definition: internal.h:16
CIB_OP_ERASE
#define CIB_OP_ERASE
Definition: internal.h:24
timer_rec_s::cib
cib_t * cib
Definition: internal.h:100
CRM_OP_NOOP
#define CRM_OP_NOOP
Definition: crm.h:100
cib_s::variant
enum cib_variant variant
Definition: cib.h:145
cib_new
cib_t * cib_new(void)
Definition: cib_client.c:290
cib_sync_call
Definition: cib.h:64
num_cib_op_callbacks
int num_cib_op_callbacks(void)
Definition: cib_client.c:653
cib_api_operations_s::query
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:101
CIB_OP_MODIFY
#define CIB_OP_MODIFY
Definition: internal.h:22
cib_callback_client_s::id
const char * id
Definition: internal.h:89
cib_client_add_notify_callback
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_scope_local
Definition: cib.h:62
timer_rec_s::call_id
int call_id
Definition: internal.h:97
crm_parse_int
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
Definition: strings.c:107
crm_perror
#define crm_perror(level, fmt, args...)
Log a system error message.
Definition: logging.h:227
host
AIS_Host host
Definition: internal.h:84
cib_undefined
Definition: cib.h:31
cib_api_operations_s::is_master
int(* is_master)(cib_t *cib)
Definition: cib.h:105
cib_s::call_id
int call_id
Definition: cib.h:147
cib_api_operations_s::set_slave
int(* set_slave)(cib_t *cib, int call_options)
Definition: cib.h:107
crm_str
#define crm_str(x)
Definition: logging.h:275
cib_api_operations_s::add_notify_callback
int(* add_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:88
ETIME
#define ETIME
Definition: portability.h:160
ciblib_GCompareFunc
gint ciblib_GCompareFunc(gconstpointer a, gconstpointer b)
Definition: cib_client.c:545
cib_file_new
cib_t * cib_file_new(const char *filename)
Definition: cib_file.c:459
cib_internal_op
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
get_shadow_file
char * get_shadow_file(const char *suffix)
Definition: cib_client.c:208
cib_api_operations_s::bump_epoch
int(* bump_epoch)(cib_t *cib, int call_options)
Definition: cib.h:114
remove_cib_op_callback
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
Definition: cib_client.c:641
cib_s::type
enum cib_conn_type type
Definition: cib.h:144
cib_s
Definition: cib.h:142
cib_s::state
enum cib_state state
Definition: cib.h:143
cib_api_operations_s::set_master
int(* set_master)(cib_t *cib, int call_options)
Definition: cib.h:106
CIB_OP_DELETE_ALT
#define CIB_OP_DELETE_ALT
Definition: internal.h:28
cib_api_operations_s::delete_absolute
int(* delete_absolute)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:123
timer_rec_s::ref
guint ref
Definition: internal.h:99
cib_new_no_shadow
cib_t * cib_new_no_shadow(void)
Definition: cib_client.c:283
CRM_CONFIG_DIR
#define CRM_CONFIG_DIR
Definition: config.h:35
CIB_OP_MASTER
#define CIB_OP_MASTER
Definition: internal.h:15
cib_api_operations_s::ping
int(* ping)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:99
cib_native_callback
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
Definition: cib_utils.c:547
cib_notify_client_s
Definition: internal.h:79
CRM_DAEMON_USER
#define CRM_DAEMON_USER
Definition: config.h:47
cib_s::op_callback
void(* op_callback)(const xmlNode *msg, int call_id, int rc, xmlNode *output)
Definition: cib.h:153
CIB_OP_DELETE
#define CIB_OP_DELETE
Definition: internal.h:23
crm_internal.h
cib_api_operations_s::register_callback
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:129
cib_api_operations_s::replace
int(* replace)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:119
crm.h
A dumping ground.
CIB_OP_REPLACE
#define CIB_OP_REPLACE
Definition: internal.h:25
pcmk_ok
#define pcmk_ok
Definition: results.h:35
timer_rec_s::timeout
int timeout
Definition: internal.h:98