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