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;
341 request = create_attrd_op(NULL);
347 rc = send_attrd_request(api, request);
351 crm_debug(
"Queried pacemaker-attrd for %s on %s: %s (%d)",
354 crm_debug(
"Queried pacemaker-attrd for %s: %s (%d)",
365 xmlNode *request = NULL;
366 const char *display_host = (node ? node :
"localhost");
373 request = create_attrd_op(NULL);
379 rc = create_api(&api);
384 rc = connect_and_send_attrd_request(api, request);
388 rc = connect_and_send_attrd_request(api, request);
391 rc = send_attrd_request(api, request);
396 crm_debug(
"Asked pacemaker-attrd to refresh %s: %s (%d)",
403 add_op_attr(xmlNode *op, uint32_t options)
415 populate_update_op(xmlNode *op,
const char *node,
const char *
name,
const char *value,
416 const char *dampen,
const char *
set, uint32_t options)
424 add_op_attr(op, options);
438 const char *value,
const char *dampen,
const char *
set,
439 const char *user_name, uint32_t options)
442 xmlNode *request = NULL;
443 const char *display_host = (node ? node :
"localhost");
444 const char *
target = NULL;
456 request = create_attrd_op(user_name);
457 populate_update_op(request, node,
name, value, dampen,
set, options);
460 rc = create_api(&api);
465 rc = connect_and_send_attrd_request(api, request);
469 rc = connect_and_send_attrd_request(api, request);
472 rc = send_attrd_request(api, request);
477 crm_debug(
"Asked pacemaker-attrd to update %s on %s: %s (%d)",
485 const char *
set,
const char *user_name,
489 xmlNode *request = NULL;
517 for (GList *iter = attrs; iter != NULL; iter = iter->next) {
521 const char *
target = NULL;
522 xmlNode *child = NULL;
525 if (request == NULL) {
526 request = create_attrd_op(user_name);
527 add_op_attr(request, options);
542 populate_update_op(child, pair->
node, pair->
name, pair->
value, dampen,
546 dampen,
set, user_name, options);
554 bool created_api =
false;
557 rc = create_api(&api);
565 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)
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.
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)
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)
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.
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 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.