public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: David Teigland <teigland@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: fence: master - fence_node: unfence local node by default Date: Thu, 26 Feb 2009 18:08:00 -0000 [thread overview] Message-ID: <20090226180803.5B229120265@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/fence.git?p=fence.git;a=commitdiff;h=9abd4d6acd89b04acb06f342f5018ff77f19ef2a Commit: 9abd4d6acd89b04acb06f342f5018ff77f19ef2a Parent: 54eccd946068e48a4c1636a938e94fa4b17e9f38 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:05:29 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);
reply other threads:[~2009-02-26 18:08 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20090226180803.5B229120265@lists.fedorahosted.org \ --to=teigland@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /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: linkBe 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 read-only IMAP folder(s) and NNTP newsgroup(s).