pacemaker  2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
cib.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2019 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 #ifndef CIB__H
9 # define CIB__H
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
21 # include <glib.h> // gboolean, GList
22 # include <libxml/tree.h> // xmlNode
23 # include <crm/common/ipc.h>
24 # include <crm/common/xml.h>
25 
26 # define CIB_FEATURE_SET "2.0"
27 
28 /* use compare_version() for doing comparisons */
29 
36 };
37 
38 enum cib_state {
42 };
43 
49 };
50 
51 /* *INDENT-OFF* */
53  cib_none = 0x00000000,
54  cib_verbose = 0x00000001, /* prefer stderr to logs */
55  cib_xpath = 0x00000002,
56  cib_multiple = 0x00000004,
57  cib_can_create = 0x00000008,
58  cib_discard_reply = 0x00000010,
59  cib_no_children = 0x00000020,
60  cib_xpath_address = 0x00000040,
61  cib_mixed_update = 0x00000080,
62  cib_scope_local = 0x00000100,
63  cib_dryrun = 0x00000200,
64  cib_sync_call = 0x00001000,
65  cib_no_mtime = 0x00002000,
66  cib_zero_copy = 0x00004000,
67  cib_inhibit_notify = 0x00010000,
68  cib_quorum_override = 0x00100000,
69  cib_inhibit_bcast = 0x01000000, /* TODO: Remove */
70  cib_force_diff = 0x10000000
71 };
72 
73 #define T_CIB_DIFF_NOTIFY "cib_diff_notify"
74 
75 /* *INDENT-ON* */
76 
77 typedef struct cib_s cib_t;
78 
79 typedef struct cib_api_operations_s {
80  int (*signon) (cib_t * cib, const char *name, enum cib_conn_type type);
81  int (*signon_raw) (cib_t * cib, const char *name, enum cib_conn_type type, int *event_fd);
82  int (*signoff) (cib_t * cib);
83  int (*free) (cib_t * cib);
84 
85  int (*set_op_callback) (cib_t * cib, void (*callback) (const xmlNode * msg, int callid,
86  int rc, xmlNode * output));
87 
88  int (*add_notify_callback) (cib_t * cib, const char *event,
89  void (*callback) (const char *event, xmlNode * msg));
90 
91  int (*del_notify_callback) (cib_t * cib, const char *event,
92  void (*callback) (const char *event, xmlNode * msg));
93 
94  int (*set_connection_dnotify) (cib_t * cib, void (*dnotify) (gpointer user_data));
95 
96  int (*inputfd) (cib_t * cib);
97 
98  int (*noop) (cib_t * cib, int call_options);
99  int (*ping) (cib_t * cib, xmlNode ** output_data, int call_options);
100 
101  int (*query) (cib_t * cib, const char *section, xmlNode ** output_data, int call_options);
102  int (*query_from) (cib_t * cib, const char *host, const char *section,
103  xmlNode ** output_data, int call_options);
104 
105  int (*is_master) (cib_t * cib);
106  int (*set_master) (cib_t * cib, int call_options);
107  int (*set_slave) (cib_t * cib, int call_options);
108  int (*set_slave_all) (cib_t * cib, int call_options);
109 
110  int (*sync) (cib_t * cib, const char *section, int call_options);
111  int (*sync_from) (cib_t * cib, const char *host, const char *section, int call_options);
112 
113  int (*upgrade) (cib_t * cib, int call_options);
114  int (*bump_epoch) (cib_t * cib, int call_options);
115 
116  int (*create) (cib_t * cib, const char *section, xmlNode * data, int call_options);
117  int (*modify) (cib_t * cib, const char *section, xmlNode * data, int call_options);
118  int (*update) (cib_t * cib, const char *section, xmlNode * data, int call_options);
119  int (*replace) (cib_t * cib, const char *section, xmlNode * data, int call_options);
120  int (*remove) (cib_t * cib, const char *section, xmlNode * data, int call_options);
121 
122  int (*erase) (cib_t * cib, xmlNode ** output_data, int call_options);
123  int (*delete_absolute) (cib_t * cib, const char *section, xmlNode * data, int call_options);
124 
125  int (*quit) (cib_t * cib, int call_options);
126 
127  int (*register_notification) (cib_t * cib, const char *callback, int enabled);
128 
129  gboolean(*register_callback) (cib_t * cib, int call_id, int timeout, gboolean only_success,
130  void *user_data, const char *callback_name,
131  void (*callback) (xmlNode *, int, int, xmlNode *, void *));
132 
133  gboolean (*register_callback_full)(cib_t *cib, int call_id, int timeout,
134  gboolean only_success, void *user_data,
135  const char *callback_name,
136  void (*callback)(xmlNode *, int, int,
137  xmlNode *, void *),
138  void (*free_func)(void *));
139 
141 
142 struct cib_s {
143  enum cib_state state;
145  enum cib_variant variant;
146 
147  int call_id;
150  void *delegate_fn;
151 
152  GList *notify_list;
153  void (*op_callback) (const xmlNode * msg, int call_id, int rc, xmlNode * output);
154 
156 };
157 
158 /* Core functions */
159 cib_t *cib_new(void);
160 cib_t *cib_native_new(void);
161 cib_t *cib_file_new(const char *filename);
162 cib_t *cib_remote_new(const char *server, const char *user, const char *passwd, int port,
163  gboolean encrypted);
164 
165 cib_t *cib_new_no_shadow(void);
166 char *get_shadow_file(const char *name);
167 cib_t *cib_shadow_new(const char *name);
168 
169 void cib_free_callbacks(cib_t *cib);
170 void cib_delete(cib_t * cib);
171 
172 void cib_dump_pending_callbacks(void);
173 int num_cib_op_callbacks(void);
174 void remove_cib_op_callback(int call_id, gboolean all_callbacks);
175 
176 # include <crm/cib/util.h>
177 
178 # define CIB_LIBRARY "libcib.so.27"
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif
cib_t * cib_shadow_new(const char *name)
Definition: cib_client.c:268
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_t * cib_remote_new(const char *server, const char *user, const char *passwd, int port, gboolean encrypted)
Definition: cib_remote.c:105
int call_timeout
Definition: cib.h:148
cib_call_options
Definition: cib.h:52
cib_t * cib_new(void)
Definition: cib_client.c:290
int(* delete_absolute)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:123
int(* signoff)(cib_t *cib)
Definition: cib.h:82
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
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
Definition: cib_client.c:641
AIS_Host host
Definition: internal.h:84
int(* signon_raw)(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
Definition: cib.h:81
int(* inputfd)(cib_t *cib)
Definition: cib.h:96
char * get_shadow_file(const char *name)
Definition: cib_client.c:208
Definition: cib.h:55
void cib_delete(cib_t *cib)
Free all memory used by CIB connection.
Definition: cib_client.c:426
Definition: cib.h:53
int(* set_op_callback)(cib_t *cib, void(*callback)(const xmlNode *msg, int callid, int rc, xmlNode *output))
Definition: cib.h:85
int(* sync)(cib_t *cib, const char *section, int call_options)
Definition: cib.h:110
struct cib_api_operations_s cib_api_operations_t
int(* set_connection_dnotify)(cib_t *cib, void(*dnotify)(gpointer user_data))
Definition: cib.h:94
int(* query_from)(cib_t *cib, const char *host, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:102
Definition: cib.h:46
cib_api_operations_t * cmds
Definition: cib.h:155
void cib_free_callbacks(cib_t *cib)
Free all callbacks for a CIB connection.
Definition: cib_client.c:404
int(* set_slave)(cib_t *cib, int call_options)
Definition: cib.h:107
int(* signon)(cib_t *cib, const char *name, enum cib_conn_type type)
Definition: cib.h:80
cib_variant
Definition: cib.h:30
int(* quit)(cib_t *cib, int call_options)
Definition: cib.h:125
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:117
int(* create)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:116
Wrappers for and extensions to libxml2.
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib.h:101
int(* is_master)(cib_t *cib)
Definition: cib.h:105
cib_t * cib_native_new(void)
Definition: cib_native.c:56
int(* replace)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:119
int num_cib_op_callbacks(void)
Definition: cib_client.c:653
Definition: cib.h:33
int(* add_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:88
int(* sync_from)(cib_t *cib, const char *host, const char *section, int call_options)
Definition: cib.h:111
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
Definition: cib.h:127
int(* ping)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:99
int(* update)(cib_t *cib, const char *section, xmlNode *data, int call_options)
Definition: cib.h:118
Definition: cib.h:63
void * variant_opaque
Definition: cib.h:149
cib_t * cib_file_new(const char *filename)
Definition: cib_file.c:459
int(* noop)(cib_t *cib, int call_options)
Definition: cib.h:98
cib_conn_type
Definition: cib.h:44
cib_state
Definition: cib.h:38
int(* set_slave_all)(cib_t *cib, int call_options)
Definition: cib.h:108
int(* del_notify_callback)(cib_t *cib, const char *event, void(*callback)(const char *event, xmlNode *msg))
Definition: cib.h:91
Definition: cib.h:34
int(* set_master)(cib_t *cib, int call_options)
Definition: cib.h:106
Definition: cib.h:32
char data[0]
Definition: internal.h:90
cib_t * cib_new_no_shadow(void)
Definition: cib_client.c:283
Wrappers for and extensions to libqb IPC.
int call_id
Definition: cib.h:147
int(* bump_epoch)(cib_t *cib, int call_options)
Definition: cib.h:114
void cib_dump_pending_callbacks(void)
Definition: cib_client.c:671
GList * notify_list
Definition: cib.h:152
int(* free)(cib_t *cib)
Definition: cib.h:83
int(* upgrade)(cib_t *cib, int call_options)
Definition: cib.h:113
int(* erase)(cib_t *cib, xmlNode **output_data, int call_options)
Definition: cib.h:122
Definition: cib.h:142
void * delegate_fn
Definition: cib.h:150
enum crm_ais_msg_types type
Definition: internal.h:83