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--;
   201     if (pcmk__str_empty(value)
   203         crm_info(
"Unrecognizable message from controller: "   204                  "invalid message type '%s'", pcmk__s(value, 
""));
   210         crm_info(
"Unrecognizable message from controller: no reference");
   216     if (pcmk__str_empty(value)) {
   217         crm_info(
"Unrecognizable message from controller: 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_info(
"Unrecognizable message from controller: unknown command '%s'",
   255         g_list_free_full(reply_data.
data.
nodes, free);
   288 create_controller_request(
const pcmk_ipc_api_t *api, 
const char *op,
   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",
   365               pcmk_ipc_name(api, 
true), pcmk__s(target_node, 
"local node"),
   366               pcmk__s(router_node, 
"local node"));
   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",
   536               pcmk_ipc_name(api, 
true), pcmk__s(rsc_id, 
"unknown resource"),
   537               pcmk__s(rsc_long_id, 
"no other names"),
   538               pcmk__s(target_node, 
"unspecified node"),
   539               pcmk__s(router_node, 
"unspecified node"));
   541                                   router_node, 
false, rsc_id, rsc_long_id,
   542                                   standard, provider, 
type);
   563                           const char *router_node,
   564                           const char *rsc_id, 
const char *rsc_long_id,
   565                           const char *standard, 
const char *provider,
   566                           const char *
type, 
bool cib_only)
   568     crm_debug(
"Sending %s IPC request to refresh %s (a.k.a. %s) on %s via %s",
   569               pcmk_ipc_name(api, 
true), pcmk__s(rsc_id, 
"unknown resource"),
   570               pcmk__s(rsc_long_id, 
"no other names"),
   571               pcmk__s(target_node, 
"unspecified node"),
   572               pcmk__s(router_node, 
"unspecified node"));
   574                                   router_node, cib_only, rsc_id, rsc_long_id,
   575                                   standard, provider, 
type);
   588     struct controld_api_private_s *
private = api->
api_data;
   590     return private->replies_expected;
   601                      const char *major_version, 
const char *minor_version)
   603     xmlNode *hello_node = NULL;
   604     xmlNode *hello = NULL;
   606     if (pcmk__str_empty(uuid) || pcmk__str_empty(client_name)
   607         || pcmk__str_empty(major_version) || pcmk__str_empty(minor_version)) {
   608         crm_err(
"Could not create IPC hello message from %s (UUID %s): "   609                 "missing information",
   610                 client_name? client_name : 
"unknown client",
   611                 uuid? uuid : 
"unknown");
   616     if (hello_node == NULL) {
   617         crm_err(
"Could not create IPC hello message from %s (UUID %s): "   618                 "Message data creation failed", client_name, uuid);
   622     crm_xml_add(hello_node, 
"major_version", major_version);
   623     crm_xml_add(hello_node, 
"minor_version", minor_version);
   624     crm_xml_add(hello_node, 
"client_name", client_name);
   629         crm_err(
"Could not create IPC hello message from %s (UUID %s): "   630                 "Request creation failed", client_name, uuid);
   635     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
 
#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. 
 
#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)
 
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)
 
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)
 
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)
 
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
 
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. 
 
#define XML_NODE_IN_CLUSTER
 
#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.