33 typedef struct cib_native_opaque_s {
36 void (*dnotify_fn) (gpointer user_data);
41 cib_native_perform_op_delegate(
cib_t *cib,
const char *op,
const char *
host,
42 const char *section, xmlNode *
data,
43 xmlNode **output_data,
int call_options,
44 const char *user_name)
50 xmlNode *op_msg = NULL;
51 xmlNode *op_reply = NULL;
59 if (output_data != NULL) {
64 crm_err(
"No operation specified");
87 crm_err(
"Couldn't perform %s operation (timeout=%ds): %s (%d)", op,
104 if (reply_id == cib->
call_id) {
107 crm_trace(
"Synchronous reply %d received", reply_id);
115 }
else if (tmp != NULL) {
119 }
else if (reply_id <= 0) {
120 crm_err(
"Received bad reply: No id set");
126 crm_err(
"Received bad reply: %d (wanted %d)", reply_id, cib->
call_id);
135 }
else if (rc ==
pcmk_ok && op_reply == NULL) {
166 crm_err(
"The CIB manager disconnected");
176 cib_native_dispatch_internal(
const char *buffer, ssize_t length,
179 const char *
type = NULL;
182 cib_t *cib = userdata;
194 crm_warn(
"Received a NULL message from the CIB manager");
218 cib_native_destroy(
void *userdata)
220 cib_t *cib = userdata;
225 native->source = NULL;
228 if (native->dnotify_fn) {
229 native->dnotify_fn(userdata);
234 cib_native_signoff(
cib_t *cib)
238 crm_debug(
"Disconnecting from the CIB manager");
243 if (native->source != NULL) {
246 native->source = NULL;
249 }
else if (native->ipc) {
270 const char *channel = NULL;
272 xmlNode *hello = NULL;
275 .
dispatch = cib_native_dispatch_internal,
276 .destroy = cib_native_destroy
297 crm_trace(
"Connecting %s channel", channel);
299 if (async_fd != NULL) {
301 if (native->ipc != NULL) {
306 crm_info(
"Couldn't get file descriptor for %s IPC",
321 crm_info(
"Could not connect to CIB manager for %s",
name);
331 xmlNode *reply = NULL;
340 crm_info(
"Reply to CIB registration message has unknown type " 347 if (native->token == NULL) {
360 crm_info(
"Successfully connected to CIB manager for %s",
name);
364 crm_info(
"Connection to CIB manager for %s failed: %s",
366 cib_native_signoff(cib);
373 return cib_native_signon_raw(cib,
name,
type, NULL);
377 cib_native_free(
cib_t *cib)
382 rc = cib_native_signoff(cib);
399 cib_native_register_notification(
cib_t *cib,
const char *callback,
int enabled)
412 crm_trace(
"Notification not registered: %d", rc);
422 cib_native_set_connection_dnotify(
cib_t *cib,
423 void (*dnotify) (gpointer user_data))
433 native->dnotify_fn = dnotify;
457 cib_native_client_id(
const cib_t *cib,
const char **async_id,
458 const char **sync_id)
462 if (async_id != NULL) {
463 *async_id = native->token;
465 if (sync_id != NULL) {
466 *sync_id = native->token;
483 if (native == NULL) {
492 native->source = NULL;
493 native->dnotify_fn = NULL;
#define CRM_CHECK(expr, failure_action)
#define PCMK__SERVER_BASED_RW
const char * pcmk_strerror(int rc)
int pcmk_rc2legacy(int rc)
int(* signoff)(cib_t *cib)
#define PCMK__CIB_REQUEST_QUERY
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
struct mainloop_io_s mainloop_io_t
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
int(* signon_raw)(cib_t *cib, const char *name, enum cib_conn_type type, int *event_fd)
void cib_free_notify(cib_t *cib)
enum crm_ais_msg_types type
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Wrappers for and extensions to glib mainloop.
xmlNode * string2xml(const char *input)
#define F_CIB_NOTIFY_ACTIVATE
int pcmk__connect_generic_ipc(crm_ipc_t *ipc)
void cib_native_notify(gpointer data, gpointer user_data)
xmlNode * copy_xml(xmlNode *src_node)
cib_t * cib_new_variant(void)
int(* set_connection_dnotify)(cib_t *cib, void(*dnotify)(gpointer user_data))
#define crm_warn(fmt, args...)
cib_api_operations_t * cmds
#define crm_debug(fmt, args...)
struct crm_ipc_s crm_ipc_t
int(* signon)(cib_t *cib, const char *name, enum cib_conn_type type)
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define crm_trace(fmt, args...)
#define crm_log_xml_explicit(xml, text)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define PCMK__IPC_TIMEOUT
void mainloop_del_ipc_client(mainloop_io_t *client)
void crm_ipc_destroy(crm_ipc_t *client)
void free_xml(xmlNode *child)
#define PCMK__SERVER_BASED_RO
int cib__create_op(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, int call_options, const char *user_name, const char *client_name, xmlNode **op_msg)
xmlNode * get_message_xml(const xmlNode *msg, const char *field)
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
#define F_CIB_NOTIFY_TYPE
bool crm_ipc_connected(crm_ipc_t *client)
#define pcmk_err_diff_resync
#define crm_log_xml_err(xml, text)
int(* end_transaction)(cib_t *cib, bool commit, int call_options)
End and optionally commit this client's CIB transaction.
#define pcmk__set_ipc_flags(ipc_flags, ipc_name, flags_to_set)
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
#define crm_err(fmt, args...)
struct cib_native_opaque_s cib_native_opaque_t
int cib__extend_transaction(cib_t *cib, xmlNode *request)
int pcmk__ipc_fd(crm_ipc_t *ipc, int *fd)
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Create a new (legacy) object for using Pacemaker daemon IPC.
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
#define crm_log_xml_trace(xml, text)
#define PCMK__SERVER_BASED_SHM
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
int crm_ipc_send(crm_ipc_t *client, const xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Send an IPC XML message.
void crm_ipc_close(crm_ipc_t *client)
int(* client_id)(const cib_t *cib, const char **async_id, const char **sync_id)
Get the given CIB connection's unique client identifier(s)
#define crm_info(fmt, args...)
Process request when the client commits the active transaction.
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
Dispatch function for an IPC connection used as mainloop source.
cib_t * cib_native_new(void)