18 #include <libxml/tree.h> 27 struct controld_api_private_s {
29 unsigned int replies_expected;
63 struct controld_api_private_s *
private = NULL;
65 api->
api_data = calloc(1,
sizeof(
struct controld_api_private_s));
79 private->client_uuid = pcmk__getpid_s();
91 free(((
struct controld_api_private_s *)
data)->client_uuid);
102 struct controld_api_private_s *
private = api->
api_data;
125 if (msg_data == NULL) {
128 data->data.node_info.have_quorum =
130 data->data.node_info.is_remote =
149 if (msg_data == NULL) {
174 node_info->
id = id_ll;
178 data->data.nodes = g_list_prepend(
data->data.nodes, node_info);
200 struct controld_api_private_s *
private = api->
api_data;
202 xmlNode *wrapper = NULL;
203 xmlNode *msg_data = NULL;
204 const char *value = NULL;
214 return private->replies_expected > 0;
217 if (private->replies_expected > 0) {
218 private->replies_expected--;
231 crm_info(
"Unrecognizable message from controller: " 232 "invalid message type '%s'", pcmk__s(value,
""));
238 crm_info(
"Unrecognizable message from controller: no reference");
244 if (pcmk__str_empty(value)) {
245 crm_info(
"Unrecognizable message from controller: no command name");
262 set_node_info_data(&reply_data, msg_data);
269 set_ping_data(&reply_data, msg_data);
272 set_nodes_data(&reply_data, msg_data);
275 crm_info(
"Unrecognizable message from controller: unknown command '%s'",
285 g_list_free_full(reply_data.
data.
nodes, free);
318 create_controller_request(
const pcmk_ipc_api_t *api,
const char *op,
319 const char *node, xmlNode *msg_data)
321 struct controld_api_private_s *
private = NULL;
322 const char *sys_to = NULL;
335 private->client_uuid);
340 send_controller_request(
pcmk_ipc_api_t *api,
const xmlNode *request,
341 bool reply_is_expected)
346 if (reply_is_expected) {
347 struct controld_api_private_s *
private = api->
api_data;
349 private->replies_expected++;
355 create_reprobe_message_data(
const char *target_node,
const char *router_node)
361 if ((router_node != NULL) && !pcmk__str_eq(router_node, target_node,
pcmk__str_casei)) {
379 const char *router_node)
388 if (router_node == NULL) {
389 router_node = target_node;
391 crm_debug(
"Sending %s IPC request to reprobe %s via %s",
392 pcmk_ipc_name(api,
true), pcmk__s(target_node,
"local node"),
393 pcmk__s(router_node,
"local node"));
394 msg_data = create_reprobe_message_data(target_node, router_node);
395 request = create_controller_request(api,
CRM_OP_REPROBE, router_node,
397 rc = send_controller_request(api, request,
true);
419 if (request == NULL) {
426 rc = send_controller_request(api, request,
true);
446 request = create_controller_request(api,
CRM_OP_PING, node_name, NULL);
447 if (request == NULL) {
450 rc = send_controller_request(api, request,
true);
471 if (request != NULL) {
472 rc = send_controller_request(api, request,
true);
481 const char *target_node,
const char *router_node,
482 bool cib_only,
const char *rsc_id,
483 const char *rsc_long_id,
const char *standard,
484 const char *provider,
const char *
type)
488 xmlNode *request, *msg_data, *xml_rsc, *params;
493 if (router_node == NULL) {
494 router_node = target_node;
504 "xxxxxxxx-xrsc-opxx-xcrm-resourcexxxx");
533 request = create_controller_request(api, op, router_node, msg_data);
534 rc = send_controller_request(api, request,
true);
557 const char *target_node,
const char *router_node,
558 const char *rsc_id,
const char *rsc_long_id,
559 const char *standard,
const char *provider,
562 crm_debug(
"Sending %s IPC request to fail %s (a.k.a. %s) on %s via %s",
563 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
564 pcmk__s(rsc_long_id,
"no other names"),
565 pcmk__s(target_node,
"unspecified node"),
566 pcmk__s(router_node,
"unspecified node"));
568 router_node,
false, rsc_id, rsc_long_id,
569 standard, provider,
type);
590 const char *router_node,
591 const char *rsc_id,
const char *rsc_long_id,
592 const char *standard,
const char *provider,
593 const char *
type,
bool cib_only)
595 crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
596 pcmk_ipc_name(api,
true), pcmk__s(rsc_id,
"unknown resource"),
597 pcmk__s(rsc_long_id,
"no other names"),
598 pcmk__s(target_node,
"unspecified node"),
599 pcmk__s(router_node,
"unspecified node"));
601 router_node, cib_only, rsc_id, rsc_long_id,
602 standard, provider,
type);
615 struct controld_api_private_s *
private = api->
api_data;
617 return private->replies_expected;
628 const char *major_version,
const char *minor_version)
630 xmlNode *hello_node = NULL;
631 xmlNode *hello = NULL;
633 if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
634 || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
635 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 636 "missing information",
637 client_name? client_name :
"unknown client",
638 uuid? uuid :
"unknown");
652 crm_err(
"Could not create IPC hello message from %s (UUID %s): " 653 "Request creation failed", client_name, uuid);
658 crm_trace(
"Created hello message from %s (UUID %s)", client_name, uuid);
#define PCMK__VALUE_RESPONSE
union pcmk_controld_api_reply_t::@1 data
enum pcmk_controld_api_reply reply_type
#define PCMK__XA_ROUTER_NODE
#define PCMK_XA_REMOTE_NODE
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.
#define PCMK_XE_PRIMITIVE
#define PCMK__CONTROLD_API_MAJOR
#define PCMK_XA_REFERENCE
#define PCMK_XA_HAVE_QUORUM
#define PCMK__XE_ATTRIBUTES
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
enum crm_exit_e crm_exit_t
#define PCMK__XA_MAJOR_VERSION
bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name)
enum crm_ais_msg_types type
#define PCMK__META_ON_NODE
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)
#define PCMK__XA_CRMD_STATE
#define PCMK__XA_CRM_TASK
#define PCMK__CONTROLD_API_MINOR
#define PCMK__XA_TRANSITION_KEY
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
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
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.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
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.
pcmk__ipc_methods_t * pcmk__controld_api_methods(void)
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.
#define PCMK__XA_CLIENT_UUID
void free_xml(xmlNode *child)
int(* post_connect)(pcmk_ipc_api_t *api)
#define PCMK__XA_CRM_SUBSYSTEM
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
IPC commands for Pacemaker controller.
#define PCMK_META_TIMEOUT
int pcmk_controld_api_list_nodes(pcmk_ipc_api_t *api)
Ask the controller for cluster information.
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
#define PCMK_XA_CRM_FEATURE_SET
int(* new_data)(pcmk_ipc_api_t *api)
#define CRM_OP_RM_NODE_CACHE
#define PCMK__XA_MINOR_VERSION
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...)
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.
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 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
Daemon's reply to client IPC request.
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
#define pcmk__assert_alloc(nmemb, size)
#define CRM_OP_LRM_DELETE
xmlNode * pcmk__xe_next_same(const xmlNode *node)
#define create_request(task, xml_data, host_to, sys_to, sys_from, uuid_from)
#define PCMK__VALUE_REQUEST
#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 PCMK__XA_CLIENT_NAME
pcmk_controld_api_reply
Possible types of controller replies.
char * crm_meta_name(const char *field)
Get the environment variable equivalent of a meta-attribute name.