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