pacemaker  2.1.0-7c3f660
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-2021 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/ipc_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 
62 # define T_CIB "cib"
63 # define T_CIB_NOTIFY "cib_notify"
64 /* notify sub-types */
65 # define T_CIB_PRE_NOTIFY "cib_pre_notify"
66 # define T_CIB_POST_NOTIFY "cib_post_notify"
67 # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
68 # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
69 
70 gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
71  int *_admin_epoch, int *_epoch, int *_updates);
72 
73 gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
74 void verify_cib_options(GHashTable * options);
75 gboolean cib_internal_config_changed(xmlNode * diff);
76 
77 extern GHashTable *cib_op_callback_table;
78 typedef struct cib_notify_client_s {
79  const char *event;
80  const char *obj_id; /* implement one day */
81  const char *obj_type; /* implement one day */
82  void (*callback) (const char *event, xmlNode * msg);
83 
85 
86 typedef struct cib_callback_client_s {
87  void (*callback) (xmlNode *, int, int, xmlNode *, void *);
88  const char *id;
89  void *user_data;
90  gboolean only_success;
91  struct timer_rec_s *timer;
92  void (*free_func)(void *);
94 
95 struct timer_rec_s {
96  int call_id;
97  int timeout;
98  guint ref;
100 };
101 
102 #define cib__set_call_options(cib_call_opts, call_for, flags_to_set) do { \
103  cib_call_opts = pcmk__set_flags_as(__func__, __LINE__, \
104  LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
105  (flags_to_set), #flags_to_set); \
106  } while (0)
107 
108 #define cib__clear_call_options(cib_call_opts, call_for, flags_to_clear) do { \
109  cib_call_opts = pcmk__clear_flags_as(__func__, __LINE__, \
110  LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
111  (flags_to_clear), #flags_to_clear); \
112  } while (0)
113 
114 typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
115  xmlNode *, xmlNode *, xmlNode **, xmlNode **);
116 
117 cib_t *cib_new_variant(void);
118 
119 int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
120  const char *section, xmlNode * req, xmlNode * input,
121  gboolean manage_counters, gboolean * config_changed,
122  xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
123  xmlNode ** output);
124 
125 xmlNode *cib_create_op(int call_id, const char *token, const char *op, const char *host,
126  const char *section, xmlNode * data, int call_options,
127  const char *user_name);
128 
129 void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
130 void cib_native_notify(gpointer data, gpointer user_data);
131 int cib_native_register_notification(cib_t * cib, const char *callback, int enabled);
132 gboolean cib_client_register_callback(cib_t * cib, int call_id, int timeout, gboolean only_success,
133  void *user_data, const char *callback_name,
134  void (*callback) (xmlNode *, int, int, xmlNode *, void *));
135 gboolean cib_client_register_callback_full(cib_t *cib, int call_id,
136  int timeout, gboolean only_success,
137  void *user_data,
138  const char *callback_name,
139  void (*callback)(xmlNode *, int, int,
140  xmlNode *, void *),
141  void (*free_func)(void *));
142 
143 int cib_process_query(const char *op, int options, const char *section, xmlNode * req,
144  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
145  xmlNode ** answer);
146 
147 int cib_process_erase(const char *op, int options, const char *section, xmlNode * req,
148  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
149  xmlNode ** answer);
150 
151 int cib_process_bump(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_replace(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_create(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_modify(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_delete(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_diff(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_upgrade(const char *op, int options, const char *section, xmlNode * req,
176  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
177  xmlNode ** answer);
178 
198 int cib_process_xpath(const char *op, int options, const char *section, xmlNode * req,
199  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
200  xmlNode ** answer);
201 
202 gboolean cib_config_changed(xmlNode * last, xmlNode * next, xmlNode ** diff);
203 gboolean update_results(xmlNode * failed, xmlNode * target, const char *operation, int return_code);
204 int cib_update_counter(xmlNode * xml_obj, const char *field, gboolean reset);
205 
206 int cib_internal_op(cib_t * cib, const char *op, const char *host,
207  const char *section, xmlNode * data,
208  xmlNode ** output_data, int call_options, const char *user_name);
209 
210 
211 int cib_file_read_and_verify(const char *filename, const char *sigfile,
212  xmlNode **root);
213 int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
214  const char *cib_filename);
215 
216 void cib__set_output(cib_t *cib, pcmk__output_t *out);
217 
218 #endif
pcmk__cpg_host_t host
Definition: cpg.c:49
char data[0]
Definition: cpg.c:55
gboolean update_results(xmlNode *failed, xmlNode *target, const char *operation, int return_code)
Definition: cib_ops.c:816
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:280
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:609
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:168
int(* cib_op_t)(const char *, int, const char *, xmlNode *, xmlNode *, xmlNode *, xmlNode **, xmlNode **)
Definition: internal.h:114
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:75
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:127
int cib_update_counter(xmlNode *xml_obj, const char *field, gboolean reset)
Definition: cib_ops.c:142
struct cib_notify_client_s cib_notify_client_t
int call_id
Definition: internal.h:96
gboolean only_success
Definition: internal.h:90
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:675
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:82
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:514
void cib_native_notify(gpointer data, gpointer user_data)
Definition: cib_utils.c:594
const char * obj_id
Definition: internal.h:80
cib_t * cib_new_variant(void)
Definition: cib_client.c:352
int timeout
Definition: internal.h:97
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:87
struct timer_rec_s * timer
Definition: internal.h:91
Formatted output for pacemaker tools.
int rc
Definition: pcmk_fence.c:35
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:584
gboolean cib_config_changed(xmlNode *last, xmlNode *next, xmlNode **diff)
Definition: cib_ops.c:603
gboolean cib_internal_config_changed(xmlNode *diff)
Definition: cib_utils.c:703
int cib_native_register_notification(cib_t *cib, const char *callback, int enabled)
Definition: cib_native.c:460
guint ref
Definition: internal.h:98
const char * event
Definition: internal.h:79
void cib__set_output(cib_t *cib, pcmk__output_t *out)
Definition: cib_remote.c:616
const char * target
Definition: pcmk_fence.c:29
GHashTable * cib_op_callback_table
Definition: cib_client.c:28
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:30
int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname, const char *cib_filename)
Definition: cib_file.c:362
gboolean cib_read_config(GHashTable *options, xmlNode *current_cib)
Definition: cib_utils.c:671
int cib_file_read_and_verify(const char *filename, const char *sigfile, xmlNode **root)
Definition: cib_file.c:141
const char * obj_type
Definition: internal.h:81
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:93
Cluster Configuration.
void verify_cib_options(GHashTable *options)
Definition: cib_utils.c:658
const char * id
Definition: internal.h:88
cib_t * cib
Definition: internal.h:99
This structure contains everything that makes up a single output formatter.
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:222
void(* free_func)(void *)
Definition: internal.h:92
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:599
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:719
unsigned int timeout
Definition: pcmk_fence.c:32
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:92
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:315
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:519