15#include <libxml/tree.h>
24struct controld_api_private_s {
26 unsigned int replies_expected;
60 struct controld_api_private_s *
private = NULL;
62 api->
api_data = calloc(1,
sizeof(
struct controld_api_private_s));
76 private->client_uuid = pcmk__getpid_s();
88 free(((
struct controld_api_private_s *)
data)->client_uuid);
99 struct controld_api_private_s *
private = api->
api_data;
122 if (msg_data == NULL) {
125 data->data.node_info.have_quorum =
127 data->data.node_info.is_remote =
146 if (msg_data == NULL) {
171 node_info->
id = id_ll;
175 data->data.nodes = g_list_prepend(
data->data.nodes, node_info);
197 struct controld_api_private_s *
private = api->
api_data;
199 xmlNode *wrapper = NULL;
200 xmlNode *msg_data = NULL;
201 const char *value = NULL;
211 return private->replies_expected > 0;
214 if (private->replies_expected > 0) {
215 private->replies_expected--;
228 crm_info(
"Unrecognizable message from controller: "
229 "invalid message type '%s'", pcmk__s(value,
""));
235 crm_info(
"Unrecognizable message from controller: no reference");
241 if (pcmk__str_empty(value)) {
242 crm_info(
"Unrecognizable message from controller: no command name");
259 set_node_info_data(&reply_data, msg_data);
266 set_ping_data(&reply_data, msg_data);
269 set_nodes_data(&reply_data, msg_data);
272 crm_info(
"Unrecognizable message from controller: unknown command '%s'",
282 g_list_free_full(reply_data.
data.
nodes, free);
315create_controller_request(
const pcmk_ipc_api_t *api,
const char *op,
316 const char *node, xmlNode *msg_data)
318 struct controld_api_private_s *
private = NULL;
319 const char *sys_to = NULL;
332 private->client_uuid);
337send_controller_request(
pcmk_ipc_api_t *api,
const xmlNode *request,
338 bool reply_is_expected)
343 if (reply_is_expected) {
344 struct controld_api_private_s *
private = api->
api_data;
346 private->replies_expected++;
352create_reprobe_message_data(
const char *target_node,
const char *router_node)
358 if ((router_node != NULL) && !pcmk__str_eq(router_node, target_node,
pcmk__str_casei)) {
376 const char *router_node)
385 if (router_node == NULL) {
386 router_node = target_node;
388 crm_debug(
"Sending %s IPC request to reprobe %s via %s",
389 pcmk_ipc_name(api,
true), pcmk__s(target_node,
"local node"),
390 pcmk__s(router_node,
"local node"));
391 msg_data = create_reprobe_message_data(target_node, router_node);
392 request = create_controller_request(api,
CRM_OP_REPROBE, router_node,
394 rc = send_controller_request(api, request,
true);
416 if (request == NULL) {
423 rc = send_controller_request(api, request,
true);
443 request = create_controller_request(api,
CRM_OP_PING, node_name, NULL);
444 if (request == NULL) {
447 rc = send_controller_request(api, request,
true);
468 if (request != NULL) {
469 rc = send_controller_request(api, request,
true);
478 const char *target_node,
const char *router_node,
479 bool cib_only,
const char *rsc_id,
480 const char *rsc_long_id,
const char *standard,
481 const char *provider,
const char *
type)
485 xmlNode *request, *msg_data, *xml_rsc, *params;
490 if (router_node == NULL) {
491 router_node = target_node;
501 "xxxxxxxx-xrsc-opxx-xcrm-resourcexxxx");
530 request = create_controller_request(api, op, router_node, msg_data);
531 rc = send_controller_request(api, request,
true);
554 const char *target_node,
const char *router_node,
555 const char *rsc_id,
const char *rsc_long_id,
556 const char *standard,
const char *provider,
559 crm_debug(
"Sending %s IPC request to fail %s (a.k.a. %s) on %s via %s",
560 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
561 pcmk__s(rsc_long_id,
"no other names"),
562 pcmk__s(target_node,
"unspecified node"),
563 pcmk__s(router_node,
"unspecified node"));
565 router_node,
false, rsc_id, rsc_long_id,
566 standard, provider,
type);
587 const char *router_node,
588 const char *rsc_id,
const char *rsc_long_id,
589 const char *standard,
const char *provider,
590 const char *
type,
bool cib_only)
592 crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
593 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
594 pcmk__s(rsc_long_id,
"no other names"),
595 pcmk__s(target_node,
"unspecified node"),
596 pcmk__s(router_node,
"unspecified node"));
598 router_node, cib_only, rsc_id, rsc_long_id,
599 standard, provider,
type);
612 struct controld_api_private_s *
private = api->
api_data;
614 return private->replies_expected;
625 const char *major_version,
const char *minor_version)
627 xmlNode *hello_node = NULL;
628 xmlNode *hello = NULL;
630 if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
631 || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
632 crm_err(
"Could not create IPC hello message from %s (UUID %s): "
633 "missing information",
634 client_name? client_name :
"unknown client",
635 uuid? uuid :
"unknown");
649 crm_err(
"Could not create IPC hello message from %s (UUID %s): "
650 "Request creation failed", client_name, uuid);
655 crm_trace(
"Created hello message from %s (UUID %s)", client_name, uuid);
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name)
#define pcmk__assert_alloc(nmemb, size)
enum crm_ais_msg_types type
#define CRM_OP_RM_NODE_CACHE
#define CRM_OP_LRM_DELETE
#define CRM_OP_INVOKE_LRM
#define PCMK__CONTROLD_CMD_NODES
G_GNUC_INTERNAL int pcmk__send_ipc_request(pcmk_ipc_api_t *api, const xmlNode *request)
#define PCMK__CONTROLD_API_MINOR
#define PCMK__CONTROLD_API_MAJOR
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)
IPC interface to Pacemaker daemons.
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
@ pcmk_ipc_event_reply
Daemon's reply to client IPC request.
const char * pcmk_ipc_name(const pcmk_ipc_api_t *api, bool for_log)
Get the IPC name used with an IPC API connection.
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.
int pcmk_controld_api_list_nodes(pcmk_ipc_api_t *api)
Ask the controller for cluster information.
int pcmk_controld_api_ping(pcmk_ipc_api_t *api, const char *node_name)
Ask the controller for status.
unsigned int pcmk_controld_api_replies_expected(const pcmk_ipc_api_t *api)
Get the number of IPC replies currently expected from the controller.
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 pcmk_controld_api_node_info(pcmk_ipc_api_t *api, uint32_t nodeid)
Send a "node info" controller operation.
const char * pcmk__controld_api_reply2str(enum pcmk_controld_api_reply 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_reprobe(pcmk_ipc_api_t *api, const char *target_node, const char *router_node)
Send a reprobe controller operation.
pcmk__ipc_methods_t * pcmk__controld_api_methods(void)
IPC commands for Pacemaker controller.
pcmk_controld_api_reply
Possible types of controller replies.
@ pcmk_controld_reply_nodes
@ pcmk_controld_reply_reprobe
@ pcmk_controld_reply_resource
@ pcmk_controld_reply_ping
@ pcmk_controld_reply_info
@ pcmk_controld_reply_unknown
#define crm_info(fmt, args...)
#define crm_debug(fmt, args...)
#define crm_err(fmt, args...)
#define crm_trace(fmt, args...)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the 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.
char * crm_meta_name(const char *field)
Get the environment variable equivalent of a meta-attribute name.
int crm_element_value_ll(const xmlNode *data, const char *name, long long *dest)
Retrieve the long long integer value of an XML attribute.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK_META_TIMEOUT
#define PCMK__VALUE_RESPONSE
#define PCMK__META_ON_NODE
#define PCMK__VALUE_REQUEST
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
@ CRM_EX_PROTOCOL
Protocol violated.
enum crm_exit_e crm_exit_t
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int(* new_data)(pcmk_ipc_api_t *api)
bool(* reply_expected)(pcmk_ipc_api_t *api, const xmlNode *request)
void(* free_data)(void *api_data)
bool(* dispatch)(pcmk_ipc_api_t *api, xmlNode *msg)
int(* post_connect)(pcmk_ipc_api_t *api)
const char * feature_set
CRM feature set advertised by controller.
struct pcmk_controld_api_reply_t::@1::@3 resource
const char * host_from
Name of node that sent reply.
enum pcmk_controld_api_reply reply_type
union pcmk_controld_api_reply_t::@1 data
Wrappers for and extensions to libxml2.
void crm_xml_set_id(xmlNode *xml, const char *format,...) G_GNUC_PRINTF(2
void free_xml(xmlNode *child)
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
xmlNode * pcmk__xe_next_same(const xmlNode *node)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
#define PCMK_XA_HAVE_QUORUM
#define PCMK_XA_CRM_FEATURE_SET
#define PCMK_XE_PRIMITIVE
#define PCMK_XA_REMOTE_NODE
#define PCMK_XA_REFERENCE
#define PCMK__XA_CRMD_STATE
#define PCMK__XA_CRM_TASK
#define PCMK__XA_CLIENT_NAME
#define PCMK__XA_MAJOR_VERSION
#define PCMK__XA_ROUTER_NODE
#define PCMK__XA_MINOR_VERSION
#define PCMK__XA_CLIENT_UUID
#define PCMK__XA_TRANSITION_KEY
#define PCMK__XE_ATTRIBUTES
#define PCMK__XA_CRM_SUBSYSTEM