15 #include <libxml/tree.h>
25 struct controld_api_private_s {
27 unsigned int replies_expected;
34 struct controld_api_private_s *
private = NULL;
36 api->
api_data = calloc(1,
sizeof(
struct controld_api_private_s));
50 private->client_uuid = pcmk__getpid_s();
62 free(((
struct controld_api_private_s *) data)->client_uuid);
73 struct controld_api_private_s *
private = api->
api_data;
92 #define xml_true(xml, field) crm_is_true(crm_element_value(xml, field))
98 if (msg_data == NULL) {
113 if (msg_data == NULL) {
137 node_info->
id = id_ll;
150 if (command == NULL) {
165 struct controld_api_private_s *
private = api->
api_data;
167 xmlNode *msg_data = NULL;
168 const char *value = NULL;
173 if (private->replies_expected > 0) {
174 private->replies_expected--;
187 crm_debug(
"Unrecognizable controller message: invalid message type '%s'",
194 crm_debug(
"Unrecognizable controller message: no reference");
201 crm_debug(
"Unrecognizable controller message: no command name");
216 set_node_info_data(&reply_data, msg_data);
223 set_ping_data(&reply_data, msg_data);
226 set_nodes_data(&reply_data, msg_data);
229 crm_debug(
"Unrecognizable controller message: unknown command '%s'",
239 g_list_free_full(reply_data.
data.
nodes, free);
271 const char *node, xmlNode *msg_data)
273 struct controld_api_private_s *
private = NULL;
274 const char *sys_to = NULL;
287 private->client_uuid);
293 bool reply_is_expected)
301 if ((rc ==
pcmk_rc_ok) && reply_is_expected) {
302 struct controld_api_private_s *
private = api->
api_data;
304 private->replies_expected++;
310 create_reprobe_message_data(
const char *target_node,
const char *router_node)
316 if ((router_node != NULL) && !pcmk__str_eq(router_node, target_node,
pcmk__str_casei)) {
334 const char *router_node)
343 if (router_node == NULL) {
344 router_node = target_node;
346 crm_debug(
"Sending %s IPC request to reprobe %s via %s",
349 msg_data = create_reprobe_message_data(target_node, router_node);
350 request = create_controller_request(api,
CRM_OP_REPROBE, router_node,
352 rc = send_controller_request(api, request,
true);
374 if (request == NULL) {
381 rc = send_controller_request(api, request,
true);
401 request = create_controller_request(api,
CRM_OP_PING, node_name, NULL);
402 if (request == NULL) {
405 rc = send_controller_request(api, request,
true);
426 if (request != NULL) {
427 rc = send_controller_request(api, request,
true);
453 if (request == NULL) {
456 rc = send_controller_request(api, request,
false);
479 request = create_controller_request(api,
CRM_OP_VOTE, NULL, NULL);
480 if (request == NULL) {
483 rc = send_controller_request(api, request,
false);
491 const char *target_node,
const char *router_node,
492 bool cib_only,
const char *rsc_id,
493 const char *rsc_long_id,
const char *standard,
494 const char *provider,
const char *
type)
498 xmlNode *request, *msg_data, *xml_rsc, *params;
503 if (router_node == NULL) {
504 router_node = target_node;
514 "xxxxxxxx-xrsc-opxx-xcrm-resourcexxxx");
543 request = create_controller_request(api, op, router_node, msg_data);
544 rc = send_controller_request(api, request,
true);
567 const char *target_node,
const char *router_node,
568 const char *rsc_id,
const char *rsc_long_id,
569 const char *standard,
const char *provider,
572 crm_debug(
"Sending %s IPC request to fail %s (a.k.a. %s) on %s via %s",
576 router_node,
false, rsc_id, rsc_long_id,
577 standard, provider, type);
598 const char *router_node,
599 const char *rsc_id,
const char *rsc_long_id,
600 const char *standard,
const char *provider,
601 const char *type,
bool cib_only)
603 crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
607 router_node, cib_only, rsc_id, rsc_long_id,
608 standard, provider, type);
621 struct controld_api_private_s *
private = api->
api_data;
623 return private->replies_expected;
634 const char *major_version,
const char *minor_version)
636 xmlNode *hello_node = NULL;
637 xmlNode *hello = NULL;
639 if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
640 || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
641 crm_err(
"Could not create IPC hello message from %s (UUID %s): "
642 "missing information",
643 client_name? client_name :
"unknown client",
644 uuid? uuid :
"unknown");
649 if (hello_node == NULL) {
650 crm_err(
"Could not create IPC hello message from %s (UUID %s): "
651 "Message data creation failed", client_name, uuid);
655 crm_xml_add(hello_node,
"major_version", major_version);
656 crm_xml_add(hello_node,
"minor_version", minor_version);
657 crm_xml_add(hello_node,
"client_name", client_name);
662 crm_err(
"Could not create IPC hello message from %s (UUID %s): "
663 "Request creation failed", client_name, uuid);
668 crm_trace(
"Created hello message from %s (UUID %s)", client_name, uuid);
void(* free_data)(void *api_data)
xmlNode * get_message_xml(xmlNode *msg, const char *field)
unsigned int pcmk_controld_api_replies_expected(pcmk_ipc_api_t *api)
Get the number of IPC replies currently expected from the controller.
enum pcmk_controld_api_reply reply_type
int(* new_data)(pcmk_ipc_api_t *api)
const char * host_from
Name of node that sent reply.
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.
int pcmk_controld_api_ping(pcmk_ipc_api_t *api, const char *node_name)
Ask the controller for status.
struct pcmk_controld_api_reply_t::@0::@1 node_info
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
void(* dispatch)(pcmk_ipc_api_t *api, xmlNode *msg)
enum crm_exit_e crm_exit_t
enum crm_ais_msg_types type
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
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.
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)
union pcmk_controld_api_reply_t::@0 data
struct pcmk_controld_api_reply_t::@0::@3 ping
#define PCMK__CONTROLD_API_MINOR
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 crm_debug(fmt, args...)
#define XML_PING_ATTR_STATUS
int pcmk_controld_api_start_election(pcmk_ipc_api_t *api)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
#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
#define XML_AGENT_ATTR_PROVIDER
#define XML_ATTR_HAVE_QUORUM
const char * pcmk_ipc_name(pcmk_ipc_api_t *api, bool for_log)
Get the IPC name used with an IPC API connection.
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, xmlNode *request)
#define XML_NODE_IS_REMOTE
#define XML_LRM_ATTR_ROUTER_NODE
void free_xml(xmlNode *child)
IPC commands for Pacemaker controller.
#define xml_true(xml, field)
#define XML_PING_ATTR_SYSFROM
int(* post_connect)(pcmk_ipc_api_t *api)
#define XML_ATTR_TRANSITION_KEY
bool(* reply_expected)(pcmk_ipc_api_t *api, xmlNode *request)
#define crm_err(fmt, args...)
#define XML_ATTR_REFERENCE
#define XML_ATTR_RESPONSE
#define XML_ATTR_CRM_VERSION
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define CRM_OP_INVOKE_LRM
IPC interface to Pacemaker daemons.
struct pcmk_controld_api_reply_t::@0::@2 resource
int pcmk_controld_api_reprobe(pcmk_ipc_api_t *api, const char *target_node, const char *router_node)
Send a reprobe controller operation.
G_GNUC_INTERNAL pcmk__ipc_methods_t * pcmk__controld_api_methods(void)
#define XML_NODE_IN_CLUSTER
int pcmk_controld_api_list_nodes(pcmk_ipc_api_t *api)
Ask the controller for cluster information.
#define PCMK__CONTROLD_CMD_NODES
#define XML_LRM_ATTR_TARGET
Daemon's reply to client IPC request.
int pcmk_controld_api_shutdown(pcmk_ipc_api_t *api, const char *node_name)
int pcmk_controld_api_node_info(pcmk_ipc_api_t *api, uint32_t nodeid)
Send a "node info" controller operation.
#define CRM_OP_LRM_DELETE
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
#define crm_info(fmt, args...)
#define XML_AGENT_ATTR_CLASS
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.