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