33typedef struct cib_native_opaque_s {
36 void (*dnotify_fn) (gpointer user_data);
41cib_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,
98 rc = -ENOMSG;
goto done);
105 if (reply_id == cib->
call_id) {
110 crm_trace(
"Synchronous reply %d received", reply_id);
121 }
else if (reply_id <= 0) {
122 crm_err(
"Received bad reply: No id set");
128 crm_err(
"Received bad reply: %d (wanted %d)", reply_id, cib->
call_id);
137 }
else if (rc ==
pcmk_ok && op_reply == NULL) {
168 crm_err(
"The CIB manager disconnected");
178cib_native_dispatch_internal(
const char *buffer, ssize_t length,
181 const char *
type = NULL;
184 cib_t *cib = userdata;
196 crm_warn(
"Received a NULL message from the CIB manager");
220cib_native_destroy(
void *userdata)
222 cib_t *cib = userdata;
227 native->source = NULL;
230 if (native->dnotify_fn) {
231 native->dnotify_fn(userdata);
236cib_native_signoff(
cib_t *cib)
240 crm_debug(
"Disconnecting from the CIB manager");
245 if (native->source != NULL) {
248 native->source = NULL;
251 }
else if (native->ipc) {
272 const char *channel = NULL;
274 xmlNode *hello = NULL;
277 .
dispatch = cib_native_dispatch_internal,
278 .destroy = cib_native_destroy
299 crm_trace(
"Connecting %s channel", channel);
301 if (async_fd != NULL) {
303 if (native->ipc != NULL) {
308 crm_info(
"Couldn't get file descriptor for %s IPC",
323 crm_info(
"Could not connect to CIB manager for %s",
name);
333 xmlNode *reply = NULL;
342 crm_info(
"Reply to CIB registration message has unknown type "
350 if (native->token == NULL) {
363 crm_info(
"Successfully connected to CIB manager for %s",
name);
367 crm_info(
"Connection to CIB manager for %s failed: %s",
369 cib_native_signoff(cib);
376 return cib_native_signon_raw(cib,
name,
type, NULL);
380cib_native_free(
cib_t *cib)
385 rc = cib_native_signoff(cib);
402cib_native_register_notification(
cib_t *cib,
const char *callback,
int enabled)
415 crm_trace(
"Notification not registered: %d", rc);
425cib_native_set_connection_dnotify(
cib_t *cib,
426 void (*dnotify) (gpointer user_data))
436 native->dnotify_fn = dnotify;
460cib_native_client_id(
const cib_t *cib,
const char **async_id,
461 const char **sync_id)
465 if (async_id != NULL) {
466 *async_id = native->token;
468 if (sync_id != NULL) {
469 *sync_id = native->token;
486 if (native == NULL) {
495 native->source = NULL;
496 native->dnotify_fn = NULL;
int cib__extend_transaction(cib_t *cib, xmlNode *request)
void cib_native_callback(cib_t *cib, xmlNode *msg, int call_id, int rc)
cib_t * cib_new_variant(void)
#define PCMK__CIB_REQUEST_QUERY
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)
void cib_native_notify(gpointer data, gpointer user_data)
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
void cib_free_notify(cib_t *cib)
cib_t * cib_native_new(void)
struct cib_native_opaque_s cib_native_opaque_t
@ cib_command_nonblocking
@ cib_transaction
Process request when the client commits the active transaction.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
enum crm_ais_msg_types type
#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, const xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
Send an IPC XML message.
@ crm_ipc_client_response
bool crm_ipc_connected(crm_ipc_t *client)
void crm_ipc_close(crm_ipc_t *client)
struct crm_ipc_s crm_ipc_t
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
Create a new (legacy) object for using Pacemaker daemon IPC.
int pcmk__connect_generic_ipc(crm_ipc_t *ipc)
int pcmk__ipc_fd(crm_ipc_t *ipc, int *fd)
#define pcmk__set_ipc_flags(ipc_flags, ipc_name, flags_to_set)
#define PCMK__IPC_TIMEOUT
#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.
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
struct mainloop_io_s mainloop_io_t
void mainloop_del_ipc_client(mainloop_io_t *client)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer 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.
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(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK__VALUE_CIB_NOTIFY
const char * pcmk_strerror(int rc)
int pcmk_rc2legacy(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(* end_transaction)(cib_t *cib, bool commit, int call_options)
End and optionally commit this client's CIB transaction.
int(* signon)(cib_t *cib, const char *name, enum cib_conn_type type)
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)
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)
Dispatch function for an IPC connection used as mainloop source.
Wrappers for and extensions to libxml2.
void free_xml(xmlNode *child)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
xmlNode * pcmk__xml_parse(const char *input)
#define PCMK__XA_CIB_NOTIFY_ACTIVATE
#define PCMK__XA_CIB_NOTIFY_TYPE
#define PCMK__XA_CIB_CALLID
#define PCMK__XA_CIB_CLIENTID
#define PCMK__XE_CIB_CALLDATA
#define PCMK__XE_CIB_CALLBACK