28 const char *
name = NULL;
42 data->data.pairs = g_list_prepend(
data->data.pairs, pair);
64 const char *value = NULL;
71 if (pcmk__str_eq((
const char *) reply->name,
"ack",
pcmk__str_none)) {
77 if (pcmk__str_empty(value)
79 crm_info(
"Unrecognizable message from attribute manager: " 80 "message type '%s' not '" T_ATTRD "'", pcmk__s(value,
""));
96 set_pairs_data(&reply_data, reply);
99 crm_info(
"Unrecognizable message from attribute manager: " 100 "message subtype '%s' unknown", pcmk__s(value,
""));
110 g_list_free_full(reply_data.
data.
pairs, free);
140 create_attrd_op(
const char *user_name)
172 connect_and_send_attrd_request(
pcmk_ipc_api_t *api, xmlNode *request)
178 crm_info(
"Connecting to cluster... %d retries remaining", max);
184 }
else if (rc == EAGAIN || rc == EALREADY) {
204 const char *resource,
const char *operation,
205 const char *interval_spec,
const char *user_name,
209 xmlNode *request = create_attrd_op(user_name);
210 const char *interval_desc = NULL;
211 const char *op_desc = NULL;
227 rc = create_api(&api);
232 rc = connect_and_send_attrd_request(api, request);
236 rc = connect_and_send_attrd_request(api, request);
239 rc = send_attrd_request(api, request);
245 interval_desc = interval_spec? interval_spec :
"nonrecurring";
248 interval_desc =
"all";
249 op_desc =
"operations";
252 crm_debug(
"Asked pacemaker-attrd to clear failure of %s %s for %s on %s: %s (%d)",
253 interval_desc, op_desc, (resource? resource :
"all resources"),
263 const char *
target = NULL;
286 xmlNode *request = NULL;
287 const char *display_host = (node ? node :
"localhost");
294 request = create_attrd_op(NULL);
300 rc = create_api(&api);
305 rc = connect_and_send_attrd_request(api, request);
309 rc = connect_and_send_attrd_request(api, request);
312 rc = send_attrd_request(api, request);
317 crm_debug(
"Asked pacemaker-attrd to purge %s: %s (%d)",
328 xmlNode *request = NULL;
329 const char *
target = NULL;
345 request = create_attrd_op(NULL);
351 rc = send_attrd_request(api, request);
355 crm_debug(
"Queried pacemaker-attrd for %s on %s: %s (%d)",
358 crm_debug(
"Queried pacemaker-attrd for %s: %s (%d)",
369 xmlNode *request = NULL;
370 const char *display_host = (node ? node :
"localhost");
377 request = create_attrd_op(NULL);
383 rc = create_api(&api);
388 rc = connect_and_send_attrd_request(api, request);
392 rc = connect_and_send_attrd_request(api, request);
395 rc = send_attrd_request(api, request);
400 crm_debug(
"Asked pacemaker-attrd to refresh %s: %s (%d)",
407 add_op_attr(xmlNode *op, uint32_t options)
419 populate_update_op(xmlNode *op,
const char *node,
const char *
name,
const char *value,
420 const char *dampen,
const char *
set, uint32_t options)
434 add_op_attr(op, options);
454 const char *value,
const char *dampen,
const char *
set,
455 const char *user_name, uint32_t options)
458 xmlNode *request = NULL;
459 const char *display_host = (node ? node :
"localhost");
460 const char *
target = NULL;
472 request = create_attrd_op(user_name);
473 populate_update_op(request, node,
name, value, dampen,
set, options);
476 rc = create_api(&api);
481 rc = connect_and_send_attrd_request(api, request);
485 rc = connect_and_send_attrd_request(api, request);
488 rc = send_attrd_request(api, request);
493 crm_debug(
"Asked pacemaker-attrd to update %s on %s: %s (%d)",
501 const char *
set,
const char *user_name,
505 xmlNode *request = NULL;
533 for (GList *iter = attrs; iter != NULL; iter = iter->next) {
537 const char *
target = NULL;
538 xmlNode *child = NULL;
541 if (request == NULL) {
542 request = create_attrd_op(user_name);
543 add_op_attr(request, options);
558 populate_update_op(child, pair->
node, pair->
name, pair->
value, dampen,
562 dampen,
set, user_name, options);
570 bool created_api =
false;
573 rc = create_api(&api);
581 rc = connect_and_send_attrd_request(api, request);
#define PCMK__XA_ATTR_DAMPENING
#define PCMK__ATTRD_CMD_UPDATE_DELAY
int pcmk__attrd_api_query(pcmk_ipc_api_t *api, const char *node, const char *name, uint32_t options)
#define PCMK__XA_ATTR_NAME
#define PCMK__ATTRD_CMD_UPDATE_BOTH
const char * pcmk__node_attr_target(const char *name)
#define PCMK__ATTRD_CMD_PEER_REMOVE
int pcmk_connect_ipc(pcmk_ipc_api_t *api, enum pcmk_ipc_dispatch dispatch_type)
Connect to a Pacemaker daemon via IPC.
int pcmk__attrd_api_update_list(pcmk_ipc_api_t *api, GList *attrs, const char *dampen, const char *set, const char *user_name, uint32_t options)
#define XML_TAG_UTILIZATION
int pcmk__attrd_api_refresh(pcmk_ipc_api_t *api, const char *node)
int pcmk_new_ipc_api(pcmk_ipc_api_t **api, enum pcmk_ipc_server server)
Create a new object for using Pacemaker daemon IPC.
#define PCMK__XA_ATTR_SET_TYPE
xmlNode * first_named_child(const xmlNode *parent, const char *name)
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.
#define PCMK__XA_ATTR_VALUE
enum crm_exit_e crm_exit_t
#define PCMK__XA_ATTR_RESOURCE
#define PCMK__ATTRD_CMD_CLEAR_FAILURE
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
G_GNUC_INTERNAL void pcmk__call_ipc_callback(pcmk_ipc_api_t *api, enum pcmk_ipc_event event_type, crm_exit_t status, void *event_data)
int pcmk__attrd_api_clear_failures(pcmk_ipc_api_t *api, const char *node, const char *resource, const char *operation, const char *interval_spec, const char *user_name, uint32_t options)
int pcmk__attrd_api_update(pcmk_ipc_api_t *api, const char *node, const char *name, const char *value, const char *dampen, const char *set, const char *user_name, uint32_t options)
#define XML_TAG_ATTR_SETS
union pcmk__attrd_api_reply_t::@0 data
#define crm_debug(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__XA_ATTR_OPERATION
#define PCMK__ATTRD_CMD_REFRESH
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK__XA_ATTR_INTERVAL
#define PCMK__XA_ATTR_IS_PRIVATE
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define PCMK__XA_ATTR_USER
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, xmlNode *request)
#define PCMK__ATTRD_CMD_QUERY
#define PCMK__ATTRD_CMD_UPDATE
void free_xml(xmlNode *child)
int(* post_connect)(pcmk_ipc_api_t *api)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
enum pcmk__attrd_api_reply reply_type
int pcmk__attrd_api_purge(pcmk_ipc_api_t *api, const char *node)
const xmlChar * pcmkXmlStr
int(* new_data)(pcmk_ipc_api_t *api)
#define PCMK__XA_ATTR_SYNC_POINT
int pcmk__attrd_api_delete(pcmk_ipc_api_t *api, const char *node, const char *name, uint32_t options)
#define PCMK__XA_ATTR_NODE_NAME
bool(* dispatch)(pcmk_ipc_api_t *api, xmlNode *msg)
#define crm_err(fmt, args...)
Sending a command will wait for any reply.
void pcmk_free_ipc_api(pcmk_ipc_api_t *api)
Free the contents of an IPC API object.
#define PCMK__VALUE_CLUSTER
void(* free_data)(void *api_data)
#define PCMK__XA_ATTR_IS_REMOTE
bool(* reply_expected)(pcmk_ipc_api_t *api, xmlNode *request)
IPC interface to Pacemaker daemons.
pcmk__ipc_methods_t * pcmk__attrd_api_methods(void)
#define PCMK__XA_ATTR_PATTERN
void pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid)
Daemon's reply to client IPC request.
#define PCMK__XA_ATTR_SET
#define PCMK__VALUE_LOCAL
#define crm_info(fmt, args...)
void pcmk_disconnect_ipc(pcmk_ipc_api_t *api)
Disconnect an IPC API instance.
bool pcmk_ipc_is_connected(pcmk_ipc_api_t *api)
Check whether an IPC API connection is active.
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.