pacemaker  2.1.6-802a72226b
Scalable High-Availability cluster resource manager
internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2023 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 // Request types for CIB manager IPC/CPG
17 #define PCMK__CIB_REQUEST_SECONDARY "cib_slave"
18 #define PCMK__CIB_REQUEST_ALL_SECONDARY "cib_slave_all"
19 #define PCMK__CIB_REQUEST_PRIMARY "cib_master"
20 #define PCMK__CIB_REQUEST_SYNC_TO_ALL "cib_sync"
21 #define PCMK__CIB_REQUEST_SYNC_TO_ONE "cib_sync_one"
22 #define PCMK__CIB_REQUEST_IS_PRIMARY "cib_ismaster"
23 #define PCMK__CIB_REQUEST_BUMP "cib_bump"
24 #define PCMK__CIB_REQUEST_QUERY "cib_query"
25 #define PCMK__CIB_REQUEST_CREATE "cib_create"
26 #define PCMK__CIB_REQUEST_MODIFY "cib_modify"
27 #define PCMK__CIB_REQUEST_DELETE "cib_delete"
28 #define PCMK__CIB_REQUEST_ERASE "cib_erase"
29 #define PCMK__CIB_REQUEST_REPLACE "cib_replace"
30 #define PCMK__CIB_REQUEST_APPLY_PATCH "cib_apply_diff"
31 #define PCMK__CIB_REQUEST_UPGRADE "cib_upgrade"
32 #define PCMK__CIB_REQUEST_ABS_DELETE "cib_delete_alt"
33 #define PCMK__CIB_REQUEST_NOOP "noop"
34 #define PCMK__CIB_REQUEST_SHUTDOWN "cib_shutdown_req"
35 
36 # define F_CIB_CLIENTID "cib_clientid"
37 # define F_CIB_CALLOPTS "cib_callopt"
38 # define F_CIB_CALLID "cib_callid"
39 # define F_CIB_CALLDATA "cib_calldata"
40 # define F_CIB_OPERATION "cib_op"
41 # define F_CIB_ISREPLY "cib_isreplyto"
42 # define F_CIB_SECTION "cib_section"
43 # define F_CIB_HOST "cib_host"
44 # define F_CIB_RC "cib_rc"
45 # define F_CIB_UPGRADE_RC "cib_upgrade_rc"
46 # define F_CIB_DELEGATED "cib_delegated_from"
47 # define F_CIB_OBJID "cib_object"
48 # define F_CIB_OBJTYPE "cib_object_type"
49 # define F_CIB_EXISTING "cib_existing_object"
50 # define F_CIB_SEENCOUNT "cib_seen"
51 # define F_CIB_TIMEOUT "cib_timeout"
52 # define F_CIB_UPDATE "cib_update"
53 # define F_CIB_GLOBAL_UPDATE "cib_update"
54 # define F_CIB_UPDATE_RESULT "cib_update_result"
55 # define F_CIB_CLIENTNAME "cib_clientname"
56 # define F_CIB_NOTIFY_TYPE "cib_notify_type"
57 # define F_CIB_NOTIFY_ACTIVATE "cib_notify_activate"
58 # define F_CIB_UPDATE_DIFF "cib_update_diff"
59 # define F_CIB_USER "cib_user"
60 # define F_CIB_LOCAL_NOTIFY_ID "cib_local_notify_id"
61 # define F_CIB_PING_ID "cib_ping_id"
62 # define F_CIB_SCHEMA_MAX "cib_schema_max"
63 # define F_CIB_CHANGE_SECTION "cib_change_section"
64 
65 # define T_CIB "cib"
66 # define T_CIB_NOTIFY "cib_notify"
67 /* notify sub-types */
68 # define T_CIB_PRE_NOTIFY "cib_pre_notify"
69 # define T_CIB_POST_NOTIFY "cib_post_notify"
70 # define T_CIB_UPDATE_CONFIRM "cib_update_confirmation"
71 # define T_CIB_REPLACE_NOTIFY "cib_refresh_notify"
72 
83 };
84 
85 
86 gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
87  int *_admin_epoch, int *_epoch, int *_updates);
88 
89 gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
90 
91 typedef struct cib_notify_client_s {
92  const char *event;
93  const char *obj_id; /* implement one day */
94  const char *obj_type; /* implement one day */
95  void (*callback) (const char *event, xmlNode * msg);
96 
98 
99 typedef struct cib_callback_client_s {
100  void (*callback) (xmlNode *, int, int, xmlNode *, void *);
101  const char *id;
102  void *user_data;
103  gboolean only_success;
105  void (*free_func)(void *);
107 
108 struct timer_rec_s {
109  int call_id;
110  int timeout;
111  guint ref;
113 };
114 
115 #define cib__set_call_options(cib_call_opts, call_for, flags_to_set) do { \
116  cib_call_opts = pcmk__set_flags_as(__func__, __LINE__, \
117  LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
118  (flags_to_set), #flags_to_set); \
119  } while (0)
120 
121 #define cib__clear_call_options(cib_call_opts, call_for, flags_to_clear) do { \
122  cib_call_opts = pcmk__clear_flags_as(__func__, __LINE__, \
123  LOG_TRACE, "CIB call", (call_for), (cib_call_opts), \
124  (flags_to_clear), #flags_to_clear); \
125  } while (0)
126 
127 typedef int (*cib_op_t) (const char *, int, const char *, xmlNode *,
128  xmlNode *, xmlNode *, xmlNode **, xmlNode **);
129 
130 cib_t *cib_new_variant(void);
131 
132 int cib_perform_op(const char *op, int call_options, cib_op_t * fn, gboolean is_query,
133  const char *section, xmlNode * req, xmlNode * input,
134  gboolean manage_counters, gboolean * config_changed,
135  xmlNode * current_cib, xmlNode ** result_cib, xmlNode ** diff,
136  xmlNode ** output);
137 
138 xmlNode *cib_create_op(int call_id, const char *op, const char *host,
139  const char *section, xmlNode * data, int call_options,
140  const char *user_name);
141 
142 void cib_native_callback(cib_t * cib, xmlNode * msg, int call_id, int rc);
143 void cib_native_notify(gpointer data, gpointer user_data);
144 
145 int cib_process_query(const char *op, int options, const char *section, xmlNode * req,
146  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
147  xmlNode ** answer);
148 
149 int cib_process_erase(const char *op, int options, const char *section, xmlNode * req,
150  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
151  xmlNode ** answer);
152 
153 int cib_process_bump(const char *op, int options, const char *section, xmlNode * req,
154  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
155  xmlNode ** answer);
156 
157 int cib_process_replace(const char *op, int options, const char *section, xmlNode * req,
158  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
159  xmlNode ** answer);
160 
161 int cib_process_create(const char *op, int options, const char *section, xmlNode * req,
162  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
163  xmlNode ** answer);
164 
165 int cib_process_modify(const char *op, int options, const char *section, xmlNode * req,
166  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
167  xmlNode ** answer);
168 
169 int cib_process_delete(const char *op, int options, const char *section, xmlNode * req,
170  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
171  xmlNode ** answer);
172 
173 int cib_process_diff(const char *op, int options, const char *section, xmlNode * req,
174  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
175  xmlNode ** answer);
176 
177 int cib_process_upgrade(const char *op, int options, const char *section, xmlNode * req,
178  xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib,
179  xmlNode ** answer);
180 
203 int cib_process_xpath(const char *op, int options, const char *section,
204  const xmlNode *req, xmlNode *input, xmlNode *existing_cib,
205  xmlNode **result_cib, xmlNode ** answer);
206 
207 bool cib__config_changed_v1(xmlNode *last, xmlNode *next, xmlNode **diff);
208 
209 int cib_internal_op(cib_t * cib, const char *op, const char *host,
210  const char *section, xmlNode * data,
211  xmlNode ** output_data, int call_options, const char *user_name);
212 
213 
214 int cib_file_read_and_verify(const char *filename, const char *sigfile,
215  xmlNode **root);
216 int cib_file_write_with_digest(xmlNode *cib_root, const char *cib_dirname,
217  const char *cib_filename);
218 
219 void cib__set_output(cib_t *cib, pcmk__output_t *out);
220 
222 
244 int cib__signon_query(pcmk__output_t *out, cib_t **cib, xmlNode **cib_object);
245 
247 
248 int cib__update_node_attr(pcmk__output_t *out, cib_t *cib, int call_options,
249  const char *section, const char *node_uuid, const char *set_type,
250  const char *set_name, const char *attr_id, const char *attr_name,
251  const char *attr_value, const char *user_name,
252  const char *node_type);
253 
254 int cib__get_node_attrs(pcmk__output_t *out, cib_t *cib, const char *section,
255  const char *node_uuid, const char *set_type, const char *set_name,
256  const char *attr_id, const char *attr_name, const char *user_name,
257  xmlNode **result);
258 
259 int cib__delete_node_attr(pcmk__output_t *out, cib_t *cib, int options,
260  const char *section, const char *node_uuid, const char *set_type,
261  const char *set_name, const char *attr_id, const char *attr_name,
262  const char *attr_value, const char *user_name);
263 
264 #endif
pcmk__cpg_host_t host
Definition: cpg.c:49
char data[0]
Definition: cpg.c:55
int cib__signon_query(pcmk__output_t *out, cib_t **cib, xmlNode **cib_object)
Definition: cib_utils.c:745
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:284
The alerts section has changed.
Definition: internal.h:81
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:171
void(* callback)(const char *event, xmlNode *msg)
Definition: internal.h:95
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:104
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:156
The nodes section has changed.
Definition: internal.h:80
struct cib_notify_client_s cib_notify_client_t
int cib__delete_node_attr(pcmk__output_t *out, cib_t *cib, int options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, const char *user_name)
Definition: cib_attrs.c:370
int call_id
Definition: internal.h:109
gboolean only_success
Definition: internal.h:103
cib_callback_client_t * cib__lookup_id(int call_id)
Definition: cib_client.c:747
void cib_native_notify(gpointer data, gpointer user_data)
Definition: cib_utils.c:549
int cib__get_node_attrs(pcmk__output_t *out, cib_t *cib, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *user_name, xmlNode **result)
Definition: cib_attrs.c:344
const char * obj_id
Definition: internal.h:93
The status section has changed.
Definition: internal.h:82
cib_t * cib_new_variant(void)
Definition: cib_client.c:595
int timeout
Definition: internal.h:110
struct timer_rec_s * timer
Definition: internal.h:104
Formatted output for pacemaker tools.
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:636
int(* cib_op_t)(const char *, int, const char *, xmlNode *, xmlNode *, xmlNode *, xmlNode **, xmlNode **)
Definition: internal.h:127
void(* callback)(xmlNode *, int, int, xmlNode *, void *)
Definition: internal.h:100
guint ref
Definition: internal.h:111
const char * event
Definition: internal.h:92
void cib__set_output(cib_t *cib, pcmk__output_t *out)
Definition: cib_remote.c:628
int cib__clean_up_connection(cib_t **cib)
Definition: cib_utils.c:799
xmlNode * cib_create_op(int call_id, const char *op, const char *host, const char *section, xmlNode *data, int call_options, const char *user_name)
Definition: cib_utils.c:468
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:789
gboolean cib_read_config(GHashTable *options, xmlNode *current_cib)
Definition: cib_utils.c:630
int cib_file_read_and_verify(const char *filename, const char *sigfile, xmlNode **root)
Definition: cib_file.c:615
pcmk__action_result_t result
Definition: pcmk_fence.c:35
const char * obj_type
Definition: internal.h:94
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:61
Cluster Configuration.
xmlNode * input
node_type
Definition: pe_types.h:87
const char * id
Definition: internal.h:101
cib_change_section_info
Definition: internal.h:78
cib_t * cib
Definition: internal.h:112
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:145
int cib__update_node_attr(pcmk__output_t *out, cib_t *cib, int call_options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, const char *user_name, const char *node_type)
Definition: cib_attrs.c:173
bool cib__config_changed_v1(xmlNode *last, xmlNode *next, xmlNode **diff)
Definition: cib_ops.c:656
int cib_process_xpath(const char *op, int options, const char *section, const xmlNode *req, xmlNode *input, xmlNode *existing_cib, xmlNode **result_cib, xmlNode **answer)
Definition: cib_ops.c:727
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
Definition: cib_utils.c:500
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:657
void(* free_func)(void *)
Definition: internal.h:105
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:121
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:319
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:570
No sections have changed.
Definition: internal.h:79