15 #include <libxml/tree.h> 25 struct controld_api_private_s {
27 unsigned int replies_expected;
61 struct controld_api_private_s *
private = NULL;
63 api->
api_data = calloc(1,
sizeof(
struct controld_api_private_s));
77 private->client_uuid = pcmk__getpid_s();
89 free(((
struct controld_api_private_s *)
data)->client_uuid);
100 struct controld_api_private_s *
private = api->
api_data;
123 if (msg_data == NULL) {
145 if (msg_data == NULL) {
169 node_info->
id = id_ll;
173 data->data.nodes = g_list_prepend(
data->data.nodes, node_info);
195 struct controld_api_private_s *
private = api->
api_data;
197 xmlNode *msg_data = NULL;
198 const char *value = NULL;
203 if (pcmk__xe_is(reply,
"ack")) {
208 return private->replies_expected > 0;
211 if (private->replies_expected > 0) {
212 private->replies_expected--;
223 if (pcmk__str_empty(value)
225 crm_info(
"Unrecognizable message from controller: " 226 "invalid message type '%s'", pcmk__s(value,
""));
232 crm_info(
"Unrecognizable message from controller: no reference");
238 if (pcmk__str_empty(value)) {
239 crm_info(
"Unrecognizable message from controller: no command name");
254 set_node_info_data(&reply_data, msg_data);
261 set_ping_data(&reply_data, msg_data);
264 set_nodes_data(&reply_data, msg_data);
267 crm_info(
"Unrecognizable message from controller: unknown command '%s'",
277 g_list_free_full(reply_data.
data.
nodes, free);
310 create_controller_request(
const pcmk_ipc_api_t *api,
const char *op,
311 const char *node, xmlNode *msg_data)
313 struct controld_api_private_s *
private = NULL;
314 const char *sys_to = NULL;
327 private->client_uuid);
332 send_controller_request(
pcmk_ipc_api_t *api,
const xmlNode *request,
333 bool reply_is_expected)
338 if (reply_is_expected) {
339 struct controld_api_private_s *
private = api->
api_data;
341 private->replies_expected++;
347 create_reprobe_message_data(
const char *target_node,
const char *router_node)
353 if ((router_node != NULL) && !pcmk__str_eq(router_node, target_node,
pcmk__str_casei)) {
371 const char *router_node)
380 if (router_node == NULL) {
381 router_node = target_node;
383 crm_debug(
"Sending %s IPC request to reprobe %s via %s",
384 pcmk_ipc_name(api,
true), pcmk__s(target_node,
"local node"),
385 pcmk__s(router_node,
"local node"));
386 msg_data = create_reprobe_message_data(target_node, router_node);
387 request = create_controller_request(api,
CRM_OP_REPROBE, router_node,
389 rc = send_controller_request(api, request,
true);
411 if (request == NULL) {
418 rc = send_controller_request(api, request,
true);
438 request = create_controller_request(api,
CRM_OP_PING, node_name, NULL);
439 if (request == NULL) {
442 rc = send_controller_request(api, request,
true);
463 if (request != NULL) {
464 rc = send_controller_request(api, request,
true);
473 const char *target_node,
const char *router_node,
474 bool cib_only,
const char *rsc_id,
475 const char *rsc_long_id,
const char *standard,
476 const char *provider,
const char *
type)
480 xmlNode *request, *msg_data, *xml_rsc, *params;
485 if (router_node == NULL) {
486 router_node = target_node;
496 "xxxxxxxx-xrsc-opxx-xcrm-resourcexxxx");
525 request = create_controller_request(api, op, router_node, msg_data);
526 rc = send_controller_request(api, request,
true);
549 const char *target_node,
const char *router_node,
550 const char *rsc_id,
const char *rsc_long_id,
551 const char *standard,
const char *provider,
554 crm_debug(
"Sending %s IPC request to fail %s (a.k.a. %s) on %s via %s",
555 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
556 pcmk__s(rsc_long_id,
"no other names"),
557 pcmk__s(target_node,
"unspecified node"),
558 pcmk__s(router_node,
"unspecified node"));
560 router_node,
false, rsc_id, rsc_long_id,
561 standard, provider,
type);
582 const char *router_node,
583 const char *rsc_id,
const char *rsc_long_id,
584 const char *standard,
const char *provider,
585 const char *
type,
bool cib_only)
587 crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
588 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
589 pcmk__s(rsc_long_id,
"no other names"),
590 pcmk__s(target_node,
"unspecified node"),
591 pcmk__s(router_node,
"unspecified node"));
593 router_node, cib_only, rsc_id, rsc_long_id,
594 standard, provider,
type);
607 struct controld_api_private_s *
private = api->
api_data;
609 return private->replies_expected;
620 const char *major_version,
const char *minor_version)
622 xmlNode *hello_node = NULL;
623 xmlNode *hello = NULL;
625 if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
626 || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
627 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 628 "missing information",
629 client_name? client_name :
"unknown client",
630 uuid? uuid :
"unknown");
635 if (hello_node == NULL) {
636 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 637 "Message data creation failed", client_name, uuid);
641 crm_xml_add(hello_node,
"major_version", major_version);
642 crm_xml_add(hello_node,
"minor_version", minor_version);
643 crm_xml_add(hello_node,
"client_name", client_name);
648 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 649 "Request creation failed", client_name, uuid);
654 crm_trace(
"Created hello message from %s (UUID %s)", client_name, uuid);
union pcmk_controld_api_reply_t::@1 data
enum pcmk_controld_api_reply reply_type
int pcmk_controld_api_reprobe(pcmk_ipc_api_t *api, const char *target_node, const char *router_node)
Send a reprobe controller operation.
const char * host_from
Name of node that sent reply.
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define PCMK__CONTROLD_API_MAJOR
#define XML_PING_ATTR_CRMDSTATE
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_GRAPH_TAG_RSC_OP
enum crm_exit_e crm_exit_t
bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name)
enum crm_ais_msg_types type
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest)
Retrieve the long long integer 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.
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)
char * crm_meta_name(const char *field)
#define PCMK__CONTROLD_API_MINOR
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define crm_debug(fmt, args...)
struct pcmk_controld_api_reply_t::@1::@3 resource
#define XML_PING_ATTR_STATUS
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
xmlNode * create_hello_message(const char *uuid, const char *client_name, const char *major_version, const char *minor_version)
Create XML for a controller IPC "hello" message.
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, const xmlNode *request)
#define crm_trace(fmt, args...)
const char * feature_set
CRM feature set advertised by controller.
void crm_xml_set_id(xmlNode *xml, const char *format,...) G_GNUC_PRINTF(2
pcmk__ipc_methods_t * pcmk__controld_api_methods(void)
#define XML_AGENT_ATTR_PROVIDER
#define XML_ATTR_HAVE_QUORUM
Wrappers for and extensions to libxml2.
int pcmk_controld_api_refresh(pcmk_ipc_api_t *api, const char *target_node, const char *router_node, const char *rsc_id, const char *rsc_long_id, const char *standard, const char *provider, const char *type, bool cib_only)
Ask the controller to refresh a resource.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_NODE_IS_REMOTE
#define XML_LRM_ATTR_ROUTER_NODE
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
xmlNode * get_message_xml(const xmlNode *msg, const char *field)
IPC commands for Pacemaker controller.
int pcmk_controld_api_list_nodes(pcmk_ipc_api_t *api)
Ask the controller for cluster information.
#define XML_PING_ATTR_SYSFROM
#define XML_ATTR_TRANSITION_KEY
int(* new_data)(pcmk_ipc_api_t *api)
#define CRM_OP_RM_NODE_CACHE
int pcmk_controld_api_node_info(pcmk_ipc_api_t *api, uint32_t nodeid)
Send a "node info" controller operation.
bool(* dispatch)(pcmk_ipc_api_t *api, xmlNode *msg)
bool(* reply_expected)(pcmk_ipc_api_t *api, const xmlNode *request)
int pcmk_controld_api_ping(pcmk_ipc_api_t *api, const char *node_name)
Ask the controller for status.
#define crm_err(fmt, args...)
#define XML_ATTR_REFERENCE
void(* free_data)(void *api_data)
const char * pcmk_ipc_name(const pcmk_ipc_api_t *api, bool for_log)
Get the IPC name used with an IPC API connection.
#define XML_ATTR_RESPONSE
unsigned int pcmk_controld_api_replies_expected(const pcmk_ipc_api_t *api)
Get the number of IPC replies currently expected from the controller.
#define XML_ATTR_CRM_VERSION
#define CRM_OP_INVOKE_LRM
const char * pcmk__controld_api_reply2str(enum pcmk_controld_api_reply reply)
IPC interface to Pacemaker daemons.
#define PCMK__CONTROLD_CMD_NODES
#define XML_LRM_ATTR_TARGET
Daemon's reply to client IPC request.
#define CRM_OP_LRM_DELETE
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
#define crm_info(fmt, args...)
int pcmk_controld_api_fail(pcmk_ipc_api_t *api, const char *target_node, const char *router_node, const char *rsc_id, const char *rsc_long_id, const char *standard, const char *provider, const char *type)
Ask the controller to fail a resource.
#define XML_AGENT_ATTR_CLASS
pcmk_controld_api_reply
Possible types of controller replies.
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.