pacemaker  2.0.2-debe490
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2018 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 #ifndef CIB_INTERNAL__H
11 # define CIB_INTERNAL__H
12 # include <crm/cib.h>
13 # include <crm/common/ipcs.h>
14 
15 # define CIB_OP_SLAVE "cib_slave"
16 # define CIB_OP_SLAVEALL "cib_slave_all"
17 # define CIB_OP_MASTER "cib_master"
18 # define CIB_OP_SYNC "cib_sync"
19 # define CIB_OP_SYNC_ONE "cib_sync_one"
20 # define CIB_OP_ISMASTER "cib_ismaster"
21 # define CIB_OP_BUMP "cib_bump"
22 # define CIB_OP_QUERY "cib_query"
23 # define CIB_OP_CREATE "cib_create"
24 # define CIB_OP_MODIFY "cib_modify"
25 # define CIB_OP_DELETE "cib_delete"
26 # define CIB_OP_ERASE "cib_erase"
27 # define CIB_OP_REPLACE "cib_replace"
28 # define CIB_OP_APPLY_DIFF "cib_apply_diff"
29 # define CIB_OP_UPGRADE "cib_upgrade"
30 # define CIB_OP_DELETE_ALT "cib_delete_alt"
31 
32 # define F_CIB_CLIENTID "cib_clientid"
33 # define F_CIB_CALLOPTS "cib_callopt"
34 # define F_CIB_CALLID "cib_callid"
35 # define F_CIB_CALLDATA "cib_calldata"
36 # define F_CIB_OPERATION "cib_op"
37 # define F_CIB_ISREPLY "cib_isreplyto"
38 # define F_CIB_SECTION "cib_section"
39 # define F_CIB_HOST "cib_host"
40 # define F_CIB_RC "cib_rc"
41 # define F_CIB_UPGRADE_RC "cib_upgrade_rc"
42 # define F_CIB_DELEGATED "cib_delegated_from"
43 # define F_CIB_OBJID "cib_object"
44 # define F_CIB_OBJTYPE "cib_object_type"
45 # define F_CIB_EXISTING "cib_existing_object"
46 # define F_CIB_SEENCOUNT "cib_seen"
47 # define F_CIB_TIMEOUT "cib_timeout"
48 # define F_CIB_UPDATE "cib_update"
49 # define F_CIB_CALLBACK_TOKEN "cib_async_id"
50 # define F_CIB_GLOBAL_UPDATE "cib_update"
51 # define F_CIB_UPDATE_RESULT "cib_update_result"
52 # define F_CIB_CLIENTNAME "cib_clientname"
53 # define F_CIB_NOTIFY_TYPE "cib_notify_type"
54 # define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate"
55 # define F_CIB_UPDATE_DIFF "cib_update_diff"
56 # define F_CIB_USER "cib_user"
57 # define F_CIB_LOCAL_NOTIFY_ID "cib_local_notify_id"
58 # define F_CIB_PING_ID "cib_ping_id"
59 # define F_CIB_SCHEMA_MAX "cib_schema_max"
60 
61 # define T_CIB "cib"
62 # define T_CIB_NOTIFY "cib_notify"
63 /* notify sub-types */
64 # define T_CIB_PRE_NOTIFY "cib_pre_notify"
65 # define T_CIB_POST_NOTIFY "cib_post_notify"
66 # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
67 # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
68 
69 # define CIB_CHANNEL_RO "cib_ro"
70 # define CIB_CHANNEL_RW "cib_rw"
71 # define CIB_CHANNEL_SHM "cib_shm"
72 
73 gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
74  int *_admin_epoch, int *_epoch, int *_updates);
75 
76 gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
77 void verify_cib_options(GHashTable * options);
78 gboolean cib_internal_config_changed(xmlNode * diff);
79 
80 extern GHashTable *cib_op_callback_table;
81 typedef struct cib_notify_client_s {
82  const char *event;
83  const char *obj_id; /* implement one day */
84  const char *obj_type; /* implement one day */
85  void (*callback) (const char *event, xmlNode * msg);
86 
88 
89 typedef struct cib_callback_client_s {
90  void (*callback) (xmlNode *, int, int, xmlNode *, void *);
91  const char *id;
92  void *user_data;
93  gboolean only_success;
94  struct timer_rec_s *timer;
95  void (*free_func)(void *);
97 
98 struct timer_rec_s {
99  int call_id;
100  int timeout;
101  guint ref;
103 };
104 
105 typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
106  xmlNode *, xmlNode *, xmlNode **, xmlNode **);
107 
108 cib_t *cib_new_variant(void);
109 
110 int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
111  const char *section, xmlNode * req, xmlNode * input,
112  gboolean manage_counters, gboolean * config_changed,
113  xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
114  xmlNode ** output);
115 
116 xmlNode *cib_create_op(int call_id, const char *token, const char *op, const char *host,
117  const char *section, xmlNode * data, int call_options,
118  const char *user_name);
119 
120 void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
121 void cib_native_notify(gpointer data, gpointer user_data);
122 int cib_native_register_notification(cib_t * cib, const char *callback, int enabled);
123 gboolean cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
124  void *user_data, const char *callback_name,
125  void (*callback) (xmlNode *, int, int, xmlNode *, void *));
126 gboolean cib_client_register_callback_full(cib_t *cib, int call_id,
127  int timeout, gboolean only_success,
128  void *user_data,
129  const char *callback_name,
130  void (*callback)(xmlNode *, int, int,
131  xmlNode *, void *),
132  void (*free_func)(void *));
133 
134 int cib_process_query(const char *op, int options, const char *section, xmlNode * req,
135  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
136  xmlNode ** answer);
137 
138 int cib_process_erase(const char *op, int options, const char *section, xmlNode * req,
139  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
140  xmlNode ** answer);
141 
142 int cib_process_bump(const char *op, int options, const char *section, xmlNode * req,
143  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
144  xmlNode ** answer);
145 
146 int cib_process_replace(const char *op, int options, const char *section, xmlNode * req,
147  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
148  xmlNode ** answer);
149 
150 int cib_process_create(const char *op, int options, const char *section, xmlNode * req,
151  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
152  xmlNode ** answer);
153 
154 int cib_process_modify(const char *op, int options, const char *section, xmlNode * req,
155  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
156  xmlNode ** answer);
157 
158 int cib_process_delete(const char *op, int options, const char *section, xmlNode * req,
159  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
160  xmlNode ** answer);
161 
162 int cib_process_diff(const char *op, int options, const char *section, xmlNode * req,
163  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
164  xmlNode ** answer);
165 
166 int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req,
167  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
168  xmlNode ** answer);
169 
189 int cib_process_xpath(const char *op, int options, const char *section, xmlNode * req,
190  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
191  xmlNode ** answer);
192 
193 gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff);
194 gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code);
195 int cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset);
196 
197 int cib_internal_op(cib_t * cib, const char *op, const char *host,
198  const char *section, xmlNode * data,
199  xmlNode ** output_data, int call_options, const char *user_name);
200 
201 
202 int cib_file_read_and_verify(const char *filename, const char *sigfile,
203  xmlNode **root);
204 int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
205  const char *cib_filename);
206 
207 #endif
gboolean update_results(xmlNode *failed, xmlNode *target, const char *operation, int return_code)
Definition: cib_ops.c:808
int cib_process_delete(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:277
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:593
int cib_process_replace(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:165
int(* cib_op_t)(const char *, int, const char *, xmlNode *, xmlNode *, xmlNode *, xmlNode **, xmlNode **)
Definition: internal.h:105
int cib_process_erase(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:72
int cib_process_bump(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:124
AIS_Host host
Definition: internal.h:86
int cib_update_counter(xmlNode *xml_obj, const char *field, gboolean reset)
Definition: cib_ops.c:139
struct cib_notify_client_s cib_notify_client_t
int call_id
Definition: internal.h:99
gboolean only_success
Definition: internal.h:93
int cib_process_xpath(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:667
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:85
xmlNode * cib_create_op(int call_id, const char *token, const char *op, const char *host, const char *section, xmlNode *data, int call_options, const char *user_name)
Definition: cib_utils.c:512
void cib_native_notify(gpointer data, gpointer user_data)
Definition: cib_utils.c:594
const char * obj_id
Definition: internal.h:83
cib_t * cib_new_variant(void)
Definition: cib_client.c:343
int timeout
Definition: internal.h:100
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:90
struct timer_rec_s * timer
Definition: internal.h:94
int cib_process_diff(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:577
gboolean cib_config_changed(xmlNode *last, xmlNode *next, xmlNode **diff)
Definition: cib_ops.c:595
gboolean cib_internal_config_changed(xmlNode *diff)
Definition: cib_utils.c:743
int cib_native_register_notification(cib_t *cib, const char *callback, int enabled)
Definition: cib_native.c:490
guint ref
Definition: internal.h:101
const char * event
Definition: internal.h:82
GHashTable * cib_op_callback_table
Definition: cib_client.c:26
int cib_process_query(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:27
int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname, const char *cib_filename)
Definition: cib_file.c:328
gboolean cib_read_config(GHashTable *options, xmlNode *current_cib)
Definition: cib_utils.c:670
int cib_file_read_and_verify(const char *filename, const char *sigfile, xmlNode **root)
Definition: cib_file.c:114
const char * obj_type
Definition: internal.h:84
gboolean cib_diff_version_details(xmlNode *diff, int *admin_epoch, int *epoch, int *updates, int *_admin_epoch, int *_epoch, int *_updates)
Definition: cib_utils.c:99
Cluster Configuration.
void verify_cib_options(GHashTable *options)
Definition: cib_utils.c:658
const char * id
Definition: internal.h:91
cib_t * cib
Definition: internal.h:102
int cib_perform_op(const char *op, int call_options, cib_op_t *fn, gboolean is_query, const char *section, xmlNode *req, xmlNode *input, gboolean manage_counters, gboolean *config_changed, xmlNode *current_cib, xmlNode **result_cib, xmlNode **diff, xmlNode **output)
Definition: cib_utils.c:213
char data[0]
Definition: internal.h:92
void(* free_func)(void *)
Definition: internal.h:95
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
Definition: cib_utils.c:547
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:583
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:759
int cib_process_upgrade(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:89
int cib_process_modify(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:311
Definition: cib.h:144
struct cib_callback_client_s cib_callback_client_t
int cib_process_create(const char *op, int options, const char *section, xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:513