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;
96 if (msg_data == NULL) {
111 if (msg_data == NULL) {
135 node_info->
id = id_ll;
139 data->data.nodes = g_list_prepend(
data->data.nodes, node_info);
148 if (command == NULL) {
163 struct controld_api_private_s *
private = api->
api_data;
165 xmlNode *msg_data = NULL;
166 const char *value = NULL;
185 if (pcmk__str_eq(crm_element_name(reply),
"ack",
pcmk__str_none)) {
189 if (private->replies_expected > 0) {
190 private->replies_expected--;
203 crm_debug(
"Unrecognizable controller message: invalid message type '%s'",
210 crm_debug(
"Unrecognizable controller message: no reference");
217 crm_debug(
"Unrecognizable controller message: no command name");
232 set_node_info_data(&reply_data, msg_data);
239 set_ping_data(&reply_data, msg_data);
242 set_nodes_data(&reply_data, msg_data);
245 crm_debug(
"Unrecognizable controller message: unknown command '%s'",
255 g_list_free_full(reply_data.
data.
nodes, free);
289 const char *node, xmlNode *msg_data)
291 struct controld_api_private_s *
private = NULL;
292 const char *sys_to = NULL;
305 private->client_uuid);
311 bool reply_is_expected)
319 if ((rc ==
pcmk_rc_ok) && reply_is_expected) {
320 struct controld_api_private_s *
private = api->
api_data;
322 private->replies_expected++;
328 create_reprobe_message_data(
const char *target_node,
const char *router_node)
334 if ((router_node != NULL) && !pcmk__str_eq(router_node, target_node,
pcmk__str_casei)) {
352 const char *router_node)
361 if (router_node == NULL) {
362 router_node = target_node;
364 crm_debug(
"Sending %s IPC request to reprobe %s via %s",
367 msg_data = create_reprobe_message_data(target_node, router_node);
368 request = create_controller_request(api,
CRM_OP_REPROBE, router_node,
370 rc = send_controller_request(api, request,
true);
392 if (request == NULL) {
399 rc = send_controller_request(api, request,
true);
419 request = create_controller_request(api,
CRM_OP_PING, node_name, NULL);
420 if (request == NULL) {
423 rc = send_controller_request(api, request,
true);
444 if (request != NULL) {
445 rc = send_controller_request(api, request,
true);
454 const char *target_node,
const char *router_node,
455 bool cib_only,
const char *rsc_id,
456 const char *rsc_long_id,
const char *standard,
457 const char *provider,
const char *
type)
461 xmlNode *request, *msg_data, *xml_rsc, *params;
466 if (router_node == NULL) {
467 router_node = target_node;
477 "xxxxxxxx-xrsc-opxx-xcrm-resourcexxxx");
506 request = create_controller_request(api, op, router_node, msg_data);
507 rc = send_controller_request(api, request,
true);
530 const char *target_node,
const char *router_node,
531 const char *rsc_id,
const char *rsc_long_id,
532 const char *standard,
const char *provider,
535 crm_debug(
"Sending %s IPC request to fail %s (a.k.a. %s) on %s via %s",
539 router_node,
false, rsc_id, rsc_long_id,
540 standard, provider,
type);
561 const char *router_node,
562 const char *rsc_id,
const char *rsc_long_id,
563 const char *standard,
const char *provider,
564 const char *
type,
bool cib_only)
566 crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
570 router_node, cib_only, rsc_id, rsc_long_id,
571 standard, provider,
type);
584 struct controld_api_private_s *
private = api->
api_data;
586 return private->replies_expected;
597 const char *major_version,
const char *minor_version)
599 xmlNode *hello_node = NULL;
600 xmlNode *hello = NULL;
602 if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
603 || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
604 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 605 "missing information",
606 client_name? client_name :
"unknown client",
607 uuid? uuid :
"unknown");
612 if (hello_node == NULL) {
613 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 614 "Message data creation failed", client_name, uuid);
618 crm_xml_add(hello_node,
"major_version", major_version);
619 crm_xml_add(hello_node,
"minor_version", minor_version);
620 crm_xml_add(hello_node,
"client_name", client_name);
625 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 626 "Request creation failed", client_name, uuid);
631 crm_trace(
"Created hello message from %s (UUID %s)", client_name, uuid);
xmlNode * get_message_xml(xmlNode *msg, const char *field)
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
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)
union pcmk_controld_api_reply_t::@0 data
#define PCMK__CONTROLD_API_MINOR
#define crm_debug(fmt, args...)
#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.
unsigned int pcmk_controld_api_replies_expected(pcmk_ipc_api_t *api)
Get the number of IPC replies currently expected from the controller.
#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()
#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.
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)
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)
int(* post_connect)(pcmk_ipc_api_t *api)
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)
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)
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)
#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)
bool(* reply_expected)(pcmk_ipc_api_t *api, xmlNode *request)
#define CRM_OP_INVOKE_LRM
IPC interface to Pacemaker daemons.
struct pcmk_controld_api_reply_t::@0::@2 resource
#define XML_NODE_IN_CLUSTER
bool pcmk__xe_attr_is_true(xmlNodePtr node, const char *name)
#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
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.