cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Jacek Konieczny <jajcus@jajcus.net>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] dlm_stonith_{off, reboot} aliases for fence helper
Date: Mon,  5 Nov 2012 19:05:22 +0100	[thread overview]
Message-ID: <1352138722-2723-2-git-send-email-jajcus@jajcus.net> (raw)
In-Reply-To: <1352138722-2723-1-git-send-email-jajcus@jajcus.net>

Not so pretty hack to allow rebooting instead of halting
the node fenced by dlm_stonith.

'dlm_stonith_reboot' can be now used instead of 'dlm_stonith'
in the dlm.conf file to request node reboot.

'dlm_stonith_off' alias is also provided to explicitly request
power-off.

Signed-off-by: Jacek Konieczny <jajcus@jajcus.net>
---
 fence/Makefile         |   10 +++++++++-
 fence/stonith_helper.c |    8 +++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/fence/Makefile b/fence/Makefile
index b4c59dd..2f24677 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -6,6 +6,8 @@ BINDIR=$(PREFIX)/sbin
 BIN_TARGET = dlm_stonith
 #MAN_TARGET = dlm_stonith.8
 
+SYMLINKS = dlm_stonith_off dlm_stonith_reboot
+
 BIN_SOURCE = stonith_helper.c
 
 BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
@@ -37,11 +39,14 @@ BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
 BIN_LDFLAGS += `xml2-config --libs`
 BIN_LDFLAGS += -ldl
 
-all: $(BIN_TARGET)
+all: $(BIN_TARGET) $(SYMLINKS)
 
 $(BIN_TARGET): $(BIN_SOURCE)
 	$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
 
+$(SYMLINKS): $(BIN_TARGET)
+	for link in $(SYMLINKS) ; do ln -sf $(BIN_TARGET) $$link ; done
+
 clean:
 	rm -f *.o *.so *.so.* $(BIN_TARGET)
 
@@ -53,5 +58,8 @@ install: all
 	$(INSTALL) -d $(DESTDIR)/$(BINDIR)
 	$(INSTALL) -d $(DESTDIR)/$(MANDIR)/man8
 	$(INSTALL) -c -m 755 $(BIN_TARGET) $(DESTDIR)/$(BINDIR)
+	for link in $(SYMLINKS) ; do \
+		ln -sf $(BIN_TARGET) $(DESTDIR)/$(BINDIR)/$$link ; \
+	done
 #	$(INSTALL) -m 644 $(MAN_TARGET) $(DESTDIR)/$(MANDIR)/man8/
 
diff --git a/fence/stonith_helper.c b/fence/stonith_helper.c
index 5b384c1..73a2245 100644
--- a/fence/stonith_helper.c
+++ b/fence/stonith_helper.c
@@ -16,6 +16,7 @@
 
 int nodeid;
 uint64_t fail_time;
+int turn_off = 1;
 
 #define MAX_ARG_LEN 1024
 
@@ -26,6 +27,11 @@ static int get_options(int argc, char *argv[])
 	char val[MAX_ARG_LEN];
 	char c;
 	int rv;
+	int arg0_l;
+
+	arg0_l = strlen(argv[0]);
+	if (arg0_l>7 && !strcmp(argv[0] + arg0_l - 7, "_reboot")) turn_off = 0;
+	else if (arg0_l>4 && !strcmp(argv[0] + arg0_l - 4, "_off")) turn_off = 1;
 
 	if (argc > 1) {
 		while ((c = getopt(argc, argv, "n:t:")) != -1) {
@@ -77,7 +83,7 @@ int main(int argc, char *argv[])
 	if (t >= fail_time)
 		return 0;
 
-	rv = stonith_api_kick_helper(nodeid, 300, 1);
+	rv = stonith_api_kick_helper(nodeid, 300, turn_off);
 	if (rv) {
 		fprintf(stderr, "kick_helper error %d nodeid %d\n", rv, nodeid);
 		openlog("stonith_helper", LOG_CONS | LOG_PID, LOG_DAEMON);
-- 
1.7.7.4



  reply	other threads:[~2012-11-05 18:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-03 14:58 [Cluster-devel] cluster4 dlm dlm_stonith – should it really fence by turning node off? Jacek Konieczny
2012-11-05 16:10 ` [Cluster-devel] cluster4 dlm dlm_stonith ??? " David Teigland
2012-11-05 17:47   ` Jacek Konieczny
2012-11-05 18:05     ` Jacek Konieczny
2012-11-05 18:05       ` Jacek Konieczny [this message]
2012-11-05 19:30         ` [Cluster-devel] [PATCH] dlm_stonith_{off, reboot} aliases for fence helper David Teigland
2012-11-05 20:46           ` Jacek Konieczny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1352138722-2723-2-git-send-email-jajcus@jajcus.net \
    --to=jajcus@jajcus.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).