29 #include <sys/types.h>
44 #ifdef HAVE_GNUTLS_GNUTLS_H
46 # include <gnutls/gnutls.h>
49 #include <sys/socket.h>
50 #include <netinet/in.h>
51 #include <netinet/ip.h>
52 #include <arpa/inet.h>
55 #define MAX_TLS_RECV_WAIT 10000
59 static int lrmd_api_disconnect(
lrmd_t * lrmd);
60 static int lrmd_api_is_connected(
lrmd_t * lrmd);
64 static void lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg);
67 #ifdef HAVE_GNUTLS_GNUTLS_H
68 # define LRMD_CLIENT_HANDSHAKE_TIMEOUT 5000
69 gnutls_psk_client_credentials_t psk_cred_s;
70 int lrmd_tls_set_key(gnutls_datum_t * key);
71 static void lrmd_tls_disconnect(
lrmd_t * lrmd);
72 static int global_remote_msg_id = 0;
74 static void lrmd_tls_connection_destroy(gpointer userdata);
77 typedef struct lrmd_private_s {
88 char *remote_nodename;
89 #ifdef HAVE_GNUTLS_GNUTLS_H
92 gnutls_psk_client_credentials_t psk_cred_c;
102 int expected_late_replies;
103 GList *pending_notify;
110 void (*proxy_callback)(
lrmd_t *lrmd,
void *userdata, xmlNode *msg);
111 void *proxy_callback_userdata;
116 lrmd_list_add(
lrmd_list_t * head,
const char *value)
121 p->
val = strdup(value);
124 while (end && end->
next) {
143 char *val = (
char *)head->
val;
158 p->
key = strdup(key);
159 p->
value = strdup(value);
162 while (end && end->
next) {
201 copy->
rsc_id =
event->rsc_id ? strdup(event->
rsc_id) : NULL;
204 copy->
output =
event->output ? strdup(event->
output) : NULL;
220 free((
char *)event->
rsc_id);
223 free((
char *)event->
output);
227 g_hash_table_destroy(event->
params);
233 lrmd_dispatch_internal(
lrmd_t * lrmd, xmlNode * msg)
240 if (proxy_session != NULL) {
242 lrmd_internal_proxy_dispatch(lrmd, msg);
244 }
else if (!native->callback) {
246 crm_trace(
"notify event received but client has not set callback");
250 event.remote_nodename = native->remote_nodename;
287 crm_trace(
"op %s notify event received", type);
288 native->callback(&event);
291 g_hash_table_destroy(event.params);
297 lrmd_ipc_dispatch(
const char *buffer, ssize_t length, gpointer userdata)
304 if (!native->callback) {
310 rc = lrmd_dispatch_internal(lrmd, msg);
315 #ifdef HAVE_GNUTLS_GNUTLS_H
317 lrmd_free_xml(gpointer userdata)
323 lrmd_tls_connected(
lrmd_t * lrmd)
327 if (native->remote->tls_session) {
335 lrmd_tls_dispatch(gpointer userdata)
341 int disconnected = 0;
343 if (lrmd_tls_connected(lrmd) == FALSE) {
344 crm_trace(
"tls dispatch triggered after disconnect");
352 if (native->pending_notify) {
355 crm_trace(
"Processing pending notifies");
356 for (iter = native->pending_notify; iter; iter = iter->next) {
357 lrmd_dispatch_internal(lrmd, iter->data);
359 g_list_free_full(native->pending_notify, lrmd_free_xml);
360 native->pending_notify = NULL;
377 lrmd_dispatch_internal(lrmd, xml);
379 if (native->expected_late_replies > 0) {
380 native->expected_late_replies--;
385 crm_err(
"Got outdated reply %d", reply_id);
393 crm_info(
"Server disconnected while reading remote server msg.");
394 lrmd_tls_disconnect(lrmd);
407 switch (native->type) {
411 #ifdef HAVE_GNUTLS_GNUTLS_H
413 if (native->pending_notify) {
420 crm_err(
"Unsupported connection type: %d", native->type);
435 switch (private->type) {
441 lrmd_ipc_dispatch(msg, strlen(msg), lrmd);
445 #ifdef HAVE_GNUTLS_GNUTLS_H
447 lrmd_tls_dispatch(lrmd);
451 crm_err(
"Unsupported connection type: %d", private->type);
454 if (lrmd_api_is_connected(lrmd) == FALSE) {
463 lrmd_create_op(
const char *token,
const char *op, xmlNode *
data,
int timeout,
482 crm_trace(
"Created lrmd %s command with call options %.8lx (%d)",
483 op, (
long)options, options);
488 lrmd_ipc_connection_destroy(gpointer userdata)
493 crm_info(
"IPC connection destroyed");
497 native->source = NULL;
499 if (native->callback) {
502 event.remote_nodename = native->remote_nodename;
503 native->callback(&event);
507 #ifdef HAVE_GNUTLS_GNUTLS_H
509 lrmd_tls_connection_destroy(gpointer userdata)
514 crm_info(
"TLS connection destroyed");
516 if (native->remote->tls_session) {
517 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
518 gnutls_deinit(*native->remote->tls_session);
519 gnutls_free(native->remote->tls_session);
521 if (native->psk_cred_c) {
522 gnutls_psk_free_client_credentials(native->psk_cred_c);
527 if (native->process_notify) {
529 native->process_notify = NULL;
531 if (native->pending_notify) {
532 g_list_free_full(native->pending_notify, lrmd_free_xml);
533 native->pending_notify = NULL;
536 free(native->remote->buffer);
537 native->remote->buffer = NULL;
540 native->psk_cred_c = NULL;
541 native->remote->tls_session = NULL;
544 if (native->callback) {
548 native->callback(&event);
562 lrmd_tls_recv_reply(
lrmd_t * lrmd,
int total_timeout,
int expected_reply_id,
int *disconnected)
566 time_t start = time(NULL);
567 const char *msg_type = NULL;
569 int remaining_timeout = 0;
582 if (remaining_timeout) {
583 remaining_timeout = total_timeout - ((time(NULL) - start) * 1000);
585 remaining_timeout = total_timeout;
587 if (remaining_timeout <= 0) {
588 crm_err(
"Never received the expected reply during the timeout period, disconnecting.");
589 *disconnected = TRUE;
596 crm_err(
"Unable to receive expected reply, disconnecting.");
597 *disconnected = TRUE;
599 }
else if (*disconnected) {
610 crm_err(
"Empty msg type received while waiting for reply");
616 native->pending_notify = g_list_append(native->pending_notify, xml);
617 if (native->process_notify) {
624 crm_err(
"Expected a reply, got %s", msg_type);
627 }
else if (reply_id != expected_reply_id) {
628 if (native->expected_late_replies > 0) {
629 native->expected_late_replies--;
631 crm_err(
"Got outdated reply, expected id %d got id %d", expected_reply_id, reply_id);
638 if (native->remote->buffer && native->process_notify) {
646 lrmd_tls_send(
lrmd_t * lrmd, xmlNode * msg)
651 global_remote_msg_id++;
652 if (global_remote_msg_id <= 0) {
653 global_remote_msg_id = 1;
656 rc = lrmd_tls_send_msg(native->remote, msg, global_remote_msg_id,
"request");
658 crm_err(
"Remote lrmd send failed, disconnecting");
659 lrmd_tls_disconnect(lrmd);
666 lrmd_tls_send_recv(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
669 int disconnected = 0;
672 if (lrmd_tls_connected(lrmd) == FALSE) {
676 rc = lrmd_tls_send(lrmd, msg);
681 xml = lrmd_tls_recv_reply(lrmd, timeout, global_remote_msg_id, &disconnected);
684 crm_err(
"Remote lrmd server disconnected while waiting for reply with id %d. ",
685 global_remote_msg_id);
686 lrmd_tls_disconnect(lrmd);
689 crm_err(
"Remote lrmd never received reply for request id %d. timeout: %dms ",
690 global_remote_msg_id, timeout);
705 lrmd_send_xml(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
710 switch (native->type) {
714 #ifdef HAVE_GNUTLS_GNUTLS_H
716 rc = lrmd_tls_send_recv(lrmd, msg, timeout, reply);
720 crm_err(
"Unsupported connection type: %d", native->type);
727 lrmd_send_xml_no_reply(
lrmd_t * lrmd, xmlNode * msg)
732 switch (native->type) {
736 #ifdef HAVE_GNUTLS_GNUTLS_H
738 rc = lrmd_tls_send(lrmd, msg);
743 native->expected_late_replies++;
748 crm_err(
"Unsupported connection type: %d", native->type);
755 lrmd_api_is_connected(
lrmd_t * lrmd)
759 switch (native->type) {
763 #ifdef HAVE_GNUTLS_GNUTLS_H
765 return lrmd_tls_connected(lrmd);
769 crm_err(
"Unsupported connection type: %d", native->type);
792 lrmd_send_command(
lrmd_t *lrmd,
const char *op, xmlNode *data,
793 xmlNode **output_data,
int timeout,
798 xmlNode *op_msg = NULL;
799 xmlNode *op_reply = NULL;
801 if (!lrmd_api_is_connected(lrmd)) {
806 crm_err(
"No operation specified");
814 op_msg = lrmd_create_op(native->token, op, data, timeout, options);
816 if (op_msg == NULL) {
821 rc = lrmd_send_xml(lrmd, op_msg, timeout, &op_reply);
823 rc = lrmd_send_xml_no_reply(lrmd, op_msg);
828 crm_perror(LOG_ERR,
"Couldn't perform %s operation (timeout=%d): %d", op, timeout, rc);
832 }
else if(op_reply == NULL) {
847 *output_data = op_reply;
852 if (lrmd_api_is_connected(lrmd) == FALSE) {
862 lrmd_api_poke_connection(
lrmd_t * lrmd)
885 value = g_hash_table_lookup(hash,
"stonith-watchdog-timeout");
895 lrmd_handshake(
lrmd_t * lrmd,
const char *name)
899 xmlNode *reply = NULL;
908 if (native->proxy_callback) {
912 rc = lrmd_send_xml(lrmd, hello, -1, &reply);
915 crm_perror(LOG_DEBUG,
"Couldn't complete registration with the lrmd API: %d", rc);
917 }
else if (reply == NULL) {
918 crm_err(
"Did not receive registration reply");
928 crm_err(
"LRMD protocol mismatch client version %s, server version %s",
933 crm_err(
"Invalid registration message: %s", msg_type);
936 }
else if (tmp_ticket == NULL) {
937 crm_err(
"No registration token provided");
941 crm_trace(
"Obtained registration token: %s", tmp_ticket);
942 native->token = strdup(tmp_ticket);
943 native->peer_version = strdup(version?version:
"1.0");
952 lrmd_api_disconnect(lrmd);
958 lrmd_ipc_connect(
lrmd_t * lrmd,
int *fd)
965 .destroy = lrmd_ipc_connection_destroy
975 }
else if (native->ipc) {
976 crm_perror(LOG_ERR,
"Connection to local resource manager failed");
984 if (native->ipc == NULL) {
985 crm_debug(
"Could not connect to the LRMD API");
992 #ifdef HAVE_GNUTLS_GNUTLS_H
994 set_key(gnutls_datum_t * key,
const char *location)
999 int buf_len = read_len;
1000 static char *key_cache = NULL;
1001 static size_t key_cache_len = 0;
1002 static time_t key_cache_updated;
1004 if (location == NULL) {
1009 time_t now = time(NULL);
1011 if ((now - key_cache_updated) < 60) {
1012 key->data = gnutls_malloc(key_cache_len + 1);
1013 key->size = key_cache_len;
1014 memcpy(key->data, key_cache, key_cache_len);
1020 key_cache_updated = 0;
1027 stream = fopen(location,
"r");
1032 key->data = gnutls_malloc(read_len);
1033 while (!feof(stream)) {
1036 if (cur_len == buf_len) {
1037 buf_len = cur_len + read_len;
1038 key->data = gnutls_realloc(key->data, buf_len);
1040 next = fgetc(stream);
1041 if (next == EOF && feof(stream)) {
1045 key->data[cur_len] = next;
1050 key->size = cur_len;
1052 gnutls_free(key->data);
1058 key_cache = calloc(1, key->size + 1);
1059 memcpy(key_cache, key->data, key->size);
1061 key_cache_len = key->size;
1062 key_cache_updated = time(NULL);
1069 lrmd_tls_set_key(gnutls_datum_t * key)
1071 const char *specific_location = getenv(
"PCMK_authkey_location");
1073 if (set_key(key, specific_location) == 0) {
1074 crm_debug(
"Using custom authkey location %s", specific_location);
1077 }
else if (specific_location) {
1078 crm_err(
"No valid lrmd remote key found at %s, trying default location", specific_location);
1091 lrmd_gnutls_global_init(
void)
1093 static int gnutls_init = 0;
1096 crm_gnutls_global_init();
1103 report_async_connection_result(
lrmd_t * lrmd,
int rc)
1107 if (native->callback) {
1110 event.remote_nodename = native->remote_nodename;
1111 event.connection_rc = rc;
1112 native->callback(&event);
1116 #ifdef HAVE_GNUTLS_GNUTLS_H
1118 lrmd_tcp_connect_cb(
void *userdata,
int sock)
1125 .destroy = lrmd_tls_connection_destroy,
1128 gnutls_datum_t psk_key = { NULL, 0 };
1130 native->async_timer = 0;
1133 lrmd_tls_connection_destroy(lrmd);
1134 crm_info(
"Could not connect to remote LRMD at %s:%d",
1135 native->server, native->port);
1136 report_async_connection_result(lrmd, rc);
1144 native->sock = sock;
1146 rc = lrmd_tls_set_key(&psk_key);
1148 crm_warn(
"Could not set key for remote LRMD at %s:%d " CRM_XS " rc=%d",
1149 native->server, native->port, rc);
1150 lrmd_tls_connection_destroy(lrmd);
1151 report_async_connection_result(lrmd, rc);
1155 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1157 gnutls_free(psk_key.data);
1162 crm_warn(
"Disconnecting after TLS handshake with remote LRMD %s:%d failed",
1163 native->server, native->port);
1164 gnutls_deinit(*native->remote->tls_session);
1165 gnutls_free(native->remote->tls_session);
1166 native->remote->tls_session = NULL;
1167 lrmd_tls_connection_destroy(lrmd);
1172 crm_info(
"TLS connection to remote LRMD %s:%d succeeded",
1173 native->server, native->port);
1179 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1181 rc = lrmd_handshake(lrmd, name);
1184 report_async_connection_result(lrmd, rc);
1189 lrmd_tls_connect_async(
lrmd_t * lrmd,
int timeout )
1195 lrmd_gnutls_global_init();
1197 &timer_id, lrmd, lrmd_tcp_connect_cb);
1201 native->sock = sock;
1202 native->async_timer = timer_id;
1207 lrmd_tls_connect(
lrmd_t * lrmd,
int *fd)
1211 .destroy = lrmd_tls_connection_destroy,
1217 gnutls_datum_t psk_key = { NULL, 0 };
1219 lrmd_gnutls_global_init();
1223 crm_warn(
"Could not establish remote lrmd connection to %s", native->server);
1224 lrmd_tls_connection_destroy(lrmd);
1228 native->sock = sock;
1230 rc = lrmd_tls_set_key(&psk_key);
1232 lrmd_tls_connection_destroy(lrmd);
1236 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1238 gnutls_free(psk_key.data);
1243 crm_err(
"Session creation for %s:%d failed", native->server, native->port);
1244 gnutls_deinit(*native->remote->tls_session);
1245 gnutls_free(native->remote->tls_session);
1246 native->remote->tls_session = NULL;
1247 lrmd_tls_connection_destroy(lrmd);
1251 crm_info(
"Remote lrmd client TLS connection established with server %s:%d", native->server,
1258 native->server, native->port);
1262 mainloop_add_fd(name, G_PRIORITY_HIGH, native->sock, lrmd, &lrmd_tls_callbacks);
1270 lrmd_api_connect(
lrmd_t * lrmd,
const char *name,
int *fd)
1275 switch (native->type) {
1277 rc = lrmd_ipc_connect(lrmd, fd);
1279 #ifdef HAVE_GNUTLS_GNUTLS_H
1280 case CRM_CLIENT_TLS:
1281 rc = lrmd_tls_connect(lrmd, fd);
1285 crm_err(
"Unsupported connection type: %d", native->type);
1289 rc = lrmd_handshake(lrmd, name);
1296 lrmd_api_connect_async(
lrmd_t * lrmd,
const char *name,
int timeout)
1301 if (!native->callback) {
1302 crm_err(
"Async connect not possible, no lrmd client callback set.");
1306 switch (native->type) {
1310 rc = lrmd_api_connect(lrmd, name, NULL);
1312 report_async_connection_result(lrmd, rc);
1315 #ifdef HAVE_GNUTLS_GNUTLS_H
1316 case CRM_CLIENT_TLS:
1317 rc = lrmd_tls_connect_async(lrmd, timeout);
1320 report_async_connection_result(lrmd, rc);
1325 crm_err(
"Unsupported connection type: %d", native->type);
1332 lrmd_ipc_disconnect(
lrmd_t * lrmd)
1336 if (native->source != NULL) {
1339 native->source = NULL;
1342 }
else if (native->ipc) {
1352 #ifdef HAVE_GNUTLS_GNUTLS_H
1354 lrmd_tls_disconnect(
lrmd_t * lrmd)
1358 if (native->remote->tls_session) {
1359 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
1360 gnutls_deinit(*native->remote->tls_session);
1361 gnutls_free(native->remote->tls_session);
1362 native->remote->tls_session = 0;
1365 if (native->async_timer) {
1366 g_source_remove(native->async_timer);
1367 native->async_timer = 0;
1370 if (native->source != NULL) {
1373 native->source = NULL;
1375 }
else if (native->sock) {
1376 close(native->sock);
1380 if (native->pending_notify) {
1381 g_list_free_full(native->pending_notify, lrmd_free_xml);
1382 native->pending_notify = NULL;
1388 lrmd_api_disconnect(
lrmd_t * lrmd)
1392 crm_info(
"Disconnecting from %d lrmd service", native->type);
1393 switch (native->type) {
1395 lrmd_ipc_disconnect(lrmd);
1397 #ifdef HAVE_GNUTLS_GNUTLS_H
1398 case CRM_CLIENT_TLS:
1399 lrmd_tls_disconnect(lrmd);
1403 crm_err(
"Unsupported connection type: %d", native->type);
1406 free(native->token);
1407 native->token = NULL;
1409 free(native->peer_version);
1410 native->peer_version = NULL;
1415 lrmd_api_register_rsc(
lrmd_t * lrmd,
1421 xmlNode *data = NULL;
1423 if (!
class || !type || !rsc_id) {
1437 rc = lrmd_send_command(lrmd,
LRMD_OP_RSC_REG, data, NULL, 0, options, TRUE);
1464 copy->
id = strdup(rsc_info->
id);
1465 copy->
type = strdup(rsc_info->
type);
1481 free(rsc_info->
type);
1482 free(rsc_info->
class);
1492 xmlNode *output = NULL;
1493 const char *
class = NULL;
1494 const char *provider = NULL;
1495 const char *type = NULL;
1499 lrmd_send_command(lrmd,
LRMD_OP_RSC_INFO, data, &output, 0, options, TRUE);
1510 if (!
class || !type) {
1519 rsc_info->
id = strdup(rsc_id);
1520 rsc_info->
class = strdup(
class);
1522 rsc_info->
provider = strdup(provider);
1524 rsc_info->
type = strdup(type);
1535 native->callback = callback;
1543 native->proxy_callback = callback;
1544 native->proxy_callback_userdata = userdata;
1548 lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg)
1552 if (native->proxy_callback) {
1554 native->proxy_callback(lrmd, native->proxy_callback_userdata, msg);
1567 return lrmd_send_xml_no_reply(lrmd, msg);
1571 stonith_get_metadata(
const char *provider,
const char *type,
char **output)
1578 stonith_api->
cmds->
free(stonith_api);
1580 if (*output == NULL) {
1587 lrmd_api_get_metadata(
lrmd_t * lrmd,
1589 const char *provider,
1594 if (!
class || !type) {
1599 return stonith_get_metadata(provider, type, output);
1605 if (action == NULL) {
1606 crm_err(
"Unable to retrieve meta-data for %s:%s:%s",
class, provider, type);
1612 crm_err(
"Failed to retrieve meta-data for %s:%s:%s",
class, provider, type);
1618 crm_err(
"Failed to receive meta-data for %s:%s:%s",
class, provider, type);
1630 lrmd_api_exec(
lrmd_t * lrmd,
const char *rsc_id,
const char *action,
const char *userdata,
int interval,
1648 for (tmp = params; tmp; tmp = tmp->
next) {
1652 rc = lrmd_send_command(lrmd,
LRMD_OP_RSC_EXEC, data, NULL, timeout, options, TRUE);
1661 lrmd_api_exec_alert(
lrmd_t *lrmd,
const char *alert_id,
const char *alert_path,
1674 for (tmp = params; tmp; tmp = tmp->
next) {
1687 lrmd_api_cancel(
lrmd_t * lrmd,
const char *rsc_id,
const char *action,
int interval)
1711 stonith_api->
cmds->
free(stonith_api);
1714 for (dIter = stonith_resources; dIter; dIter = dIter->
next) {
1717 *resources = lrmd_list_add(*resources, dIter->
value);
1726 lrmd_api_list_agents(
lrmd_t * lrmd,
lrmd_list_t ** resources,
const char *
class,
1727 const char *provider)
1732 rc += list_stonith_agents(resources);
1738 for (gIter = agents; gIter != NULL; gIter = gIter->next) {
1739 *resources = lrmd_list_add(*resources, (
const char *)gIter->data);
1742 g_list_free_full(agents, free);
1745 rc += list_stonith_agents(resources);
1750 crm_notice(
"No agents found for class %s",
class);
1751 rc = -EPROTONOSUPPORT;
1757 does_provider_have_agent(
const char *agent,
const char *provider,
const char *
class)
1760 GList *agents = NULL;
1764 for (gIter2 = agents; gIter2 != NULL; gIter2 = gIter2->next) {
1769 g_list_free_full(agents, free);
1775 lrmd_api_list_ocf_providers(
lrmd_t * lrmd,
const char *agent,
lrmd_list_t ** providers)
1778 char *provider = NULL;
1779 GList *ocf_providers = NULL;
1784 for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
1785 provider = gIter->data;
1786 if (!agent || does_provider_have_agent(agent, provider,
1788 *providers = lrmd_list_add(*providers, (
const char *)gIter->data);
1793 g_list_free_full(ocf_providers, free);
1801 GList *standards = NULL;
1806 for (gIter = standards; gIter != NULL; gIter = gIter->next) {
1807 *supported = lrmd_list_add(*supported, (
const char *)gIter->data);
1811 if (list_stonith_agents(NULL) > 0) {
1816 g_list_free_full(standards, free);
1826 new_lrmd = calloc(1,
sizeof(
lrmd_t));
1844 new_lrmd->
cmds->
exec = lrmd_api_exec;
1857 #ifdef HAVE_GNUTLS_GNUTLS_H
1861 if (!nodename && !server) {
1866 native->type = CRM_CLIENT_TLS;
1867 native->remote_nodename = nodename ? strdup(nodename) : strdup(server);
1868 native->server = server ? strdup(server) : strdup(nodename);
1869 native->port = port;
1870 if (native->port == 0) {
1876 crm_err(
"GNUTLS is not enabled for this build, remote LRMD client can not be created");
1893 #ifdef HAVE_GNUTLS_GNUTLS_H
1894 free(native->server);
1896 free(native->remote_nodename);
1897 free(native->remote);
1898 free(native->token);
1899 free(native->peer_version);
#define CRM_CHECK(expr, failure_action)
#define LRMD_OP_ALERT_EXEC
#define CRMD_METADATA_CALL_TIMEOUT
bool crm_ipc_connect(crm_ipc_t *client)
Establish an IPC connection to a Pacemaker component.
#define crm_notice(fmt, args...)
GHashTable * xml2list(xmlNode *parent)
gboolean safe_str_neq(const char *a, const char *b)
void services_action_free(svc_action_t *op)
int crm_remote_ready(crm_remote_t *remote, int total_timeout)
gboolean crm_remote_recv(crm_remote_t *remote, int total_timeout, int *disconnected)
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
#define F_LRMD_IS_IPC_PROVIDER
int(* cancel)(lrmd_t *lrmd, const char *rsc_id, const char *action, int interval)
Cancel a recurring command.
int(* metadata)(stonith_t *st, int options, const char *device, const char *namespace, char **output, int timeout)
Get the metadata documentation for a resource.
#define F_LRMD_IPC_SESSION
#define F_LRMD_RSC_EXEC_TIME
#define F_LRMD_RSC_ACTION
#define LRMD_OP_RSC_CANCEL
int crm_ipc_get_fd(crm_ipc_t *client)
int(* exec)(lrmd_t *lrmd, const char *rsc_id, const char *action, const char *userdata, int interval, int timeout, int start_delay, enum lrmd_call_options options, lrmd_key_value_t *params)
Issue a command on a resource.
#define F_LRMD_RSC_OUTPUT
int(* poke_connection)(lrmd_t *lrmd)
Poke lrmd connection to verify it is still capable of serving requests.
void(* set_callback)(lrmd_t *lrmd, lrmd_event_callback callback)
Sets the callback to receive lrmd events on.
int(* is_connected)(lrmd_t *lrmd)
Is connected to lrmd daemon?
svc_action_t * resources_action_create(const char *name, const char *standard, const char *provider, const char *agent, const char *action, int interval, int timeout, GHashTable *params, enum svc_action_flags flags)
Create a new resource action.
struct stonith_key_value_s * next
void lrmd_list_freeall(lrmd_list_t *head)
struct mainloop_io_s mainloop_io_t
void lrmd_free_event(lrmd_event_data_t *event)
void mainloop_set_trigger(crm_trigger_t *source)
#define DEFAULT_REMOTE_USERNAME
#define MAX_TLS_RECV_WAIT
int(* free)(stonith_t *st)
Destroy the stonith api structure.
void(* lrmd_event_callback)(lrmd_event_data_t *event)
int(* dispatch)(gpointer userdata)
int lrmd_internal_proxy_send(lrmd_t *lrmd, xmlNode *msg)
#define F_LRMD_ALERT_PATH
long crm_ipc_read(crm_ipc_t *client)
gboolean mainloop_destroy_trigger(crm_trigger_t *source)
lrmd_t * lrmd_remote_api_new(const char *nodename, const char *server, int port)
Create a new remote lrmd connection using tls backend.
int crm_remote_tcp_connect(const char *host, int port)
Wrappers for and extensions to glib mainloop.
#define F_LRMD_PROTOCOL_VERSION
stonith_t * stonith_api_new(void)
xmlNode * string2xml(const char *input)
int(* exec_alert)(lrmd_t *lrmd, const char *alert_id, const char *alert_path, int timeout, lrmd_key_value_t *params)
Execute an alert agent.
int(* disconnect)(lrmd_t *lrmd)
Disconnect from the lrmd.
const char * crm_ipc_buffer(crm_ipc_t *client)
#define LRMD_OP_RSC_UNREG
#define CRM_TRACE_INIT_DATA(name)
#define DEFAULT_REMOTE_KEY_LOCATION
struct trigger_s crm_trigger_t
int(* list_ocf_providers)(lrmd_t *lrmd, const char *agent, lrmd_list_t **providers)
Retrieve a list of resource agent providers.
void hash2smartfield(gpointer key, gpointer value, gpointer user_data)
struct lrmd_private_s lrmd_private_t
lrmd_rsc_info_t * lrmd_copy_rsc_info(lrmd_rsc_info_t *rsc_info)
#define crm_warn(fmt, args...)
#define PCMK_RESOURCE_CLASS_OCF
#define crm_debug(fmt, args...)
int crm_initiate_client_tls_handshake(crm_remote_t *remote, int timeout_ms)
struct crm_ipc_s crm_ipc_t
#define F_LRMD_RSC_EXIT_REASON
int(* get_metadata)(lrmd_t *lrmd, const char *class, const char *provider, const char *agent, char **output, enum lrmd_call_options options)
Get resource metadata for a specified resource agent.
#define ALT_REMOTE_KEY_LOCATION
int remote_proxy_check(lrmd_t *lrmd, GHashTable *hash)
struct lrmd_list_s * next
gboolean services_action_sync(svc_action_t *op)
#define LRMD_PROTOCOL_VERSION
xmlNode * crm_remote_parse_buffer(crm_remote_t *remote)
#define crm_trace(fmt, args...)
crm_trigger_t * mainloop_add_trigger(int priority, int(*dispatch)(gpointer user_data), gpointer userdata)
lrmd_t * lrmd_api_new(void)
Create a new local lrmd connection.
#define LRMD_OP_NEW_CLIENT
xmlNode * create_xml_node(xmlNode *parent, const char *name)
int crm_element_value_int(xmlNode *data, const char *name, int *dest)
const char * crm_element_value(xmlNode *data, const char *name)
bool lrmd_dispatch(lrmd_t *lrmd)
Use after lrmd_poll returns 1 to read and dispatch a message.
void stonith_key_value_freeall(stonith_key_value_t *kvp, int keys, int values)
lrmd_key_value_t * lrmd_key_value_add(lrmd_key_value_t *kvp, const char *key, const char *value)
void mainloop_del_ipc_client(mainloop_io_t *client)
void crm_ipc_destroy(crm_ipc_t *client)
GList * resources_list_providers(const char *standard)
Get a list of providers.
struct lrmd_key_value_s * next
#define F_LRMD_RSC_USERDATA_STR
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
void free_xml(xmlNode *child)
#define F_LRMD_RSC_INTERVAL
int crm_remote_tcp_connect_async(const char *host, int port, int timeout, int *timer_id, void *userdata, void(*callback)(void *userdata, int sock))
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
int(* connect_async)(lrmd_t *lrmd, const char *client_name, int timeout)
Establish an connection to lrmd, don't block while connecting.
#define F_LRMD_RSC_START_DELAY
bool crm_ipc_connected(crm_ipc_t *client)
void lrmd_key_value_freeall(lrmd_key_value_t *head)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#define PCMK_RESOURCE_CLASS_STONITH
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
int crm_ipc_ready(crm_ipc_t *client)
Check whether an IPC connection is ready to be read.
#define F_LRMD_RSC_RCCHANGE_TIME
#define crm_log_xml_err(xml, text)
#define F_LRMD_REMOTE_MSG_ID
#define crm_perror(level, fmt, args...)
Log a system error message.
int(* connect)(lrmd_t *lrmd, const char *client_name, int *fd)
Connect from the lrmd.
const char * remote_nodename
lrmd_api_operations_t * cmds
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
GList * resources_list_standards(void)
#define crm_err(fmt, args...)
enum lrmd_callback_event type
stonith_api_operations_t * cmds
int crm_ipc_send(crm_ipc_t *client, xmlNode *message, enum crm_ipc_flags flags, int32_t ms_timeout, xmlNode **reply)
int(* list_agents)(lrmd_t *lrmd, lrmd_list_t **agents, const char *class, const char *provider)
Retrieve a list of installed resource agents.
GHashTable * crm_str_table_dup(GHashTable *old_table)
crm_ipc_t * crm_ipc_new(const char *name, size_t max_size)
int(* unregister_rsc)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Unregister a resource from the lrmd.
GList * resources_list_agents(const char *standard, const char *provider)
Get a list of resource agents.
void * create_psk_tls_session(int csock, int type, void *credentials)
lrmd_event_data_t * lrmd_copy_event(lrmd_event_data_t *event)
#define F_LRMD_RSC_RUN_TIME
int lrmd_poll(lrmd_t *lrmd, int timeout)
Poll for a specified timeout period to determine if a message is ready for dispatch.
void lrmd_internal_set_proxy_callback(lrmd_t *lrmd, void *userdata, void(*callback)(lrmd_t *lrmd, void *userdata, xmlNode *msg))
#define crm_log_xml_trace(xml, text)
void lrmd_free_rsc_info(lrmd_rsc_info_t *rsc_info)
bool crm_provider_required(const char *standard)
Check whether a resource standard requires a provider to be specified.
#define F_LRMD_CLIENTNAME
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
#define F_LRMD_RSC_QUEUE_TIME
#define F_LRMD_RSC_DELETED
int(* list_agents)(stonith_t *stonith, int call_options, const char *namespace, stonith_key_value_t **devices, int timeout)
Retrieve a list of installed stonith agents.
lrmd_rsc_info_t *(* get_rsc_info)(lrmd_t *lrmd, const char *rsc_id, enum lrmd_call_options options)
Retrieve registration info for a rsc.
#define safe_str_eq(a, b)
#define F_LRMD_CALLBACK_TOKEN
void lrmd_api_delete(lrmd_t *lrmd)
Destroy lrmd object.
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
int(* register_rsc)(lrmd_t *lrmd, const char *rsc_id, const char *class, const char *provider, const char *agent, enum lrmd_call_options options)
Register a resource with the lrmd.
#define F_LRMD_REMOTE_MSG_TYPE
void crm_ipc_close(crm_ipc_t *client)
int crm_remote_send(crm_remote_t *remote, xmlNode *msg)
#define crm_info(fmt, args...)
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
int(* list_standards)(lrmd_t *lrmd, lrmd_list_t **standards)
Retrieve a list of standards supported by this machine/installation.
int crm_default_remote_port(void)
Get the default remote connection TCP port on this host.
enum crm_ais_msg_types type