29 typedef struct cib_native_opaque_s {
32 void (*dnotify_fn) (gpointer user_data);
37 cib_native_perform_op_delegate(
cib_t *cib,
const char *op,
const char *
host,
38 const char *section, xmlNode *
data,
39 xmlNode **output_data,
int call_options,
40 const char *user_name)
46 xmlNode *op_msg = NULL;
47 xmlNode *op_reply = NULL;
55 if (output_data != NULL) {
60 crm_err(
"No operation specified");
83 crm_err(
"Couldn't perform %s operation (timeout=%ds): %s (%d)", op,
94 rc = -ENOMSG;
goto done);
101 if (reply_id == cib->
call_id) {
106 crm_trace(
"Synchronous reply %d received", reply_id);
117 }
else if (reply_id <= 0) {
118 crm_err(
"Received bad reply: No id set");
124 crm_err(
"Received bad reply: %d (wanted %d)", reply_id, cib->
call_id);
133 }
else if (rc ==
pcmk_ok && op_reply == NULL) {
164 crm_err(
"The CIB manager disconnected");
174 cib_native_dispatch_internal(
const char *buffer, ssize_t length,
177 const char *
type = NULL;
180 cib_t *cib = userdata;
192 crm_warn(
"Received a NULL message from the CIB manager");
216 cib_native_destroy(
void *userdata)
218 cib_t *cib = userdata;
223 native->source = NULL;
226 if (native->dnotify_fn) {
227 native->dnotify_fn(userdata);
232 cib_native_signoff(
cib_t *cib)
236 crm_debug(
"Disconnecting from the CIB manager");
241 if (native->source != NULL) {
244 native->source = NULL;
247 }
else if (native->ipc) {
267 const char *channel = NULL;
269 xmlNode *hello = NULL;
272 .
dispatch = cib_native_dispatch_internal,
273 .destroy = cib_native_destroy
298 crm_trace(
"Connecting %s channel", channel);
301 512 * 1024, cib, &cib_callbacks);
305 crm_info(
"Could not connect to CIB manager for %s",
name);
315 xmlNode *reply = NULL;
324 crm_info(
"Reply to CIB registration message has unknown type " 332 if (native->token == NULL) {
345 crm_info(
"Successfully connected to CIB manager for %s",
name);
349 crm_info(
"Connection to CIB manager for %s failed: %s",
351 cib_native_signoff(cib);
356 cib_native_free(
cib_t *cib)
361 rc = cib_native_signoff(cib);
378 cib_native_register_notification(
cib_t *cib,
const char *callback,
int enabled)
391 crm_trace(
"Notification not registered: %d", rc);
401 cib_native_set_connection_dnotify(
cib_t *cib,
402 void (*dnotify) (gpointer user_data))
412 native->dnotify_fn = dnotify;
436 cib_native_client_id(
const cib_t *cib,
const char **async_id,
437 const char **sync_id)
441 if (async_id != NULL) {
442 *async_id = native->token;
444 if (sync_id != NULL) {
445 *sync_id = native->token;
462 if (native == NULL) {
471 native->source = NULL;
472 native->dnotify_fn = NULL;
#define CRM_CHECK(expr, failure_action)
#define PCMK__SERVER_BASED_RW
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)
const char * pcmk_strerror(int rc)
#define PCMK__XE_CIB_CALLBACK
enum pcmk_ipc_server type
#define PCMK__XA_CIB_CLIENTID
int(* signoff)(cib_t *cib)
#define PCMK__CIB_REQUEST_QUERY
struct mainloop_io_s mainloop_io_t
void remove_cib_op_callback(int call_id, gboolean all_callbacks)
void cib_free_notify(cib_t *cib)
#define PCMK__XA_CIB_NOTIFY_TYPE
Wrappers for and extensions to glib mainloop.
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
void pcmk__xml_free(xmlNode *xml)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
void cib_native_notify(gpointer data, gpointer user_data)
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.
#define PCMK__XE_CIB_CALLDATA
Wrappers for and extensions to libxml2.
#define PCMK__IPC_TIMEOUT
void mainloop_del_ipc_client(mainloop_io_t *client)
void crm_ipc_destroy(crm_ipc_t *client)
#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 * pcmk__xml_parse(const char *input)
int(* register_notification)(cib_t *cib, const char *callback, int enabled)
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 crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
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)
#define PCMK__XA_CIB_NOTIFY_ACTIVATE
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 PCMK__XA_CIB_CALLID
#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)
#define PCMK__VALUE_CIB_NOTIFY
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.