1
2
3
4
5
6
7
8
9
10 #ifndef CIB_INTERNAL__H
11 # define CIB_INTERNAL__H
12 # include <crm/cib.h>
13 # include <crm/common/ipc_internal.h>
14 # include <crm/common/output_internal.h>
15
16 # define CIB_OP_SLAVE "cib_slave"
17 # define CIB_OP_SLAVEALL "cib_slave_all"
18 # define CIB_OP_MASTER "cib_master"
19 # define CIB_OP_SYNC "cib_sync"
20 # define CIB_OP_SYNC_ONE "cib_sync_one"
21 # define CIB_OP_ISMASTER "cib_ismaster"
22 # define CIB_OP_BUMP "cib_bump"
23 # define CIB_OP_QUERY "cib_query"
24 # define CIB_OP_CREATE "cib_create"
25 # define CIB_OP_MODIFY "cib_modify"
26 # define CIB_OP_DELETE "cib_delete"
27 # define CIB_OP_ERASE "cib_erase"
28 # define CIB_OP_REPLACE "cib_replace"
29 # define CIB_OP_APPLY_DIFF "cib_apply_diff"
30 # define CIB_OP_UPGRADE "cib_upgrade"
31 # define CIB_OP_DELETE_ALT "cib_delete_alt"
32
33 # define F_CIB_CLIENTID "cib_clientid"
34 # define F_CIB_CALLOPTS "cib_callopt"
35 # define F_CIB_CALLID "cib_callid"
36 # define F_CIB_CALLDATA "cib_calldata"
37 # define F_CIB_OPERATION "cib_op"
38 # define F_CIB_ISREPLY "cib_isreplyto"
39 # define F_CIB_SECTION "cib_section"
40 # define F_CIB_HOST "cib_host"
41 # define F_CIB_RC "cib_rc"
42 # define F_CIB_UPGRADE_RC "cib_upgrade_rc"
43 # define F_CIB_DELEGATED "cib_delegated_from"
44 # define F_CIB_OBJID "cib_object"
45 # define F_CIB_OBJTYPE "cib_object_type"
46 # define F_CIB_EXISTING "cib_existing_object"
47 # define F_CIB_SEENCOUNT "cib_seen"
48 # define F_CIB_TIMEOUT "cib_timeout"
49 # define F_CIB_UPDATE "cib_update"
50 # define F_CIB_CALLBACK_TOKEN "cib_async_id"
51 # define F_CIB_GLOBAL_UPDATE "cib_update"
52 # define F_CIB_UPDATE_RESULT "cib_update_result"
53 # define F_CIB_CLIENTNAME "cib_clientname"
54 # define F_CIB_NOTIFY_TYPE "cib_notify_type"
55 # define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate"
56 # define F_CIB_UPDATE_DIFF "cib_update_diff"
57 # define F_CIB_USER "cib_user"
58 # define F_CIB_LOCAL_NOTIFY_ID "cib_local_notify_id"
59 # define F_CIB_PING_ID "cib_ping_id"
60 # define F_CIB_SCHEMA_MAX "cib_schema_max"
61 # define F_CIB_CHANGE_SECTION "cib_change_section"
62
63 # define T_CIB "cib"
64 # define T_CIB_NOTIFY "cib_notify"
65
66 # define T_CIB_PRE_NOTIFY "cib_pre_notify"
67 # define T_CIB_POST_NOTIFY "cib_post_notify"
68 # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
69 # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
70
71 enum cib_change_section_info {
72 cib_change_section_none = 0x00000000,
73 cib_change_section_nodes = 0x00000001,
74 cib_change_section_alerts = 0x00000002,
75 cib_change_section_status = 0x00000004
76 };
77
78
79 gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
80 int *_admin_epoch, int *_epoch, int *_updates);
81
82 gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
83 void verify_cib_options(GHashTable * options);
84 gboolean cib_internal_config_changed(xmlNode * diff);
85
86 typedef struct cib_notify_client_s {
87 const char *event;
88 const char *obj_id;
89 const char *obj_type;
90 void (*callback) (const char *event, xmlNode * msg);
91
92 } cib_notify_client_t;
93
94 typedef struct cib_callback_client_s {
95 void (*callback) (xmlNode *, int, int, xmlNode *, void *);
96 const char *id;
97 void *user_data;
98 gboolean only_success;
99 struct timer_rec_s *timer;
100 void (*free_func)(void *);
101 } cib_callback_client_t;
102
103 struct timer_rec_s {
104 int call_id;
105 int timeout;
106 guint ref;
107 cib_t *cib;
108 };
109
110 #define cib__set_call_options(cib_call_opts, call_for, flags_to_set) do { \
111 cib_call_opts = pcmk__set_flags_as(__func__, __LINE__, \
112 LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
113 (flags_to_set), #flags_to_set); \
114 } while (0)
115
116 #define cib__clear_call_options(cib_call_opts, call_for, flags_to_clear) do { \
117 cib_call_opts = pcmk__clear_flags_as(__func__, __LINE__, \
118 LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
119 (flags_to_clear), #flags_to_clear); \
120 } while (0)
121
122 typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
123 xmlNode *, xmlNode *, xmlNode **, xmlNode **);
124
125 cib_t *cib_new_variant(void);
126
127 int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
128 const char *section, xmlNode * req, xmlNode * input,
129 gboolean manage_counters, gboolean * config_changed,
130 xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
131 xmlNode ** output);
132
133 xmlNode *cib_create_op(int call_id, const char *token, const char *op, const char *host,
134 const char *section, xmlNode * data, int call_options,
135 const char *user_name);
136
137 void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
138 void cib_native_notify(gpointer data, gpointer user_data);
139 int cib_native_register_notification(cib_t * cib, const char *callback, int enabled);
140 gboolean cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
141 void *user_data, const char *callback_name,
142 void (*callback) (xmlNode *, int, int, xmlNode *, void *));
143 gboolean cib_client_register_callback_full(cib_t *cib, int call_id,
144 int timeout, gboolean only_success,
145 void *user_data,
146 const char *callback_name,
147 void (*callback)(xmlNode *, int, int,
148 xmlNode *, void *),
149 void (*free_func)(void *));
150
151 int cib_process_query(const char *op, int options, const char *section, xmlNode * req,
152 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
153 xmlNode ** answer);
154
155 int cib_process_erase(const char *op, int options, const char *section, xmlNode * req,
156 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
157 xmlNode ** answer);
158
159 int cib_process_bump(const char *op, int options, const char *section, xmlNode * req,
160 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
161 xmlNode ** answer);
162
163 int cib_process_replace(const char *op, int options, const char *section, xmlNode * req,
164 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
165 xmlNode ** answer);
166
167 int cib_process_create(const char *op, int options, const char *section, xmlNode * req,
168 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
169 xmlNode ** answer);
170
171 int cib_process_modify(const char *op, int options, const char *section, xmlNode * req,
172 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
173 xmlNode ** answer);
174
175 int cib_process_delete(const char *op, int options, const char *section, xmlNode * req,
176 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
177 xmlNode ** answer);
178
179 int cib_process_diff(const char *op, int options, const char *section, xmlNode * req,
180 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
181 xmlNode ** answer);
182
183 int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req,
184 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
185 xmlNode ** answer);
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 int cib_process_xpath(const char *op, int options, const char *section, xmlNode * req,
207 xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
208 xmlNode ** answer);
209
210 gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff);
211 gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code);
212 int cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset);
213
214 int cib_internal_op(cib_t * cib, const char *op, const char *host,
215 const char *section, xmlNode * data,
216 xmlNode ** output_data, int call_options, const char *user_name);
217
218
219 int cib_file_read_and_verify(const char *filename, const char *sigfile,
220 xmlNode **root);
221 int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
222 const char *cib_filename);
223
224 void cib__set_output(cib_t *cib, pcmk__output_t *out);
225
226 cib_callback_client_t* cib__lookup_id (int call_id);
227
228
229
230
231
232
233
234
235
236
237
238
239
240 int cib__signon_query(cib_t **cib, xmlNode **cib_object);
241
242 int cib__clean_up_connection(cib_t **cib);
243
244 int cib__update_node_attr(pcmk__output_t *out, cib_t *cib, int call_options,
245 const char *section, const char *node_uuid, const char *set_type,
246 const char *set_name, const char *attr_id, const char *attr_name,
247 const char *attr_value, const char *user_name,
248 const char *node_type);
249
250 int cib__read_node_attr(pcmk__output_t *out, cib_t *cib, const char *section,
251 const char *node_uuid, const char *set_type, const char *set_name,
252 const char *attr_id, const char *attr_name, char **attr_value,
253 const char *user_name);
254
255 int cib__delete_node_attr(pcmk__output_t *out, cib_t *cib, int options,
256 const char *section, const char *node_uuid, const char *set_type,
257 const char *set_name, const char *attr_id, const char *attr_name,
258 const char *attr_value, const char *user_name);
259
260 #endif