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