public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - fence_node: unfence local node by default
@ 2009-02-26 18:05 David Teigland
0 siblings, 0 replies; only message in thread
From: David Teigland @ 2009-02-26 18:05 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=6e4790ff21127e92714bc3f6911075858d620d3c
Commit: 6e4790ff21127e92714bc3f6911075858d620d3c
Parent: ad81ca710d21bd6623fba9dc8900169c0af2264e
Author: David Teigland <teigland@redhat.com>
AuthorDate: Thu Feb 26 12:00:08 2009 -0600
Committer: David Teigland <teigland@redhat.com>
CommitterDate: Thu Feb 26 12:02:58 2009 -0600
fence_node: unfence local node by default
and wait for cman to be active before using it for getting the
local node name (for unfence default), and ccs queries (in libfence).
Signed-off-by: David Teigland <teigland@redhat.com>
---
fence/fence_node/Makefile | 4 +-
fence/fence_node/fence_node.c | 55 ++++++++++++++++++++++++++++++++++++----
2 files changed, 51 insertions(+), 8 deletions(-)
diff --git a/fence/fence_node/Makefile b/fence/fence_node/Makefile
index 0ce0615..06a8e54 100644
--- a/fence/fence_node/Makefile
+++ b/fence/fence_node/Makefile
@@ -14,11 +14,11 @@ OBJS= fence_node.o
CFLAGS += -D_FILE_OFFSET_BITS=64
-CFLAGS += -I${ccsincdir} -I${fenceincdir} -I${logtincdir}
+CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${fenceincdir} -I${logtincdir}
CFLAGS += -I$(S)/../libfenced
CFLAGS += -I${incdir}
-LDFLAGS += -L${ccslibdir} -L${fencelibdir} -lccs -lfence
+LDFLAGS += -L${ccslibdir} -L{cmanlibdir} -L${fencelibdir} -lccs -lcman -lfence
LDFLAGS += -L${logtlibdir} -llogthread
LDFLAGS += -L../libfenced -lfenced
LDFLAGS += -L${libdir}
diff --git a/fence/fence_node/fence_node.c b/fence/fence_node/fence_node.c
index 6cb15e7..1e3c293 100644
--- a/fence/fence_node/fence_node.c
+++ b/fence/fence_node/fence_node.c
@@ -4,12 +4,14 @@
#include <stdint.h>
#include <string.h>
#include <liblogthread.h>
+#include <libcman.h>
#include "libfence.h"
#include "libfenced.h"
#include "copyright.cf"
static char *prog_name;
+static char our_name[CMAN_MAX_NODENAME_LEN+1];
static int verbose;
static int unfence;
@@ -37,13 +39,47 @@ static void print_usage(void)
printf("\n");
printf("Options:\n");
printf("\n");
- printf(" -U Unfence the node\n");
+ printf(" -U Unfence the node, default local node name\n");
printf(" -v Show fence agent results, -vv for agent args\n");
printf(" -h Print this help, then exit\n");
printf(" -V Print program version information, then exit\n");
printf("\n");
}
+static int setup_cman(void)
+{
+ cman_handle_t ch;
+ cman_node_t node;
+ int active = 0;
+ int rv;
+
+ ch = cman_init(NULL);
+ if (!ch)
+ return -1;
+
+ retry_active:
+ rv = cman_is_active(ch);
+ if (!rv) {
+ if (active++ < 2) {
+ sleep(1);
+ goto retry_active;
+ }
+ cman_finish(ch);
+ return -1;
+ }
+
+ rv = cman_get_node(ch, CMAN_NODEID_US, &node);
+ if (rv < 0) {
+ cman_finish(ch);
+ return -1;
+ }
+
+ memset(our_name, 0, sizeof(our_name));
+ strncpy(our_name, node.cn_name, CMAN_MAX_NODENAME_LEN);
+ cman_finish(ch);
+ return 0;
+}
+
static char *fe_str(int r)
{
switch (r) {
@@ -74,7 +110,7 @@ static char *fe_str(int r)
int main(int argc, char *argv[])
{
- char *victim = NULL, *p;
+ char *victim = NULL;
int cont = 1, optchar, error, rv, i, c;
prog_name = argv[0];
@@ -128,9 +164,16 @@ int main(int argc, char *argv[])
optind++;
}
- if (!victim)
+ if (!victim && !unfence)
die("no node name specified");
+ error = setup_cman();
+ if (error)
+ die("cannot connect to cman");
+
+ if (!victim && unfence)
+ victim = our_name;
+
memset(&log, 0, sizeof(log));
log_count = 0;
@@ -139,9 +182,6 @@ int main(int argc, char *argv[])
else
error = fence_node(victim, log, FL_SIZE, &log_count);
- logt_init("fence_node", LOG_MODE_OUTPUT_SYSLOG, SYSLOGFACILITY,
- SYSLOGLEVEL, 0, NULL);
-
if (!verbose)
goto skip;
@@ -167,6 +207,9 @@ int main(int argc, char *argv[])
}
skip:
+ logt_init("fence_node", LOG_MODE_OUTPUT_SYSLOG, SYSLOGFACILITY,
+ SYSLOGLEVEL, 0, NULL);
+
if (error) {
fprintf(stderr, "%s %s failed\n", action, victim);
logt_print(LOG_ERR, "%s %s failed\n", action, victim);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-26 18:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-26 18:05 cluster: STABLE3 - fence_node: unfence local node by default David Teigland
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 read-only IMAP folder(s) and NNTP newsgroup(s).