19 #include <sys/types.h>
36 #ifdef HAVE_GNUTLS_GNUTLS_H
38 # include <gnutls/gnutls.h>
41 #include <sys/socket.h>
42 #include <netinet/in.h>
43 #include <netinet/ip.h>
44 #include <arpa/inet.h>
47 #define MAX_TLS_RECV_WAIT 10000
51 static int lrmd_api_disconnect(
lrmd_t * lrmd);
52 static int lrmd_api_is_connected(
lrmd_t * lrmd);
56 static void lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg);
59 #ifdef HAVE_GNUTLS_GNUTLS_H
60 # define LRMD_CLIENT_HANDSHAKE_TIMEOUT 5000
61 gnutls_psk_client_credentials_t psk_cred_s;
62 int lrmd_tls_set_key(gnutls_datum_t * key);
63 static void lrmd_tls_disconnect(
lrmd_t * lrmd);
64 static int global_remote_msg_id = 0;
65 static void lrmd_tls_connection_destroy(gpointer userdata);
68 typedef struct lrmd_private_s {
79 char *remote_nodename;
80 #ifdef HAVE_GNUTLS_GNUTLS_H
83 gnutls_psk_client_credentials_t psk_cred_c;
93 int expected_late_replies;
94 GList *pending_notify;
101 void (*proxy_callback)(
lrmd_t *lrmd,
void *userdata, xmlNode *msg);
102 void *proxy_callback_userdata;
107 lrmd_list_add(
lrmd_list_t * head,
const char *value)
112 p->
val = strdup(value);
115 while (end && end->
next) {
134 char *val = (
char *)head->
val;
149 p->
key = strdup(key);
150 p->
value = strdup(value);
153 while (end && end->
next) {
198 if (rsc_id != NULL) {
199 event->rsc_id = strdup(rsc_id);
203 event->op_type = strdup(task);
206 event->interval_ms = interval_ms;
222 copy->
rsc_id =
event->rsc_id ? strdup(event->
rsc_id) : NULL;
225 copy->
output =
event->output ? strdup(event->
output) : NULL;
241 free((
char *)event->
rsc_id);
244 free((
char *)event->
output);
248 g_hash_table_destroy(event->
params);
254 lrmd_dispatch_internal(
lrmd_t * lrmd, xmlNode * msg)
261 if (proxy_session != NULL) {
263 lrmd_internal_proxy_dispatch(lrmd, msg);
265 }
else if (!native->callback) {
267 crm_trace(
"notify event received but client has not set callback");
271 event.remote_nodename = native->remote_nodename;
291 event.t_run = (
unsigned int) epoch;
294 event.t_rcchange = (
unsigned int) epoch;
315 native->callback(&event);
318 g_hash_table_destroy(event.params);
324 lrmd_ipc_dispatch(
const char *buffer, ssize_t length, gpointer userdata)
331 if (!native->callback) {
337 rc = lrmd_dispatch_internal(lrmd, msg);
342 #ifdef HAVE_GNUTLS_GNUTLS_H
344 lrmd_free_xml(gpointer userdata)
350 lrmd_tls_connected(
lrmd_t * lrmd)
354 if (native->remote->tls_session) {
362 lrmd_tls_dispatch(gpointer userdata)
369 if (lrmd_tls_connected(lrmd) == FALSE) {
370 crm_trace(
"TLS dispatch triggered after disconnect");
378 if (native->pending_notify) {
381 crm_trace(
"Processing pending notifies");
382 for (iter = native->pending_notify; iter; iter = iter->next) {
383 lrmd_dispatch_internal(lrmd, iter->data);
385 g_list_free_full(native->pending_notify, lrmd_free_xml);
386 native->pending_notify = NULL;
406 lrmd_dispatch_internal(lrmd, xml);
408 if (native->expected_late_replies > 0) {
409 native->expected_late_replies--;
414 crm_err(
"Got outdated Pacemaker Remote reply %d", reply_id);
421 if (
rc == ENOTCONN) {
422 crm_info(
"Lost %s executor connection while reading data",
423 (native->remote_nodename? native->remote_nodename :
"local"));
424 lrmd_tls_disconnect(lrmd);
437 switch (native->type) {
441 #ifdef HAVE_GNUTLS_GNUTLS_H
442 case PCMK__CLIENT_TLS:
443 if (native->pending_notify) {
459 crm_err(
"Unsupported connection type: %d", native->type);
474 switch (private->type) {
480 lrmd_ipc_dispatch(msg, strlen(msg), lrmd);
484 #ifdef HAVE_GNUTLS_GNUTLS_H
485 case PCMK__CLIENT_TLS:
486 lrmd_tls_dispatch(lrmd);
490 crm_err(
"Unsupported connection type: %d", private->type);
493 if (lrmd_api_is_connected(lrmd) == FALSE) {
502 lrmd_create_op(
const char *token,
const char *op, xmlNode *
data,
int timeout,
521 crm_trace(
"Created executor %s command with call options %.8lx (%d)",
522 op, (
long)options, options);
527 lrmd_ipc_connection_destroy(gpointer userdata)
532 crm_info(
"IPC connection destroyed");
536 native->source = NULL;
538 if (native->callback) {
541 event.remote_nodename = native->remote_nodename;
542 native->callback(&event);
546 #ifdef HAVE_GNUTLS_GNUTLS_H
548 lrmd_tls_connection_destroy(gpointer userdata)
553 crm_info(
"TLS connection destroyed");
555 if (native->remote->tls_session) {
556 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
557 gnutls_deinit(*native->remote->tls_session);
558 gnutls_free(native->remote->tls_session);
560 if (native->psk_cred_c) {
561 gnutls_psk_free_client_credentials(native->psk_cred_c);
566 if (native->process_notify) {
568 native->process_notify = NULL;
570 if (native->pending_notify) {
571 g_list_free_full(native->pending_notify, lrmd_free_xml);
572 native->pending_notify = NULL;
575 free(native->remote->buffer);
576 native->remote->buffer = NULL;
579 native->psk_cred_c = NULL;
580 native->remote->tls_session = NULL;
583 if (native->callback) {
587 native->callback(&event);
595 const char *msg_type)
603 lrmd_tls_recv_reply(
lrmd_t * lrmd,
int total_timeout,
int expected_reply_id,
int *disconnected)
607 time_t start = time(NULL);
608 const char *msg_type = NULL;
610 int remaining_timeout = 0;
623 if (remaining_timeout) {
624 remaining_timeout = total_timeout - ((time(NULL) - start) * 1000);
626 remaining_timeout = total_timeout;
628 if (remaining_timeout <= 0) {
629 crm_err(
"Never received the expected reply during the timeout period, disconnecting.");
630 *disconnected = TRUE;
635 remaining_timeout) == ENOTCONN) {
636 *disconnected = TRUE;
638 *disconnected = FALSE;
642 crm_err(
"Unable to receive expected reply, disconnecting.");
643 *disconnected = TRUE;
645 }
else if (*disconnected) {
656 crm_err(
"Empty msg type received while waiting for reply");
662 native->pending_notify = g_list_append(native->pending_notify, xml);
663 if (native->process_notify) {
670 crm_err(
"Expected a reply, got %s", msg_type);
673 }
else if (reply_id != expected_reply_id) {
674 if (native->expected_late_replies > 0) {
675 native->expected_late_replies--;
677 crm_err(
"Got outdated reply, expected id %d got id %d", expected_reply_id, reply_id);
684 if (native->remote->buffer && native->process_notify) {
692 lrmd_tls_send(
lrmd_t * lrmd, xmlNode * msg)
697 global_remote_msg_id++;
698 if (global_remote_msg_id <= 0) {
699 global_remote_msg_id = 1;
704 crm_err(
"Disconnecting because TLS message could not be sent to "
706 lrmd_tls_disconnect(lrmd);
713 lrmd_tls_send_recv(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
716 int disconnected = 0;
719 if (lrmd_tls_connected(lrmd) == FALSE) {
723 rc = lrmd_tls_send(lrmd, msg);
728 xml = lrmd_tls_recv_reply(lrmd,
timeout, global_remote_msg_id, &disconnected);
731 crm_err(
"Pacemaker Remote disconnected while waiting for reply to request id %d",
732 global_remote_msg_id);
733 lrmd_tls_disconnect(lrmd);
736 crm_err(
"Did not receive reply from Pacemaker Remote for request id %d (timeout %dms)",
737 global_remote_msg_id,
timeout);
752 lrmd_send_xml(
lrmd_t * lrmd, xmlNode * msg,
int timeout, xmlNode ** reply)
757 switch (native->type) {
761 #ifdef HAVE_GNUTLS_GNUTLS_H
762 case PCMK__CLIENT_TLS:
763 rc = lrmd_tls_send_recv(lrmd, msg,
timeout, reply);
767 crm_err(
"Unsupported connection type: %d", native->type);
774 lrmd_send_xml_no_reply(
lrmd_t * lrmd, xmlNode * msg)
779 switch (native->type) {
783 #ifdef HAVE_GNUTLS_GNUTLS_H
784 case PCMK__CLIENT_TLS:
785 rc = lrmd_tls_send(lrmd, msg);
790 native->expected_late_replies++;
795 crm_err(
"Unsupported connection type: %d", native->type);
802 lrmd_api_is_connected(
lrmd_t * lrmd)
806 switch (native->type) {
810 #ifdef HAVE_GNUTLS_GNUTLS_H
811 case PCMK__CLIENT_TLS:
812 return lrmd_tls_connected(lrmd);
816 crm_err(
"Unsupported connection type: %d", native->type);
841 lrmd_send_command(
lrmd_t *lrmd,
const char *op, xmlNode *
data,
842 xmlNode **output_data,
int timeout,
847 xmlNode *op_msg = NULL;
848 xmlNode *op_reply = NULL;
850 if (!lrmd_api_is_connected(lrmd)) {
855 crm_err(
"No operation specified");
861 crm_trace(
"Sending %s op to executor", op);
863 op_msg = lrmd_create_op(native->token, op,
data,
timeout, options);
865 if (op_msg == NULL) {
870 rc = lrmd_send_xml(lrmd, op_msg,
timeout, &op_reply);
872 rc = lrmd_send_xml_no_reply(lrmd, op_msg);
881 }
else if(op_reply == NULL) {
896 *output_data = op_reply;
901 if (lrmd_api_is_connected(lrmd) == FALSE) {
902 crm_err(
"Executor disconnected");
911 lrmd_api_poke_connection(
lrmd_t * lrmd)
935 value = g_hash_table_lookup(hash,
"stonith-watchdog-timeout");
946 lrmd_handshake(
lrmd_t * lrmd,
const char *
name)
950 xmlNode *reply = NULL;
959 if (native->proxy_callback) {
963 rc = lrmd_send_xml(lrmd, hello, -1, &reply);
966 crm_perror(LOG_DEBUG,
"Couldn't complete registration with the executor API: %d",
rc);
968 }
else if (reply == NULL) {
969 crm_err(
"Did not receive registration reply");
979 crm_err(
"Executor protocol version mismatch between client (%s) and server (%s)",
984 crm_err(
"Invalid registration message: %s", msg_type);
987 }
else if (tmp_ticket == NULL) {
988 crm_err(
"No registration token provided");
992 crm_trace(
"Obtained registration token: %s", tmp_ticket);
993 native->token = strdup(tmp_ticket);
1003 lrmd_api_disconnect(lrmd);
1009 lrmd_ipc_connect(
lrmd_t * lrmd,
int *fd)
1016 .destroy = lrmd_ipc_connection_destroy
1019 crm_info(
"Connecting to executor");
1026 }
else if (native->ipc) {
1027 crm_perror(LOG_ERR,
"Connection to executor failed");
1035 if (native->ipc == NULL) {
1036 crm_debug(
"Could not connect to the executor API");
1043 #ifdef HAVE_GNUTLS_GNUTLS_H
1045 copy_gnutls_datum(gnutls_datum_t *dest, gnutls_datum_t *source)
1047 dest->data = gnutls_malloc(source->size);
1049 memcpy(dest->data, source->data, source->size);
1050 dest->size = source->size;
1054 clear_gnutls_datum(gnutls_datum_t *datum)
1056 gnutls_free(datum->data);
1061 #define KEY_READ_LEN 256
1064 set_key(gnutls_datum_t * key,
const char *location)
1067 size_t buf_len = KEY_READ_LEN;
1068 static gnutls_datum_t key_cache = { 0, };
1069 static time_t key_cache_updated = 0;
1071 if (location == NULL) {
1075 if (key_cache.data != NULL) {
1076 if ((time(NULL) - key_cache_updated) < 60) {
1077 copy_gnutls_datum(key, &key_cache);
1078 crm_debug(
"Using cached Pacemaker Remote key");
1081 clear_gnutls_datum(&key_cache);
1082 key_cache_updated = 0;
1083 crm_debug(
"Cleared Pacemaker Remote key cache");
1087 stream = fopen(location,
"r");
1092 key->data = gnutls_malloc(buf_len);
1094 while (!feof(stream)) {
1095 int next = fgetc(stream);
1098 if (!feof(stream)) {
1099 crm_err(
"Error reading Pacemaker Remote key; copy in memory may be corrupted");
1103 if (key->size == buf_len) {
1104 buf_len = key->size + KEY_READ_LEN;
1105 key->data = gnutls_realloc(key->data, buf_len);
1108 key->data[key->size++] = (
unsigned char) next;
1112 if (key->size == 0) {
1113 clear_gnutls_datum(key);
1117 if (key_cache.data == NULL) {
1118 copy_gnutls_datum(&key_cache, key);
1119 key_cache_updated = time(NULL);
1120 crm_debug(
"Cached Pacemaker Remote key");
1127 lrmd_tls_set_key(gnutls_datum_t * key)
1129 const char *specific_location = getenv(
"PCMK_authkey_location");
1131 if (set_key(key, specific_location) == 0) {
1132 crm_debug(
"Using custom authkey location %s", specific_location);
1135 }
else if (specific_location) {
1136 crm_err(
"No valid Pacemaker Remote key found at %s, trying default location", specific_location);
1149 lrmd_gnutls_global_init(
void)
1151 static int gnutls_init = 0;
1154 crm_gnutls_global_init();
1161 report_async_connection_result(
lrmd_t * lrmd,
int rc)
1165 if (native->callback) {
1168 event.remote_nodename = native->remote_nodename;
1169 event.connection_rc =
rc;
1170 native->callback(&event);
1174 #ifdef HAVE_GNUTLS_GNUTLS_H
1178 return pcmk__tls_client_handshake(remote, LRMD_CLIENT_HANDSHAKE_TIMEOUT);
1182 lrmd_tcp_connect_cb(
void *userdata,
int rc,
int sock)
1189 .destroy = lrmd_tls_connection_destroy,
1191 gnutls_datum_t psk_key = { NULL, 0 };
1193 native->async_timer = 0;
1196 lrmd_tls_connection_destroy(lrmd);
1197 crm_info(
"Could not connect to Pacemaker Remote at %s:%d: %s "
1208 native->sock = sock;
1210 rc = lrmd_tls_set_key(&psk_key);
1212 crm_warn(
"Could not set key for Pacemaker Remote at %s:%d " CRM_XS " rc=%d",
1213 native->server, native->port,
rc);
1214 lrmd_tls_connection_destroy(lrmd);
1215 report_async_connection_result(lrmd,
rc);
1219 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1221 gnutls_free(psk_key.data);
1223 native->remote->tls_session = pcmk__new_tls_session(sock, GNUTLS_CLIENT,
1225 native->psk_cred_c);
1226 if (native->remote->tls_session == NULL) {
1227 lrmd_tls_connection_destroy(lrmd);
1228 report_async_connection_result(lrmd, -EPROTO);
1232 if (lrmd__tls_client_handshake(native->remote) !=
pcmk_rc_ok) {
1233 crm_warn(
"Disconnecting after TLS handshake with Pacemaker Remote server %s:%d failed",
1234 native->server, native->port);
1235 gnutls_deinit(*native->remote->tls_session);
1236 gnutls_free(native->remote->tls_session);
1237 native->remote->tls_session = NULL;
1238 lrmd_tls_connection_destroy(lrmd);
1243 crm_info(
"TLS connection to Pacemaker Remote server %s:%d succeeded",
1244 native->server, native->port);
1247 native->server, native->port);
1253 rc = lrmd_handshake(lrmd,
name);
1256 report_async_connection_result(lrmd,
rc);
1267 lrmd_gnutls_global_init();
1270 &(native->sock), lrmd, lrmd_tcp_connect_cb);
1272 crm_warn(
"Pacemaker Remote connection to %s:%s failed: %s "
1277 native->async_timer = timer_id;
1282 lrmd_tls_connect(
lrmd_t * lrmd,
int *fd)
1286 .destroy = lrmd_tls_connection_destroy,
1291 gnutls_datum_t psk_key = { NULL, 0 };
1293 lrmd_gnutls_global_init();
1297 &(native->sock), NULL, NULL);
1299 crm_warn(
"Pacemaker Remote connection to %s:%s failed: %s "
1302 lrmd_tls_connection_destroy(lrmd);
1306 rc = lrmd_tls_set_key(&psk_key);
1308 lrmd_tls_connection_destroy(lrmd);
1312 gnutls_psk_allocate_client_credentials(&native->psk_cred_c);
1314 gnutls_free(psk_key.data);
1316 native->remote->tls_session = pcmk__new_tls_session(native->sock, GNUTLS_CLIENT,
1318 native->psk_cred_c);
1319 if (native->remote->tls_session == NULL) {
1320 lrmd_tls_connection_destroy(lrmd);
1324 if (lrmd__tls_client_handshake(native->remote) !=
pcmk_rc_ok) {
1325 crm_err(
"Session creation for %s:%d failed", native->server, native->port);
1326 gnutls_deinit(*native->remote->tls_session);
1327 gnutls_free(native->remote->tls_session);
1328 native->remote->tls_session = NULL;
1329 lrmd_tls_connection_destroy(lrmd);
1333 crm_info(
"Client TLS connection established with Pacemaker Remote server %s:%d", native->server,
1340 native->server, native->port);
1352 lrmd_api_connect(
lrmd_t * lrmd,
const char *
name,
int *fd)
1357 switch (native->type) {
1359 rc = lrmd_ipc_connect(lrmd, fd);
1361 #ifdef HAVE_GNUTLS_GNUTLS_H
1362 case PCMK__CLIENT_TLS:
1363 rc = lrmd_tls_connect(lrmd, fd);
1367 crm_err(
"Unsupported connection type: %d", native->type);
1371 rc = lrmd_handshake(lrmd,
name);
1383 CRM_CHECK(native && native->callback,
return -1);
1385 switch (native->type) {
1389 rc = lrmd_api_connect(lrmd,
name, NULL);
1391 report_async_connection_result(lrmd,
rc);
1394 #ifdef HAVE_GNUTLS_GNUTLS_H
1395 case PCMK__CLIENT_TLS:
1396 rc = lrmd_tls_connect_async(lrmd,
timeout);
1399 report_async_connection_result(lrmd,
rc);
1404 crm_err(
"Unsupported connection type: %d", native->type);
1411 lrmd_ipc_disconnect(
lrmd_t * lrmd)
1415 if (native->source != NULL) {
1418 native->source = NULL;
1421 }
else if (native->ipc) {
1431 #ifdef HAVE_GNUTLS_GNUTLS_H
1433 lrmd_tls_disconnect(
lrmd_t * lrmd)
1437 if (native->remote->tls_session) {
1438 gnutls_bye(*native->remote->tls_session, GNUTLS_SHUT_RDWR);
1439 gnutls_deinit(*native->remote->tls_session);
1440 gnutls_free(native->remote->tls_session);
1441 native->remote->tls_session = 0;
1444 if (native->async_timer) {
1445 g_source_remove(native->async_timer);
1446 native->async_timer = 0;
1449 if (native->source != NULL) {
1452 native->source = NULL;
1454 }
else if (native->sock) {
1455 close(native->sock);
1459 if (native->pending_notify) {
1460 g_list_free_full(native->pending_notify, lrmd_free_xml);
1461 native->pending_notify = NULL;
1467 lrmd_api_disconnect(
lrmd_t * lrmd)
1471 crm_info(
"Disconnecting %s %s executor connection",
1473 (native->remote_nodename? native->remote_nodename :
"local"));
1474 switch (native->type) {
1476 lrmd_ipc_disconnect(lrmd);
1478 #ifdef HAVE_GNUTLS_GNUTLS_H
1479 case PCMK__CLIENT_TLS:
1480 lrmd_tls_disconnect(lrmd);
1484 crm_err(
"Unsupported connection type: %d", native->type);
1487 free(native->token);
1488 native->token = NULL;
1490 free(native->peer_version);
1491 native->peer_version = NULL;
1496 lrmd_api_register_rsc(
lrmd_t * lrmd,
1502 xmlNode *
data = NULL;
1504 if (!
class || !
type || !rsc_id) {
1540 const char *provider,
const char *
type)
1546 rsc_info->
id = strdup(rsc_id);
1550 rsc_info->
standard = strdup(standard);
1554 rsc_info->
provider = strdup(provider);
1578 free(rsc_info->
type);
1589 xmlNode *output = NULL;
1590 const char *
class = NULL;
1591 const char *provider = NULL;
1592 const char *
type = NULL;
1607 if (!
class || !
type) {
1634 lrmd_api_get_recurring_ops(
lrmd_t *lrmd,
const char *rsc_id,
int timeout_ms,
1637 xmlNode *
data = NULL;
1638 xmlNode *output_xml = NULL;
1641 if (output == NULL) {
1653 timeout_ms, options, TRUE);
1659 if ((
rc !=
pcmk_ok) || (output_xml == NULL)) {
1666 if (rsc_id == NULL) {
1667 crm_err(
"Could not parse recurring operation information from executor");
1676 op_info->
rsc_id = strdup(rsc_id);
1682 *output = g_list_prepend(*output, op_info);
1695 native->callback = callback;
1703 native->proxy_callback = callback;
1704 native->proxy_callback_userdata = userdata;
1708 lrmd_internal_proxy_dispatch(
lrmd_t *lrmd, xmlNode *msg)
1712 if (native->proxy_callback) {
1714 native->proxy_callback(lrmd, native->proxy_callback_userdata, msg);
1727 return lrmd_send_xml_no_reply(lrmd, msg);
1731 stonith_get_metadata(
const char *provider,
const char *
type,
char **output)
1736 if (stonith_api == NULL) {
1737 crm_err(
"Could not get fence agent meta-data: API memory allocation failed");
1742 provider, output, 0);
1743 if ((
rc ==
pcmk_ok) && (*output == NULL)) {
1746 stonith_api->
cmds->
free(stonith_api);
1751 lrmd_api_get_metadata(
lrmd_t *lrmd,
const char *standard,
const char *provider,
1752 const char *
type,
char **output,
1756 output, options, NULL);
1760 lrmd_api_get_metadata_params(
lrmd_t *lrmd,
const char *standard,
1761 const char *provider,
const char *
type,
1766 GHashTable *params_table = NULL;
1768 if (!standard || !
type) {
1775 return stonith_get_metadata(provider,
type, output);
1778 params_table = crm_str_table_new();
1780 g_hash_table_insert(params_table, strdup(param->key), strdup(param->value));
1789 crm_err(
"Unable to retrieve meta-data for %s:%s:%s",
1790 standard, provider,
type);
1795 crm_err(
"Failed to retrieve meta-data for %s:%s:%s",
1796 standard, provider,
type);
1801 if (!
action->stdout_data) {
1802 crm_err(
"Failed to receive meta-data for %s:%s:%s",
1803 standard, provider,
type);
1808 *output = strdup(
action->stdout_data);
1815 lrmd_api_exec(
lrmd_t *lrmd,
const char *rsc_id,
const char *
action,
1816 const char *userdata, guint interval_ms,
1834 for (tmp = params; tmp; tmp = tmp->
next) {
1847 lrmd_api_exec_alert(
lrmd_t *lrmd,
const char *alert_id,
const char *alert_path,
1860 for (tmp = params; tmp; tmp = tmp->
next) {
1873 lrmd_api_cancel(
lrmd_t *lrmd,
const char *rsc_id,
const char *
action,
1896 if (stonith_api == NULL) {
1897 crm_err(
"Could not list fence agents: API memory allocation failed");
1901 &stonith_resources, 0);
1902 stonith_api->
cmds->
free(stonith_api);
1904 for (dIter = stonith_resources; dIter; dIter = dIter->
next) {
1907 *resources = lrmd_list_add(*resources, dIter->
value);
1916 lrmd_api_list_agents(
lrmd_t * lrmd,
lrmd_list_t ** resources,
const char *
class,
1917 const char *provider)
1920 int stonith_count = 0;
1929 for (gIter = agents; gIter != NULL; gIter = gIter->next) {
1930 *resources = lrmd_list_add(*resources, (
const char *)gIter->data);
1933 g_list_free_full(agents, free);
1940 if (stonith_count) {
1942 stonith_count = list_stonith_agents(resources);
1943 if (stonith_count > 0) {
1944 rc += stonith_count;
1948 crm_notice(
"No agents found for class %s",
class);
1949 rc = -EPROTONOSUPPORT;
1955 does_provider_have_agent(
const char *agent,
const char *provider,
const char *
class)
1958 GList *agents = NULL;
1962 for (gIter2 = agents; gIter2 != NULL; gIter2 = gIter2->next) {
1967 g_list_free_full(agents, free);
1973 lrmd_api_list_ocf_providers(
lrmd_t * lrmd,
const char *agent,
lrmd_list_t ** providers)
1976 char *provider = NULL;
1977 GList *ocf_providers = NULL;
1982 for (gIter = ocf_providers; gIter != NULL; gIter = gIter->next) {
1983 provider = gIter->data;
1984 if (!agent || does_provider_have_agent(agent, provider,
1986 *providers = lrmd_list_add(*providers, (
const char *)gIter->data);
1991 g_list_free_full(ocf_providers, free);
1999 GList *standards = NULL;
2004 for (gIter = standards; gIter != NULL; gIter = gIter->next) {
2005 *supported = lrmd_list_add(*supported, (
const char *)gIter->data);
2009 if (list_stonith_agents(NULL) > 0) {
2014 g_list_free_full(standards, free);
2024 new_lrmd = calloc(1,
sizeof(
lrmd_t));
2043 new_lrmd->
cmds->
exec = lrmd_api_exec;
2057 #ifdef HAVE_GNUTLS_GNUTLS_H
2061 if (!nodename && !server) {
2066 native->type = PCMK__CLIENT_TLS;
2067 native->remote_nodename = nodename ? strdup(nodename) : strdup(server);
2068 native->server = server ? strdup(server) : strdup(nodename);
2069 native->port = port;
2070 if (native->port == 0) {
2076 crm_err(
"Cannot communicate with Pacemaker Remote because GnuTLS is not enabled for this build");
2092 #ifdef HAVE_GNUTLS_GNUTLS_H
2093 free(native->server);
2095 free(native->remote_nodename);
2096 free(native->remote);
2097 free(native->token);
2098 free(native->peer_version);