33 typedef struct cib_native_opaque_s {
36 void (*dnotify_fn) (gpointer user_data);
42 xmlNode *
data, xmlNode ** output_data,
int call_options);
45 const char *section, xmlNode *
data, xmlNode ** output_data,
46 int call_options,
const char *user_name);
69 native->source = NULL;
70 native->dnotify_fn = NULL;
92 cib_native_dispatch_internal(
const char *buffer, ssize_t length, gpointer userdata)
94 const char *
type = NULL;
97 cib_t *cib = userdata;
109 crm_warn(
"Received a NULL message from the CIB manager");
135 gboolean stay_connected = TRUE;
150 cib_native_dispatch_internal(msg, strlen(msg), cib);
155 stay_connected = FALSE;
159 return stay_connected;
163 cib_native_destroy(
void *userdata)
165 cib_t *cib = userdata;
170 native->source = NULL;
173 if (native->dnotify_fn) {
174 native->dnotify_fn(userdata);
182 const char *channel = NULL;
186 .
dispatch = cib_native_dispatch_internal,
187 .destroy = cib_native_destroy
208 crm_trace(
"Connecting %s channel", channel);
210 if (async_fd != NULL) {
216 }
else if (native->ipc) {
228 crm_info(
"Could not connect to CIB manager for %s",
name);
233 xmlNode *reply = NULL;
248 crm_info(
"Reply to CIB registration message has "
249 "unknown type '%s'", msg_type);
254 if (native->token == NULL) {
268 crm_info(
"Successfully connected to CIB manager for %s",
name);
272 crm_info(
"Connection to CIB manager for %s failed: %s",
283 crm_debug(
"Disconnecting from the CIB manager");
285 if (native->source != NULL) {
288 native->source = NULL;
291 }
else if (native->ipc) {
329 xmlNode *
data, xmlNode ** output_data,
int call_options)
332 data, output_data, call_options, NULL);
337 xmlNode *
data, xmlNode ** output_data,
int call_options,
338 const char *user_name)
344 xmlNode *op_msg = NULL;
345 xmlNode *op_reply = NULL;
353 if (output_data != NULL) {
358 crm_err(
"No operation specified");
380 if (op_msg == NULL) {
389 crm_err(
"Couldn't perform %s operation (timeout=%ds): %s (%d)", op,
406 if (reply_id == cib->
call_id) {
409 crm_trace(
"Synchronous reply %d received", reply_id);
417 }
else if (tmp != NULL) {
421 }
else if (reply_id <= 0) {
422 crm_err(
"Received bad reply: No id set");
428 crm_err(
"Received bad reply: %d (wanted %d)", reply_id, cib->
call_id);
437 }
else if (
rc ==
pcmk_ok && op_reply == NULL) {
468 crm_err(
"The CIB manager disconnected");
487 native->dnotify_fn = dnotify;
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
#define F_CIB_NOTIFY_TYPE
#define F_CIB_NOTIFY_ACTIVATE
cib_t * cib_new_variant(void)
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)
void cib_native_notify(gpointer data, gpointer user_data)
int cib_native_perform_op(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options)
int cib_native_perform_op_delegate(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options, const char *user_name)
int cib_native_signon_raw(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
cib_t * cib_native_new(void)
int cib_native_signon(cib_t *cib, const char *name, enum cib_conn_type type)
struct cib_native_opaque_s cib_native_opaque_t
bool cib_native_dispatch(cib_t *cib)
int cib_native_signoff(cib_t *cib)
int cib_native_register_notification(cib_t *cib, const char *callback, int enabled)
int cib_native_free(cib_t *cib)
int cib_native_set_connection_dnotify(cib_t *cib, void(*dnotify)(gpointer user_data))
@ cib_command_nonblocking
enum crm_ais_msg_types type
gboolean safe_str_neq(const char *a, const char *b)
#define safe_str_eq(a, b)
#define PCMK__SERVER_BASED_RO
#define PCMK__SERVER_BASED_RW
#define PCMK__SERVER_BASED_SHM
void crm_ipc_destroy(crm_ipc_t *client)
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Send an IPC XML message.
const char * crm_ipc_buffer(crm_ipc_t *client)
long crm_ipc_read(crm_ipc_t *client)
int crm_ipc_get_fd(crm_ipc_t *client)
@ crm_ipc_client_response
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
bool crm_ipc_connected(crm_ipc_t *client)
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
void crm_ipc_close(crm_ipc_t *client)
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
struct crm_ipc_s crm_ipc_t
#define crm_info(fmt, args...)
#define crm_warn(fmt, args...)
#define crm_log_xml_explicit(xml, text)
#define crm_log_xml_err(xml, text)
#define CRM_CHECK(expr, failure_action)
#define crm_debug(fmt, args...)
#define crm_err(fmt, args...)
#define crm_log_xml_trace(xml, text)
#define crm_trace(fmt, args...)
Wrappers for and extensions to glib mainloop.
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
struct mainloop_io_s mainloop_io_t
void mainloop_del_ipc_client(mainloop_io_t *client)
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
const char * pcmk_strerror(int rc)
#define pcmk_err_diff_resync
int(* set_connection_dnotify)(cib_t *cib, void(*dnotify)(gpointer user_data))
int(* signoff)(cib_t *cib)
int(* signon)(cib_t *cib, const char *name, enum cib_conn_type type)
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
int(* signon_raw)(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
cib_api_operations_t * cmds
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
xmlNode * copy_xml(xmlNode *src_node)
xmlNode * get_message_xml(xmlNode *msg, const char *field)
void free_xml(xmlNode *child)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
xmlNode * string2xml(const char *input)