summaryrefslogtreecommitdiffstats
path: root/daemons/fenced/pacemaker-fenced.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-03 13:39:28 +0000
commit7332b914bff2786ff70ccace103fc9ebdfb61a23 (patch)
tree3a8a60c4edba014c7e350be41839e3edbf2a315f /daemons/fenced/pacemaker-fenced.c
parentAdding debian version 2.1.7-1. (diff)
downloadpacemaker-7332b914bff2786ff70ccace103fc9ebdfb61a23.tar.xz
pacemaker-7332b914bff2786ff70ccace103fc9ebdfb61a23.zip
Merging upstream version 2.1.8~rc1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'daemons/fenced/pacemaker-fenced.c')
-rw-r--r--daemons/fenced/pacemaker-fenced.c392
1 files changed, 87 insertions, 305 deletions
diff --git a/daemons/fenced/pacemaker-fenced.c b/daemons/fenced/pacemaker-fenced.c
index 7c69fb8..5ba97b5 100644
--- a/daemons/fenced/pacemaker-fenced.c
+++ b/daemons/fenced/pacemaker-fenced.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2023 the Pacemaker project contributors
+ * Copyright 2009-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -22,7 +22,6 @@
#include <inttypes.h> // PRIu32, PRIx32
#include <crm/crm.h>
-#include <crm/msg_xml.h>
#include <crm/common/cmdline_internal.h>
#include <crm/common/ipc.h>
#include <crm/common/ipc_internal.h>
@@ -42,7 +41,7 @@
#define SUMMARY "daemon for executing fencing devices in a Pacemaker cluster"
char *stonith_our_uname = NULL;
-long stonith_watchdog_timeout_ms = 0;
+long long stonith_watchdog_timeout_ms = 0;
GList *stonith_watchdog_targets = NULL;
static GMainLoop *mainloop = NULL;
@@ -75,11 +74,11 @@ st_ipc_accept(qb_ipcs_connection_t * c, uid_t uid, gid_t gid)
if (stonith_shutdown_flag) {
crm_info("Ignoring new client [%d] during shutdown",
pcmk__client_pid(c));
- return -EPERM;
+ return -ECONNREFUSED;
}
if (pcmk__new_client(c, uid, gid) == NULL) {
- return -EIO;
+ return -ENOMEM;
}
return 0;
}
@@ -102,34 +101,31 @@ st_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size)
request = pcmk__client_data2xml(c, data, &id, &flags);
if (request == NULL) {
- pcmk__ipc_send_ack(c, id, flags, "nack", NULL, CRM_EX_PROTOCOL);
+ pcmk__ipc_send_ack(c, id, flags, PCMK__XE_NACK, NULL, CRM_EX_PROTOCOL);
return 0;
}
- op = crm_element_value(request, F_CRM_TASK);
+ op = crm_element_value(request, PCMK__XA_CRM_TASK);
if(pcmk__str_eq(op, CRM_OP_RM_NODE_CACHE, pcmk__str_casei)) {
- crm_xml_add(request, F_TYPE, T_STONITH_NG);
- crm_xml_add(request, F_STONITH_OPERATION, op);
- crm_xml_add(request, F_STONITH_CLIENTID, c->id);
- crm_xml_add(request, F_STONITH_CLIENTNAME, pcmk__client_name(c));
- crm_xml_add(request, F_STONITH_CLIENTNODE, stonith_our_uname);
+ crm_xml_add(request, PCMK__XA_T, PCMK__VALUE_STONITH_NG);
+ crm_xml_add(request, PCMK__XA_ST_OP, op);
+ crm_xml_add(request, PCMK__XA_ST_CLIENTID, c->id);
+ crm_xml_add(request, PCMK__XA_ST_CLIENTNAME, pcmk__client_name(c));
+ crm_xml_add(request, PCMK__XA_ST_CLIENTNODE, stonith_our_uname);
- send_cluster_message(NULL, crm_msg_stonith_ng, request, FALSE);
+ pcmk__cluster_send_message(NULL, crm_msg_stonith_ng, request);
free_xml(request);
return 0;
}
if (c->name == NULL) {
- const char *value = crm_element_value(request, F_STONITH_CLIENTNAME);
+ const char *value = crm_element_value(request, PCMK__XA_ST_CLIENTNAME);
- if (value == NULL) {
- value = "unknown";
- }
- c->name = crm_strdup_printf("%s.%u", value, c->pid);
+ c->name = crm_strdup_printf("%s.%u", pcmk__s(value, "unknown"), c->pid);
}
- crm_element_value_int(request, F_STONITH_CALLOPTS, &call_options);
+ crm_element_value_int(request, PCMK__XA_ST_CALLOPT, &call_options);
crm_trace("Flags %#08" PRIx32 "/%#08x for command %" PRIu32
" from client %s", flags, call_options, id, pcmk__client_name(c));
@@ -139,9 +135,9 @@ st_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size)
c->request_id = id; /* Reply only to the last one */
}
- crm_xml_add(request, F_STONITH_CLIENTID, c->id);
- crm_xml_add(request, F_STONITH_CLIENTNAME, pcmk__client_name(c));
- crm_xml_add(request, F_STONITH_CLIENTNODE, stonith_our_uname);
+ crm_xml_add(request, PCMK__XA_ST_CLIENTID, c->id);
+ crm_xml_add(request, PCMK__XA_ST_CLIENTNAME, pcmk__client_name(c));
+ crm_xml_add(request, PCMK__XA_ST_CLIENTNODE, stonith_our_uname);
crm_log_xml_trace(request, "ipc-received");
stonith_command(c, id, flags, request, NULL);
@@ -177,10 +173,10 @@ st_ipc_destroy(qb_ipcs_connection_t * c)
static void
stonith_peer_callback(xmlNode * msg, void *private_data)
{
- const char *remote_peer = crm_element_value(msg, F_ORIG);
- const char *op = crm_element_value(msg, F_STONITH_OPERATION);
+ const char *remote_peer = crm_element_value(msg, PCMK__XA_SRC);
+ const char *op = crm_element_value(msg, PCMK__XA_ST_OP);
- if (pcmk__str_eq(op, "poke", pcmk__str_none)) {
+ if (pcmk__str_eq(op, STONITH_OP_POKE, pcmk__str_none)) {
return;
}
@@ -197,20 +193,19 @@ stonith_peer_ais_callback(cpg_handle_t handle,
uint32_t kind = 0;
xmlNode *xml = NULL;
const char *from = NULL;
- char *data = pcmk_message_common_cs(handle, nodeid, pid, msg, &kind, &from);
+ char *data = pcmk__cpg_message_data(handle, nodeid, pid, msg, &kind, &from);
if(data == NULL) {
return;
}
if (kind == crm_class_cluster) {
- xml = string2xml(data);
+ xml = pcmk__xml_parse(data);
if (xml == NULL) {
crm_err("Invalid XML: '%.120s'", data);
free(data);
return;
}
- crm_xml_add(xml, F_ORIG, from);
- /* crm_xml_add_int(xml, F_SEQ, wrapper->id); */
+ crm_xml_add(xml, PCMK__XA_SRC, from);
stonith_peer_callback(xml, NULL);
}
@@ -257,7 +252,7 @@ do_local_reply(const xmlNode *notify_src, pcmk__client_t *client,
uint64_t
get_stonith_flag(const char *name)
{
- if (pcmk__str_eq(name, T_STONITH_NOTIFY_FENCE, pcmk__str_casei)) {
+ if (pcmk__str_eq(name, PCMK__VALUE_ST_NOTIFY_FENCE, pcmk__str_none)) {
return st_callback_notify_fence;
} else if (pcmk__str_eq(name, STONITH_OP_DEVICE_ADD, pcmk__str_casei)) {
@@ -266,10 +261,12 @@ get_stonith_flag(const char *name)
} else if (pcmk__str_eq(name, STONITH_OP_DEVICE_DEL, pcmk__str_casei)) {
return st_callback_device_del;
- } else if (pcmk__str_eq(name, T_STONITH_NOTIFY_HISTORY, pcmk__str_casei)) {
+ } else if (pcmk__str_eq(name, PCMK__VALUE_ST_NOTIFY_HISTORY,
+ pcmk__str_none)) {
return st_callback_notify_history;
- } else if (pcmk__str_eq(name, T_STONITH_NOTIFY_HISTORY_SYNCED, pcmk__str_casei)) {
+ } else if (pcmk__str_eq(name, PCMK__VALUE_ST_NOTIFY_HISTORY_SYNCED,
+ pcmk__str_none)) {
return st_callback_notify_history_synced;
}
@@ -287,7 +284,7 @@ stonith_notify_client(gpointer key, gpointer value, gpointer user_data)
CRM_CHECK(client != NULL, return);
CRM_CHECK(update_msg != NULL, return);
- type = crm_element_value(update_msg, F_SUBTYPE);
+ type = crm_element_value(update_msg, PCMK__XA_SUBT);
CRM_CHECK(type != NULL, crm_log_xml_err(update_msg, "notify"); return);
if (client->ipcs == NULL) {
@@ -325,10 +322,10 @@ do_stonith_async_timeout_update(const char *client_id, const char *call_id, int
return;
}
- notify_data = create_xml_node(NULL, T_STONITH_TIMEOUT_VALUE);
- crm_xml_add(notify_data, F_TYPE, T_STONITH_TIMEOUT_VALUE);
- crm_xml_add(notify_data, F_STONITH_CALLID, call_id);
- crm_xml_add_int(notify_data, F_STONITH_TIMEOUT, timeout);
+ notify_data = pcmk__xe_create(NULL, PCMK__XE_ST_ASYNC_TIMEOUT_VALUE);
+ crm_xml_add(notify_data, PCMK__XA_T, PCMK__VALUE_ST_ASYNC_TIMEOUT_VALUE);
+ crm_xml_add(notify_data, PCMK__XA_ST_CALLID, call_id);
+ crm_xml_add_int(notify_data, PCMK__XA_ST_TIMEOUT, timeout);
crm_trace("timeout update is %d for client %s and call id %s", timeout, client_id, call_id);
@@ -352,17 +349,19 @@ fenced_send_notification(const char *type, const pcmk__action_result_t *result,
xmlNode *data)
{
/* TODO: Standardize the contents of data */
- xmlNode *update_msg = create_xml_node(NULL, "notify");
+ xmlNode *update_msg = pcmk__xe_create(NULL, PCMK__XE_NOTIFY);
CRM_LOG_ASSERT(type != NULL);
- crm_xml_add(update_msg, F_TYPE, T_STONITH_NOTIFY);
- crm_xml_add(update_msg, F_SUBTYPE, type);
- crm_xml_add(update_msg, F_STONITH_OPERATION, type);
+ crm_xml_add(update_msg, PCMK__XA_T, PCMK__VALUE_ST_NOTIFY);
+ crm_xml_add(update_msg, PCMK__XA_SUBT, type);
+ crm_xml_add(update_msg, PCMK__XA_ST_OP, type);
stonith__xe_set_result(update_msg, result);
if (data != NULL) {
- add_message_xml(update_msg, F_STONITH_CALLDATA, data);
+ xmlNode *wrapper = pcmk__xe_create(update_msg, PCMK__XE_ST_CALLDATA);
+
+ pcmk__xml_copy(wrapper, data);
}
crm_trace("Notifying clients");
@@ -375,60 +374,25 @@ fenced_send_notification(const char *type, const pcmk__action_result_t *result,
* \internal
* \brief Send notifications for a configuration change to subscribed clients
*
- * \param[in] op Notification type (STONITH_OP_DEVICE_ADD,
- * STONITH_OP_DEVICE_DEL, STONITH_OP_LEVEL_ADD, or
- * STONITH_OP_LEVEL_DEL)
- * \param[in] result Operation result
- * \param[in] desc Description of what changed
- * \param[in] active Current number of devices or topologies in use
- */
-static void
-send_config_notification(const char *op, const pcmk__action_result_t *result,
- const char *desc, int active)
-{
- xmlNode *notify_data = create_xml_node(NULL, op);
-
- CRM_CHECK(notify_data != NULL, return);
-
- crm_xml_add(notify_data, F_STONITH_DEVICE, desc);
- crm_xml_add_int(notify_data, F_STONITH_ACTIVE, active);
-
- fenced_send_notification(op, result, notify_data);
- free_xml(notify_data);
-}
-
-/*!
- * \internal
- * \brief Send notifications for a device change to subscribed clients
- *
- * \param[in] op Notification type (STONITH_OP_DEVICE_ADD or
- * STONITH_OP_DEVICE_DEL)
+ * \param[in] op Notification type (\c STONITH_OP_DEVICE_ADD,
+ * \c STONITH_OP_DEVICE_DEL, \c STONITH_OP_LEVEL_ADD, or
+ * \c STONITH_OP_LEVEL_DEL)
* \param[in] result Operation result
- * \param[in] desc ID of device that changed
+ * \param[in] desc Description of what changed (either device ID or string
+ * representation of level
+ * (<tt><target>[<level_index>]</tt>))
*/
void
-fenced_send_device_notification(const char *op,
+fenced_send_config_notification(const char *op,
const pcmk__action_result_t *result,
const char *desc)
{
- send_config_notification(op, result, desc, g_hash_table_size(device_list));
-}
+ xmlNode *notify_data = pcmk__xe_create(NULL, op);
-/*!
- * \internal
- * \brief Send notifications for a topology level change to subscribed clients
- *
- * \param[in] op Notification type (STONITH_OP_LEVEL_ADD or
- * STONITH_OP_LEVEL_DEL)
- * \param[in] result Operation result
- * \param[in] desc String representation of level (<target>[<level_index>])
- */
-void
-fenced_send_level_notification(const char *op,
- const pcmk__action_result_t *result,
- const char *desc)
-{
- send_config_notification(op, result, desc, g_hash_table_size(topology));
+ crm_xml_add(notify_data, PCMK__XA_ST_DEVICE_ID, desc);
+
+ fenced_send_notification(op, result, notify_data);
+ free_xml(notify_data);
}
/*!
@@ -466,7 +430,7 @@ stonith_cleanup(void)
qb_ipcs_destroy(ipcs);
}
- crm_peer_destroy();
+ pcmk__cluster_destroy_node_caches();
pcmk__client_cleanup();
free_stonith_remote_op_list();
free_topology_list();
@@ -512,221 +476,34 @@ st_peer_update_callback(enum crm_status_type type, crm_node_t * node, const void
* This is a hack until we can send to a nodeid and/or we fix node name lookups
* These messages are ignored in stonith_peer_callback()
*/
- xmlNode *query = create_xml_node(NULL, "stonith_command");
+ xmlNode *query = pcmk__xe_create(NULL, PCMK__XE_STONITH_COMMAND);
- crm_xml_add(query, F_XML_TAGNAME, "stonith_command");
- crm_xml_add(query, F_TYPE, T_STONITH_NG);
- crm_xml_add(query, F_STONITH_OPERATION, "poke");
+ crm_xml_add(query, PCMK__XA_T, PCMK__VALUE_STONITH_NG);
+ crm_xml_add(query, PCMK__XA_ST_OP, STONITH_OP_POKE);
crm_debug("Broadcasting our uname because of node %u", node->id);
- send_cluster_message(NULL, crm_msg_stonith_ng, query, FALSE);
+ pcmk__cluster_send_message(NULL, crm_msg_stonith_ng, query);
free_xml(query);
}
}
-static pcmk__cluster_option_t fencer_options[] = {
- /* name, old name, type, allowed values,
- * default value, validator,
- * short description,
- * long description
- */
- {
- PCMK_STONITH_HOST_ARGUMENT, NULL, "string", NULL, "port", NULL,
- N_("Advanced use only: An alternate parameter to supply instead of 'port'"),
- N_("some devices do not support the "
- "standard 'port' parameter or may provide additional ones. Use "
- "this to specify an alternate, device-specific, parameter "
- "that should indicate the machine to be fenced. A value of "
- "none can be used to tell the cluster not to supply any "
- "additional parameters.")
- },
- {
- PCMK_STONITH_HOST_MAP,NULL, "string", NULL, "", NULL,
- N_("A mapping of host names to ports numbers for devices that do not support host names."),
- N_("Eg. node1:1;node2:2,3 would tell the cluster to use port 1 for node1 and ports 2 and 3 for node2")
- },
- {
- PCMK_STONITH_HOST_LIST,NULL, "string", NULL, "", NULL,
- N_("Eg. node1,node2,node3"),
- N_("A list of machines controlled by "
- "this device (Optional unless pcmk_host_list=static-list)")
- },
- {
- PCMK_STONITH_HOST_CHECK,NULL, "string", NULL, "dynamic-list", NULL,
- N_("How to determine which machines are controlled by the device."),
- N_("Allowed values: dynamic-list "
- "(query the device via the 'list' command), static-list "
- "(check the pcmk_host_list attribute), status "
- "(query the device via the 'status' command), "
- "none (assume every device can fence every "
- "machine)")
- },
- {
- PCMK_STONITH_DELAY_MAX,NULL, "time", NULL, "0s", NULL,
- N_("Enable a base delay for fencing actions and specify base delay value."),
- N_("Enable a delay of no more than the "
- "time specified before executing fencing actions. Pacemaker "
- "derives the overall delay by taking the value of "
- "pcmk_delay_base and adding a random delay value such "
- "that the sum is kept below this maximum.")
- },
- {
- PCMK_STONITH_DELAY_BASE,NULL, "string", NULL, "0s", NULL,
- N_("Enable a base delay for "
- "fencing actions and specify base delay value."),
- N_("This enables a static delay for "
- "fencing actions, which can help avoid \"death matches\" where "
- "two nodes try to fence each other at the same time. If "
- "pcmk_delay_max is also used, a random delay will be "
- "added such that the total delay is kept below that value."
- "This can be set to a single time value to apply to any node "
- "targeted by this device (useful if a separate device is "
- "configured for each target), or to a node map (for example, "
- "\"node1:1s;node2:5\") to set a different value per target.")
- },
- {
- PCMK_STONITH_ACTION_LIMIT,NULL, "integer", NULL, "1", NULL,
- N_("The maximum number of actions can be performed in parallel on this device"),
- N_("Cluster property concurrent-fencing=true needs to be configured first."
- "Then use this to specify the maximum number of actions can be performed in parallel on this device. -1 is unlimited.")
- },
- {
- "pcmk_reboot_action", NULL, "string", NULL,
- PCMK_ACTION_REBOOT, NULL,
- N_("Advanced use only: An alternate command to run instead of 'reboot'"),
- N_("Some devices do not support the standard commands or may provide additional ones.\n"
- "Use this to specify an alternate, device-specific, command that implements the \'reboot\' action.")
- },
- {
- "pcmk_reboot_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for reboot actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal."
- "Use this to specify an alternate, device-specific, timeout for \'reboot\' actions.")
- },
- {
- "pcmk_reboot_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the 'reboot' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'reboot\' actions before giving up.")
- },
- {
- "pcmk_off_action", NULL, "string", NULL,
- PCMK_ACTION_OFF, NULL,
- N_("Advanced use only: An alternate command to run instead of \'off\'"),
- N_("Some devices do not support the standard commands or may provide additional ones."
- "Use this to specify an alternate, device-specific, command that implements the \'off\' action.")
- },
- {
- "pcmk_off_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for off actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal."
- "Use this to specify an alternate, device-specific, timeout for \'off\' actions.")
- },
- {
- "pcmk_off_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the 'off' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'off\' actions before giving up.")
- },
- {
- "pcmk_on_action", NULL, "string", NULL,
- PCMK_ACTION_ON, NULL,
- N_("Advanced use only: An alternate command to run instead of 'on'"),
- N_("Some devices do not support the standard commands or may provide additional ones."
- "Use this to specify an alternate, device-specific, command that implements the \'on\' action.")
- },
- {
- "pcmk_on_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for on actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal."
- "Use this to specify an alternate, device-specific, timeout for \'on\' actions.")
- },
- {
- "pcmk_on_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the 'on' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'on\' actions before giving up.")
- },
- {
- "pcmk_list_action",NULL, "string", NULL,
- PCMK_ACTION_LIST, NULL,
- N_("Advanced use only: An alternate command to run instead of \'list\'"),
- N_("Some devices do not support the standard commands or may provide additional ones."
- "Use this to specify an alternate, device-specific, command that implements the \'list\' action.")
- },
- {
- "pcmk_list_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for list actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal."
- "Use this to specify an alternate, device-specific, timeout for \'list\' actions.")
- },
- {
- "pcmk_list_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the \'list\' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'list\' actions before giving up.")
- },
- {
- "pcmk_monitor_action", NULL, "string", NULL,
- PCMK_ACTION_MONITOR, NULL,
- N_("Advanced use only: An alternate command to run instead of \'monitor\'"),
- N_("Some devices do not support the standard commands or may provide additional ones."
- "Use this to specify an alternate, device-specific, command that implements the \'monitor\' action.")
- },
- {
- "pcmk_monitor_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for monitor actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal.\n"
- "Use this to specify an alternate, device-specific, timeout for \'monitor\' actions.")
- },
- {
- "pcmk_monitor_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the \'monitor\' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'monitor\' actions before giving up.")
- },
- {
- "pcmk_status_action", NULL, "string", NULL,
- PCMK_ACTION_STATUS, NULL,
- N_("Advanced use only: An alternate command to run instead of \'status\'"),
- N_("Some devices do not support the standard commands or may provide additional ones."
- "Use this to specify an alternate, device-specific, command that implements the \'status\' action.")
- },
- {
- "pcmk_status_timeout",NULL, "time", NULL, "60s", NULL,
- N_("Advanced use only: Specify an alternate timeout to use for status actions instead of stonith-timeout"),
- N_("Some devices need much more/less time to complete than normal."
- "Use this to specify an alternate, device-specific, timeout for \'status\' actions.")
- },
- {
- "pcmk_status_retries",NULL, "integer", NULL, "2", NULL,
- N_("Advanced use only: The maximum number of times to retry the \'status\' command within the timeout period"),
- N_("Some devices do not support multiple connections."
- " Operations may 'fail' if the device is busy with another task so Pacemaker will automatically retry the operation, if there is time remaining."
- " Use this option to alter the number of times Pacemaker retries \'status\' actions before giving up.")
- },
-};
-
-void
+/* @COMPAT Deprecated since 2.1.8. Use pcmk_list_fence_attrs() or
+ * crm_resource --list-options=fencing instead of querying daemon metadata.
+ */
+static int
fencer_metadata(void)
{
+ const char *name = "pacemaker-fenced";
const char *desc_short = N_("Instance attributes available for all "
- "\"stonith\"-class resources");
- const char *desc_long = N_("Instance attributes available for all \"stonith\"-"
- "class resources and used by Pacemaker's fence "
- "daemon, formerly known as stonithd");
-
- gchar *s = pcmk__format_option_metadata("pacemaker-fenced", desc_short,
- desc_long, fencer_options,
- PCMK__NELEM(fencer_options));
- printf("%s", s);
- g_free(s);
+ "\"stonith\"-class resources");
+ const char *desc_long = N_("Instance attributes available for all "
+ "\"stonith\"-class resources and used by "
+ "Pacemaker's fence daemon, formerly known as "
+ "stonithd");
+
+ return pcmk__daemon_metadata(out, name, desc_short, desc_long,
+ pcmk__opt_fencing);
}
static GOptionEntry entries[] = {
@@ -747,8 +524,7 @@ build_arg_context(pcmk__common_args_t *args, GOptionGroup **group)
{
GOptionContext *context = NULL;
- context = pcmk__build_arg_context(args, "text (default), xml", group,
- "[metadata]");
+ context = pcmk__build_arg_context(args, "text (default), xml", group, NULL);
pcmk__add_main_args(context, entries);
return context;
}
@@ -757,7 +533,7 @@ int
main(int argc, char **argv)
{
int rc = pcmk_rc_ok;
- crm_cluster_t *cluster = NULL;
+ pcmk_cluster_t *cluster = NULL;
crm_ipc_t *old_instance = NULL;
GError *error = NULL;
@@ -791,7 +567,13 @@ main(int argc, char **argv)
if ((g_strv_length(processed_args) >= 2)
&& pcmk__str_eq(processed_args[1], "metadata", pcmk__str_none)) {
- fencer_metadata();
+
+ rc = fencer_metadata();
+ if (rc != pcmk_rc_ok) {
+ exit_code = CRM_EX_FATAL;
+ g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
+ "Unable to display metadata: %s", pcmk_rc_str(rc));
+ }
goto done;
}
@@ -826,7 +608,7 @@ main(int argc, char **argv)
mainloop_add_signal(SIGTERM, stonith_shutdown);
- crm_peer_init();
+ pcmk__cluster_init_node_caches();
rc = fenced_scheduler_init();
if (rc != pcmk_rc_ok) {
@@ -840,16 +622,16 @@ main(int argc, char **argv)
if (!stand_alone) {
#if SUPPORT_COROSYNC
- if (is_corosync_cluster()) {
- cluster->destroy = stonith_peer_cs_destroy;
- cluster->cpg.cpg_deliver_fn = stonith_peer_ais_callback;
- cluster->cpg.cpg_confchg_fn = pcmk_cpg_membership;
+ if (pcmk_get_cluster_layer() == pcmk_cluster_layer_corosync) {
+ pcmk_cluster_set_destroy_fn(cluster, stonith_peer_cs_destroy);
+ pcmk_cpg_set_deliver_fn(cluster, stonith_peer_ais_callback);
+ pcmk_cpg_set_confchg_fn(cluster, pcmk__cpg_confchg_cb);
}
#endif // SUPPORT_COROSYNC
- crm_set_status_callback(&st_peer_update_callback);
+ pcmk__cluster_set_status_callback(&st_peer_update_callback);
- if (crm_cluster_connect(cluster) == FALSE) {
+ if (pcmk_cluster_connect(cluster) != pcmk_rc_ok) {
exit_code = CRM_EX_FATAL;
crm_crit("Cannot sign in to the cluster... terminating");
goto done;