summaryrefslogtreecommitdiffstats
path: root/lib/fencing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fencing')
-rw-r--r--lib/fencing/Makefile.am12
-rw-r--r--lib/fencing/st_client.c50
-rw-r--r--lib/fencing/st_lha.c13
-rw-r--r--lib/fencing/st_rhcs.c15
4 files changed, 56 insertions, 34 deletions
diff --git a/lib/fencing/Makefile.am b/lib/fencing/Makefile.am
index a72b7d6..5302035 100644
--- a/lib/fencing/Makefile.am
+++ b/lib/fencing/Makefile.am
@@ -14,15 +14,19 @@ noinst_HEADERS = fencing_private.h
lib_LTLIBRARIES = libstonithd.la
-libstonithd_la_LDFLAGS = -version-info 34:3:8
+libstonithd_la_LDFLAGS = -version-info 34:4:8
libstonithd_la_CFLAGS = $(CFLAGS_HARDENED_LIB)
libstonithd_la_LDFLAGS += $(LDFLAGS_HARDENED_LIB)
-libstonithd_la_LIBADD = $(top_builddir)/lib/common/libcrmcommon.la
-libstonithd_la_LIBADD += $(top_builddir)/lib/services/libcrmservice.la
+libstonithd_la_LIBADD = $(top_builddir)/lib/services/libcrmservice.la
+libstonithd_la_LIBADD += $(top_builddir)/lib/common/libcrmcommon.la
-libstonithd_la_SOURCES = st_actions.c st_client.c st_output.c st_rhcs.c
+## Library sources (*must* use += format for bumplibs)
+libstonithd_la_SOURCES = st_actions.c
+libstonithd_la_SOURCES += st_client.c
if BUILD_LHA_SUPPORT
libstonithd_la_SOURCES += st_lha.c
endif
+libstonithd_la_SOURCES += st_output.c
+libstonithd_la_SOURCES += st_rhcs.c
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
index e2783d5..1d32cc1 100644
--- a/lib/fencing/st_client.c
+++ b/lib/fencing/st_client.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2022 the Pacemaker project contributors
+ * Copyright 2004-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -515,7 +515,7 @@ stonith_api_device_metadata(stonith_t *stonith, int call_options,
enum stonith_namespace ns = stonith_get_namespace(agent, namespace);
if (timeout_sec <= 0) {
- timeout_sec = CRMD_METADATA_CALL_TIMEOUT;
+ timeout_sec = PCMK_DEFAULT_METADATA_TIMEOUT_MS;
}
crm_trace("Looking up metadata for %s agent %s",
@@ -553,7 +553,7 @@ stonith_api_query(stonith_t * stonith, int call_options, const char *target,
data = create_xml_node(NULL, F_STONITH_DEVICE);
crm_xml_add(data, F_STONITH_ORIGIN, __func__);
crm_xml_add(data, F_STONITH_TARGET, target);
- crm_xml_add(data, F_STONITH_ACTION, "off");
+ crm_xml_add(data, F_STONITH_ACTION, PCMK_ACTION_OFF);
rc = stonith_send_command(stonith, STONITH_OP_QUERY, data, &output, call_options, timeout);
if (rc < 0) {
@@ -625,7 +625,8 @@ stonith_api_list(stonith_t * stonith, int call_options, const char *id, char **l
int rc;
xmlNode *output = NULL;
- rc = stonith_api_call(stonith, call_options, id, "list", NULL, timeout, &output);
+ rc = stonith_api_call(stonith, call_options, id, PCMK_ACTION_LIST, NULL,
+ timeout, &output);
if (output && list_info) {
const char *list_str;
@@ -647,14 +648,16 @@ stonith_api_list(stonith_t * stonith, int call_options, const char *id, char **l
static int
stonith_api_monitor(stonith_t * stonith, int call_options, const char *id, int timeout)
{
- return stonith_api_call(stonith, call_options, id, "monitor", NULL, timeout, NULL);
+ return stonith_api_call(stonith, call_options, id, PCMK_ACTION_MONITOR,
+ NULL, timeout, NULL);
}
static int
stonith_api_status(stonith_t * stonith, int call_options, const char *id, const char *port,
int timeout)
{
- return stonith_api_call(stonith, call_options, id, "status", port, timeout, NULL);
+ return stonith_api_call(stonith, call_options, id, PCMK_ACTION_STATUS, port,
+ timeout, NULL);
}
static int
@@ -689,7 +692,8 @@ static int
stonith_api_confirm(stonith_t * stonith, int call_options, const char *target)
{
stonith__set_call_options(call_options, target, st_opt_manual_ack);
- return stonith_api_fence(stonith, call_options, target, "off", 0, 0);
+ return stonith_api_fence(stonith, call_options, target, PCMK_ACTION_OFF, 0,
+ 0);
}
static int
@@ -1105,13 +1109,20 @@ stonith_api_signon(stonith_t * stonith, const char *name, int *stonith_fd)
if (stonith_fd) {
/* No mainloop */
native->ipc = crm_ipc_new("stonith-ng", 0);
-
- if (native->ipc && crm_ipc_connect(native->ipc)) {
- *stonith_fd = crm_ipc_get_fd(native->ipc);
- } else if (native->ipc) {
- crm_ipc_close(native->ipc);
- crm_ipc_destroy(native->ipc);
- native->ipc = NULL;
+ if (native->ipc != NULL) {
+ rc = pcmk__connect_generic_ipc(native->ipc);
+ if (rc == pcmk_rc_ok) {
+ rc = pcmk__ipc_fd(native->ipc, stonith_fd);
+ if (rc != pcmk_rc_ok) {
+ crm_debug("Couldn't get file descriptor for IPC: %s",
+ pcmk_rc_str(rc));
+ }
+ }
+ if (rc != pcmk_rc_ok) {
+ crm_ipc_close(native->ipc);
+ crm_ipc_destroy(native->ipc);
+ native->ipc = NULL;
+ }
}
} else {
@@ -1765,7 +1776,7 @@ stonith_api_validate(stonith_t *st, int call_options, const char *rsc_id,
}
if (timeout_sec <= 0) {
- timeout_sec = CRMD_METADATA_CALL_TIMEOUT; // Questionable
+ timeout_sec = PCMK_DEFAULT_METADATA_TIMEOUT_MS; // Questionable
}
switch (stonith_get_namespace(agent, namespace_s)) {
@@ -1961,7 +1972,7 @@ stonith_api_kick(uint32_t nodeid, const char *uname, int timeout, bool off)
{
int rc = pcmk_ok;
stonith_t *st = stonith_api_new();
- const char *action = off? "off" : "reboot";
+ const char *action = off? PCMK_ACTION_OFF : PCMK_ACTION_REBOOT;
api_log_open();
if (st == NULL) {
@@ -2098,9 +2109,9 @@ stonith_action_str(const char *action)
{
if (action == NULL) {
return "fencing";
- } else if (!strcmp(action, "on")) {
+ } else if (strcmp(action, PCMK_ACTION_ON) == 0) {
return "unfencing";
- } else if (!strcmp(action, "off")) {
+ } else if (strcmp(action, PCMK_ACTION_OFF) == 0) {
return "turning off";
} else {
return action;
@@ -2160,7 +2171,8 @@ parse_list_line(const char *line, int len, GList **output)
line + entry_start, entry_start, i);
free(entry);
- } else if (pcmk__strcase_any_of(entry, "on", "off", NULL)) {
+ } else if (pcmk__strcase_any_of(entry, PCMK_ACTION_ON,
+ PCMK_ACTION_OFF, NULL)) {
/* Some agents print the target status in the list output,
* though none are known now (the separate list-status command
* is used for this, but it can also print "UNKNOWN"). To handle
diff --git a/lib/fencing/st_lha.c b/lib/fencing/st_lha.c
index d477ded..fd26217 100644
--- a/lib/fencing/st_lha.c
+++ b/lib/fencing/st_lha.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2022 the Pacemaker project contributors
+ * Copyright 2004-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -41,10 +41,10 @@ static const char META_TEMPLATE[] =
" <shortdesc lang=\"en\">%s</shortdesc>\n"
"%s\n"
" <actions>\n"
- " <action name=\"start\" timeout=\"20\" />\n"
+ " <action name=\"start\" timeout=\"%s\" />\n"
" <action name=\"stop\" timeout=\"15\" />\n"
- " <action name=\"status\" timeout=\"20\" />\n"
- " <action name=\"monitor\" timeout=\"20\" interval=\"3600\"/>\n"
+ " <action name=\"status\" timeout=\"%s\" />\n"
+ " <action name=\"monitor\" timeout=\"%s\" interval=\"3600\"/>\n"
" <action name=\"meta-data\" timeout=\"15\" />\n"
" </actions>\n"
" <special tag=\"heartbeat\">\n"
@@ -200,6 +200,7 @@ stonith__lha_metadata(const char *agent, int timeout, char **output)
char *meta_param = NULL;
char *meta_longdesc = NULL;
char *meta_shortdesc = NULL;
+ const char *timeout_str = NULL;
stonith_obj = (*st_new_fn) (agent);
if (stonith_obj) {
@@ -236,8 +237,10 @@ stonith__lha_metadata(const char *agent, int timeout, char **output)
xml_meta_shortdesc =
(char *)xmlEncodeEntitiesReentrant(NULL, (const unsigned char *)meta_shortdesc);
+ timeout_str = pcmk__readable_interval(PCMK_DEFAULT_ACTION_TIMEOUT_MS);
buffer = crm_strdup_printf(META_TEMPLATE, agent, xml_meta_longdesc,
- xml_meta_shortdesc, meta_param);
+ xml_meta_shortdesc, meta_param,
+ timeout_str, timeout_str, timeout_str);
xmlFree(xml_meta_longdesc);
xmlFree(xml_meta_shortdesc);
diff --git a/lib/fencing/st_rhcs.c b/lib/fencing/st_rhcs.c
index ec80793..854d333 100644
--- a/lib/fencing/st_rhcs.c
+++ b/lib/fencing/st_rhcs.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2022 the Pacemaker project contributors
+ * Copyright 2004-2023 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -180,14 +180,17 @@ stonith__rhcs_get_metadata(const char *agent, int timeout_sec,
xpathObj = xpath_search(xml, "//action[@name='stop']");
if (numXpathResults(xpathObj) <= 0) {
xmlNode *tmp = NULL;
+ const char *timeout_str = NULL;
+
+ timeout_str = pcmk__readable_interval(PCMK_DEFAULT_ACTION_TIMEOUT_MS);
tmp = create_xml_node(actions, "action");
- crm_xml_add(tmp, "name", "stop");
- crm_xml_add(tmp, "timeout", CRM_DEFAULT_OP_TIMEOUT_S);
+ crm_xml_add(tmp, "name", PCMK_ACTION_STOP);
+ crm_xml_add(tmp, "timeout", timeout_str);
tmp = create_xml_node(actions, "action");
- crm_xml_add(tmp, "name", "start");
- crm_xml_add(tmp, "timeout", CRM_DEFAULT_OP_TIMEOUT_S);
+ crm_xml_add(tmp, "name", PCMK_ACTION_START);
+ crm_xml_add(tmp, "timeout", timeout_str);
}
freeXpathObject(xpathObj);
@@ -292,7 +295,7 @@ stonith__rhcs_validate(stonith_t *st, int call_options, const char *target,
host_arg = NULL;
}
- action = stonith__action_create(agent, "validate-all", target, 0,
+ action = stonith__action_create(agent, PCMK_ACTION_VALIDATE_ALL, target, 0,
remaining_timeout, params, NULL, host_arg);
rc = stonith__execute(action);