pacemaker  1.1.18-7fdfbbe
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 (C) 2004 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef CIB_INTERNAL__H
19 # define CIB_INTERNAL__H
20 # include <crm/cib.h>
21 # include <crm/common/ipcs.h>
22 
23 # define CIB_OP_SLAVE "cib_slave"
24 # define CIB_OP_SLAVEALL "cib_slave_all"
25 # define CIB_OP_MASTER "cib_master"
26 # define CIB_OP_SYNC "cib_sync"
27 # define CIB_OP_SYNC_ONE "cib_sync_one"
28 # define CIB_OP_ISMASTER "cib_ismaster"
29 # define CIB_OP_BUMP "cib_bump"
30 # define CIB_OP_QUERY "cib_query"
31 # define CIB_OP_CREATE "cib_create"
32 # define CIB_OP_UPDATE "cib_update"
33 # define CIB_OP_MODIFY "cib_modify"
34 # define CIB_OP_DELETE "cib_delete"
35 # define CIB_OP_ERASE "cib_erase"
36 # define CIB_OP_REPLACE "cib_replace"
37 # define CIB_OP_APPLY_DIFF "cib_apply_diff"
38 # define CIB_OP_UPGRADE "cib_upgrade"
39 # define CIB_OP_UPGRADE_OK "cib_upgrade_ok"
40 # define CIB_OP_DELETE_ALT "cib_delete_alt"
41 # define CIB_OP_NOTIFY "cib_notify"
42 
43 # define F_CIB_CLIENTID "cib_clientid"
44 # define F_CIB_CALLOPTS "cib_callopt"
45 # define F_CIB_CALLID "cib_callid"
46 # define F_CIB_CALLDATA "cib_calldata"
47 # define F_CIB_OPERATION "cib_op"
48 # define F_CIB_ISREPLY "cib_isreplyto"
49 # define F_CIB_SECTION "cib_section"
50 # define F_CIB_HOST "cib_host"
51 # define F_CIB_RC "cib_rc"
52 # define F_CIB_DELEGATED "cib_delegated_from"
53 # define F_CIB_OBJID "cib_object"
54 # define F_CIB_OBJTYPE "cib_object_type"
55 # define F_CIB_EXISTING "cib_existing_object"
56 # define F_CIB_SEENCOUNT "cib_seen"
57 # define F_CIB_TIMEOUT "cib_timeout"
58 # define F_CIB_UPDATE "cib_update"
59 # define F_CIB_CALLBACK_TOKEN "cib_async_id"
60 # define F_CIB_GLOBAL_UPDATE "cib_update"
61 # define F_CIB_UPDATE_RESULT "cib_update_result"
62 # define F_CIB_CLIENTNAME "cib_clientname"
63 # define F_CIB_NOTIFY_TYPE "cib_notify_type"
64 # define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate"
65 # define F_CIB_UPDATE_DIFF "cib_update_diff"
66 # define F_CIB_USER "cib_user"
67 # define F_CIB_LOCAL_NOTIFY_ID "cib_local_notify_id"
68 # define F_CIB_PING_ID "cib_ping_id"
69 # define F_CIB_SCHEMA_MAX "cib_schema_max"
70 
71 # define T_CIB "cib"
72 # define T_CIB_NOTIFY "cib_notify"
73 /* notify sub-types */
74 # define T_CIB_PRE_NOTIFY "cib_pre_notify"
75 # define T_CIB_POST_NOTIFY "cib_post_notify"
76 # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
77 # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
78 
79 # define cib_channel_ro "cib_ro"
80 # define cib_channel_rw "cib_rw"
81 # define cib_channel_shm "cib_shm"
82 
83 void cib_add_digest(xmlNode * source, xmlNode * target);
84 void fix_cib_diff(xmlNode * last, xmlNode * next, xmlNode * local_diff, gboolean changed);
85 gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
86  int *_admin_epoch, int *_epoch, int *_updates);
87 
88 gboolean startCib(const char *filename);
89 int cib_compare_generation(xmlNode * left, xmlNode * right);
90 gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
91 void verify_cib_options(GHashTable * options);
92 gboolean cib_internal_config_changed(xmlNode * diff);
93 
94 extern GHashTable *cib_op_callback_table;
95 typedef struct cib_notify_client_s {
96  const char *event;
97  const char *obj_id; /* implement one day */
98  const char *obj_type; /* implement one day */
99  void (*callback) (const char *event, xmlNode * msg);
100 
102 
103 typedef struct cib_callback_client_s {
104  void (*callback) (xmlNode *, int, int, xmlNode *, void *);
105  const char *id;
106  void *user_data;
107  gboolean only_success;
109  void (*free_func)(void *);
111 
112 struct timer_rec_s {
113  int call_id;
114  int timeout;
115  guint ref;
117 };
118 
119 typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
120  xmlNode *, xmlNode *, xmlNode **, xmlNode **);
121 
122 cib_t *cib_new_variant(void);
123 
124 int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
125  const char *section, xmlNode * req, xmlNode * input,
126  gboolean manage_counters, gboolean * config_changed,
127  xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
128  xmlNode ** output);
129 
130 xmlNode *cib_create_op(int call_id, const char *token, const char *op, const char *host,
131  const char *section, xmlNode * data, int call_options,
132  const char *user_name);
133 
134 void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
135 void cib_native_notify(gpointer data, gpointer user_data);
136 int cib_native_register_notification(cib_t * cib, const char *callback, int enabled);
137 gboolean cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
138  void *user_data, const char *callback_name,
139  void (*callback) (xmlNode *, int, int, xmlNode *, void *));
140 gboolean cib_client_register_callback_full(cib_t *cib, int call_id,
141  int timeout, gboolean only_success,
142  void *user_data,
143  const char *callback_name,
144  void (*callback)(xmlNode *, int, int,
145  xmlNode *, void *),
146  void (*free_func)(void *));
147 
148 int cib_process_query(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_erase(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_bump(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_replace(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_create(const char *op, int options, const char *section, xmlNode * req,
165  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
166  xmlNode ** answer);
167 
168 int cib_process_modify(const char *op, int options, const char *section, xmlNode * req,
169  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
170  xmlNode ** answer);
171 
172 int cib_process_delete(const char *op, int options, const char *section, xmlNode * req,
173  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
174  xmlNode ** answer);
175 
176 int cib_process_diff(const char *op, int options, const char *section, xmlNode * req,
177  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
178  xmlNode ** answer);
179 
180 int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req,
181  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
182  xmlNode ** answer);
183 
203 int cib_process_xpath(const char *op, int options, const char *section, xmlNode * req,
204  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
205  xmlNode ** answer);
206 
207 gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff);
208 gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code);
209 int cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset);
210 
211 int cib_internal_op(cib_t * cib, const char *op, const char *host,
212  const char *section, xmlNode * data,
213  xmlNode ** output_data, int call_options, const char *user_name);
214 
215 
216 int cib_file_read_and_verify(const char *filename, const char *sigfile,
217  xmlNode **root);
218 int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
219  const char *cib_filename);
220 
221 #endif
gboolean update_results(xmlNode *failed, xmlNode *target, const char *operation, int return_code)
Definition: cib_ops.c:833
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:288
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:604
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:176
void fix_cib_diff(xmlNode *last, xmlNode *next, xmlNode *local_diff, gboolean changed)
int(* cib_op_t)(const char *, int, const char *, xmlNode *, xmlNode *, xmlNode *, xmlNode **, xmlNode **)
Definition: internal.h:119
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:83
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:134
AIS_Host host
Definition: internal.h:52
int cib_update_counter(xmlNode *xml_obj, const char *field, gboolean reset)
Definition: cib_ops.c:149
struct cib_notify_client_s cib_notify_client_t
gboolean startCib(const char *filename)
int call_id
Definition: internal.h:113
gboolean only_success
Definition: internal.h:107
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:680
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:99
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:588
void cib_native_notify(gpointer data, gpointer user_data)
Definition: cib_utils.c:670
const char * obj_id
Definition: internal.h:97
cib_t * cib_new_variant(void)
Definition: cib_client.c:354
int timeout
Definition: internal.h:114
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:104
struct timer_rec_s * timer
Definition: internal.h:108
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:590
gboolean cib_config_changed(xmlNode *last, xmlNode *next, xmlNode **diff)
Definition: cib_ops.c:608
gboolean cib_internal_config_changed(xmlNode *diff)
Definition: cib_utils.c:819
int cib_native_register_notification(cib_t *cib, const char *callback, int enabled)
Definition: cib_native.c:493
guint ref
Definition: internal.h:115
const char * event
Definition: internal.h:96
GHashTable * cib_op_callback_table
Definition: cib_client.c:37
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:38
int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname, const char *cib_filename)
Definition: cib_file.c:346
gboolean cib_read_config(GHashTable *options, xmlNode *current_cib)
Definition: cib_utils.c:746
int cib_file_read_and_verify(const char *filename, const char *sigfile, xmlNode **root)
Definition: cib_file.c:125
int cib_compare_generation(xmlNode *left, xmlNode *right)
Definition: cib_utils.c:66
const char * obj_type
Definition: internal.h:98
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:177
Cluster Configuration.
void verify_cib_options(GHashTable *options)
Definition: cib_utils.c:734
const char * id
Definition: internal.h:105
cib_t * cib
Definition: internal.h:116
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:291
char data[0]
Definition: internal.h:58
void(* free_func)(void *)
Definition: internal.h:109
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
Definition: cib_utils.c:623
void cib_add_digest(xmlNode *source, xmlNode *target)
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:594
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:835
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:100
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:322
Definition: cib.h:148
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:526