cluster: RHEL6 - rgmanager: Fix rg_test exit status on failures
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=6fbf7b593db...
Commit: 6fbf7b593dbd48245fee4411935abb03ba063183
Parent: c4aaef4d08c0e886fbba70a0abf4cdc1ce241a27
Author: Ryan McCabe <rmccabe(a)redhat.com>
AuthorDate: Mon Jun 16 10:55:15 2014 -0400
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Sun Jun 22 21:12:42 2014 -0400
rgmanager: Fix rg_test exit status on failures
Exit with a non-zero exit code on all failure paths when running
rg_test.
Resolves: rhbz#1033162
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/src/daemons/test.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/test.c b/rgmanager/src/daemons/test.c
index 1982995..e74a8c1 100644
--- a/rgmanager/src/daemons/test.c
+++ b/rgmanager/src/daemons/test.c
@@ -128,6 +128,7 @@ test_func(int argc, char **argv)
conf_setconfig(argv[1]);
ccsfd = ccs_lock();
if (ccsfd < 0) {
+ ret = -1;
printf("Error parsing %s\n", argv[1]);
goto out;
}
@@ -430,6 +431,7 @@ main(int argc, char **argv)
} else {
ret = stat(argv[1], &st);
if (ret == -1 || !S_ISDIR(st.st_mode)) {
+ ret = -1;
break;
}
fprintf(stderr,
9 years, 10 months
cluster: RHEL6 - rgmanager: resrules: make expand_time buffer-less
by Ryan McCabe
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=c4aaef4d08c...
Commit: c4aaef4d08c0e886fbba70a0abf4cdc1ce241a27
Parent: 0e5ba8bc5938c8b92d28d1a807616d08bd3ce47e
Author: Jan Pokorný <jpokorny(a)redhat.com>
AuthorDate: Thu Apr 5 20:46:15 2012 +0200
Committer: Ryan McCabe <rmccabe(a)redhat.com>
CommitterDate: Sun Jun 22 21:11:10 2014 -0400
rgmanager: resrules: make expand_time buffer-less
This has several advantages:
- safe against unchecked (tainted; restart_expire, etc.) input
- detection of int type oveflow during conversion
- more flexibility when needed (e.g. when introducing more
strict rules)
Additionally, the int type overflow is checked before
any multiplying operation. All overflows leads to returning 0.
Test program for interactive tests of the function provided
(use "CFLAGS=-DNO_CCS make test-expand-time disable_dbus=1",
some dependencies needed due to high coupling :/)
Resolves: rhbz#1036652
Signed-off-by: Jan Pokorný <jpokorny(a)redhat.com>
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
---
rgmanager/include/reslist.h | 2 +-
rgmanager/src/daemons/Makefile | 13 +++++-
rgmanager/src/daemons/resrules.c | 74 +++++++++++++++++++-----------
rgmanager/src/daemons/test-expand-time.c | 25 ++++++++++
4 files changed, 85 insertions(+), 29 deletions(-)
diff --git a/rgmanager/include/reslist.h b/rgmanager/include/reslist.h
index 68ea032..cdfc819 100644
--- a/rgmanager/include/reslist.h
+++ b/rgmanager/include/reslist.h
@@ -136,7 +136,7 @@ int res_condstart(resource_node_t **tree, resource_t *res, void *ret);
int res_condstop(resource_node_t **tree, resource_t *res, void *ret);
int res_exec(resource_node_t *node, int op, const char *arg, int depth);
/*int res_resinfo(resource_node_t **tree, resource_t *res, void *ret);*/
-int expand_time(char *val);
+int expand_time(const char *val);
int store_action(resource_act_t **actsp, char *name, int depth, int timeout, int interval);
diff --git a/rgmanager/src/daemons/Makefile b/rgmanager/src/daemons/Makefile
index a178523..43d3377 100644
--- a/rgmanager/src/daemons/Makefile
+++ b/rgmanager/src/daemons/Makefile
@@ -3,6 +3,7 @@ TARGET2= rg_test
TARGET3= clurgmgrd
TARGET4= cpglockd
TARGET5= cpglockdump
+TARGET6= test-expand-time
SBINDIRT=$(TARGET1) $(TARGET2) $(TARGET4) $(TARGET5)
SBINSYMT=$(TARGET3)
@@ -47,6 +48,11 @@ OBJS4= cpglockd.o
OBJS5= cpglockdump.o
+OBJS6= test-expand-time.o \
+ reslist.o \
+ resrules.o \
+ rg_locks.o
+
CFLAGS += -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE
CFLAGS += -fPIC
CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${corosyncincdir}
@@ -93,7 +99,7 @@ ${TARGET1}: ${OBJS1} ${LDDEPS}
#
# The data in the 'tests' directory is hand-crafted; so running 'gentests.sh'
# will require that the developer hand-verify the correctness of the
-# resulting output prior to committing back to CVS.
+# resulting output prior to committing back to VCS.
#
# This is NOT meant to be an installed binary. Rather, RPMs and/or other
# packages should run 'make check' as part of the build process.
@@ -112,6 +118,11 @@ ${TARGET4}: ${OBJS4} ${LDDEPS}
${TARGET5}: ${OBJS5} ${LDDEPS}
$(CC) -o $@ $^ $(CPG_LDFLAGS)
+# This is a test of a specific parsing function; after top-level "configure",
+# compile it locally as "CFLAGS=-DNO_CCS make test-expand-time disable_dbus=1".
+${TARGET6}: ${OBJS6}
+ $(CC) -o $@ $^ $(XML2_LDFLAGS)
+
check: rg_test
cd tests && ./runtests.sh
diff --git a/rgmanager/src/daemons/resrules.c b/rgmanager/src/daemons/resrules.c
index 142cfcd..3cfc90f 100644
--- a/rgmanager/src/daemons/resrules.c
+++ b/rgmanager/src/daemons/resrules.c
@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <limits.h>
#include <resgroup.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -213,65 +214,84 @@ _get_version(xmlDocPtr doc, xmlXPathContextPtr ctx, char *base,
}
+/* Relying on compiler to cope with constants efficiently */
+#define TIMEF_M ( 60 * 1 )
+#define TIMEF_H ( 60 * TIMEF_M )
+#define TIMEF_D ( 24 * TIMEF_H )
+#define TIMEF_W ( 7 * TIMEF_D )
+#define TIMEF_Y ( 365 * TIMEF_D )
+
+/* NOTE: Only int type oveflows are checked (no targeted against time_t) */
int
-expand_time (char *val)
+expand_time (const char *val)
{
- int curval, len;
- int ret = 0;
- char *start = val, ival[16];
-
- if (!val)
- return (time_t)0;
+ int curval, tmp, ret = 0;
- while (start[0]) {
+ if (!val || *val == '\0')
+ return 0;
- len = 0;
+ do {
curval = 0;
- memset(ival, 0, sizeof(ival));
- while (isdigit(start[len])) {
- ival[len] = start[len];
- len++;
- }
+ while (isdigit(*val)) {
+ tmp = *val - '0';
- if (len) {
- curval = atoi(ival);
- } else {
- len = 1;
+ if (curval > INT_MAX/10
+ || (curval == INT_MAX/10 && tmp > INT_MAX%10))
+ /* Overflow */
+ break;
+
+ curval *= 10;
+ curval += tmp;
+ ++val;
}
- switch(start[len]) {
+ if (isdigit(*val))
+ /* Overflow detected */
+ return 0;
+
+ /* Watch for overflow also here */
+ switch(*val) {
case 0:
case 'S':
case 's':
break;
case 'M':
case 'm':
- curval *= 60;
+ if (curval > INT_MAX/TIMEF_M)
+ return 0;
+ curval *= TIMEF_M;
break;
case 'h':
case 'H':
- curval *= 3600;
+ if (curval > INT_MAX/TIMEF_H)
+ return 0;
+ curval *= TIMEF_H;
break;
case 'd':
case 'D':
- curval *= 86400;
+ if (curval > INT_MAX/TIMEF_D)
+ return 0;
+ curval *= TIMEF_D;
break;
case 'w':
case 'W':
- curval *= 604800;
+ if (curval > INT_MAX/TIMEF_W)
+ return 0;
+ curval *= TIMEF_W;
break;
case 'y':
case 'Y':
- curval *= 31536000;
+ if (curval > INT_MAX/TIMEF_Y)
+ return 0;
+ curval *= TIMEF_Y;
break;
default:
curval = 0;
}
+ ret += curval;
- ret += (time_t)curval;
- start += len;
- }
+ } while (*++val != '\0');
return ret;
}
diff --git a/rgmanager/src/daemons/test-expand-time.c b/rgmanager/src/daemons/test-expand-time.c
new file mode 100644
index 0000000..0a15452
--- /dev/null
+++ b/rgmanager/src/daemons/test-expand-time.c
@@ -0,0 +1,25 @@
+#include <stdio.h>
+#include <time.h>
+
+/* XXX "list_head()", reslist.h should include on its own? */
+#include "list.h"
+/* XXX "restart_counter_t", dtto */
+#include "restart_counter.h"
+
+#include "reslist.h"
+
+int main(int argc, char *argv[])
+{
+ char buffer[255];
+ char *aux;
+ for (;;) {
+ printf("Time string: ");
+ if (!fgets(buffer, sizeof(buffer), stdin) && feof(stdin))
+ break;
+ aux = strchr(buffer,'\n');
+ if (aux)
+ *aux = '\0';
+ printf("Expanded : %d\n", expand_time(buffer));
+ }
+ return EXIT_SUCCESS;
+}
9 years, 10 months
fence-agents: master - fence_rsb: Accept new prompt in parsing
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=62d90e...
Commit: 62d90e3a0827fcdc5be632bdf4103d3c08b39622
Parent: 9caf5a23e58b52e05042674260eb1f1aa6d22558
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Jun 20 15:37:40 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Jun 20 16:06:40 2014 +0200
fence_rsb: Accept new prompt in parsing
Resolves: rhbz#1110428
---
fence/agents/rsb/fence_rsb.py | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/fence/agents/rsb/fence_rsb.py b/fence/agents/rsb/fence_rsb.py
index 9c1df5f..bcad1de 100755
--- a/fence/agents/rsb/fence_rsb.py
+++ b/fence/agents/rsb/fence_rsb.py
@@ -30,6 +30,8 @@ def set_power_status(conn, options):
conn.log_expect(options, options["--command-prompt"], int(options["--shell-timeout"]))
conn.send_eol(action)
conn.log_expect(options, ["want to power off", "'yes' or 'no'"], int(options["--shell-timeout"]))
+ conn.log_expect(options, ["want to power " + options["--action"],
+ "yes/no", "'yes' or 'no'"], int(options["--shell-timeout"]))
conn.send_eol("yes")
conn.log_expect(options, "any key to continue", int(options["--power-timeout"]))
conn.send_eol("")
9 years, 10 months
fence-agents: RHEL6 - fence_broade: Port fence agent to fencing library
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=9c38cb...
Commit: 9c38cbf1b3e474b6a8eff80f4b8a719047792855
Parent: 8fc75f57798be791b13208ac2f2d872c44c70116
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Fri Jun 20 15:22:22 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Fri Jun 20 15:22:22 2014 +0200
fence_broade: Port fence agent to fencing library
Backported from upstream
Resolves: rhbz#641632 rhbz#642232 rhbz#841556
---
fence/agents/brocade/Makefile.am | 4 +-
fence/agents/brocade/fence_brocade.pl | 322 ---------------------------------
fence/agents/brocade/fence_brocade.py | 82 +++++++++
3 files changed, 84 insertions(+), 324 deletions(-)
diff --git a/fence/agents/brocade/Makefile.am b/fence/agents/brocade/Makefile.am
index 3338804..171425f 100644
--- a/fence/agents/brocade/Makefile.am
+++ b/fence/agents/brocade/Makefile.am
@@ -2,7 +2,7 @@ MAINTAINERCLEANFILES = Makefile.in
TARGET = fence_brocade
-SRC = $(TARGET).pl
+SRC = $(TARGET).py
EXTRA_DIST = $(SRC)
@@ -11,7 +11,7 @@ sbin_SCRIPTS = $(TARGET)
man_MANS = $(TARGET).8
include $(top_srcdir)/make/fencebuild.mk
-include $(top_srcdir)/make/fencemanperl.mk
+include $(top_srcdir)/make/fenceman.mk
clean-local: clean-man
rm -f $(TARGET)
diff --git a/fence/agents/brocade/fence_brocade.pl b/fence/agents/brocade/fence_brocade.pl
deleted file mode 100644
index e3f7290..0000000
--- a/fence/agents/brocade/fence_brocade.pl
+++ /dev/null
@@ -1,322 +0,0 @@
-#!/usr/bin/perl
-
-use Getopt::Std;
-use Net::Telnet ();
-
-my $ME = $0;
-
-END {
- defined fileno STDOUT or return;
- close STDOUT and return;
- warn "$ME: failed to close standard output: $!\n";
- $? ||= 1;
-}
-
-# Get the program name from $0 and strip directory names
-$_=$0;
-s/.*\///;
-my $pname = $_;
-
-$opt_o = 'disable'; # Default fence action
-
-# WARNING!! Do not add code bewteen "#BEGIN_VERSION_GENERATION" and
-# "#END_VERSION_GENERATION" It is generated by the Makefile
-
-#BEGIN_VERSION_GENERATION
-$RELEASE_VERSION="";
-$REDHAT_COPYRIGHT="";
-$BUILD_DATE="";
-#END_VERSION_GENERATION
-
-
-sub usage
-{
- print "Usage:\n";
- print "\n";
- print "$pname [options]\n";
- print "\n";
- print "Options:\n";
- print " -a <ip> IP address or hostname of switch\n";
- print " -h usage\n";
- print " -l <name> Login name\n";
- print " -n <num> Port number to operate on\n";
- print " -o <string> Action: disable (default), enable or metadata\n";
- print " -p <string> Password for login\n";
- print " -S <path> Script to run to retrieve password\n";
- print " -q quiet mode\n";
- print " -V version\n";
-
- exit 0;
-}
-
-sub fail
-{
- ($msg) = @_;
- print $msg."\n" unless defined $opt_q;
- $t->close if defined $t;
- exit 1;
-}
-
-sub fail_usage
-{
- ($msg)=@_;
- print STDERR $msg."\n" if $msg;
- print STDERR "Please use '-h' for usage.\n";
- exit 1;
-}
-
-sub version
-{
- print "$pname $RELEASE_VERSION $BUILD_DATE\n";
- print "$REDHAT_COPYRIGHT\n" if ( $REDHAT_COPYRIGHT );
-
- exit 0;
-}
-
-sub print_metadata
-{
-print '<?xml version="1.0" ?>
-<resource-agent name="fence_brocade" shortdesc="Fence agent for Brocade over telnet" >
-<longdesc>
-fence_brocade is an I/O Fencing agent which can be used with Brocade FC switches. It logs into a Brocade switch via telnet and disables a specified port. Disabling the port which a machine is connected to effectively fences that machine. Lengthy telnet connections to the switch should be avoided while a GFS cluster is running because the connection will block any necessary fencing actions.
-
-After a fence operation has taken place the fenced machine can no longer connect to the Brocade FC switch. When the fenced machine is ready to be brought back into the GFS cluster (after reboot) the port on the Brocade FC switch needs to be enabled. This can be done by running fence_brocade and specifying the enable action.
-</longdesc>
-<vendor-url>http://www.brocade.com</vendor-url>
-<parameters>
- <parameter name="action" unique="0" required="1">
- <getopt mixed="-o <action>" />
- <content type="string" default="disable" />
- <shortdesc lang="en">Fencing Action</shortdesc>
- </parameter>
- <parameter name="ipaddr" unique="0" required="1">
- <getopt mixed="-a <ip>" />
- <content type="string" />
- <shortdesc lang="en">IP Address or Hostname</shortdesc>
- </parameter>
- <parameter name="login" unique="0" required="1">
- <getopt mixed="-l <name>" />
- <content type="string" />
- <shortdesc lang="en">Login Name</shortdesc>
- </parameter>
- <parameter name="passwd" unique="0" required="0">
- <getopt mixed="-p <password>" />
- <content type="string" />
- <shortdesc lang="en">Login password or passphrase</shortdesc>
- </parameter>
- <parameter name="passwd_script" unique="0" required="0">
- <getopt mixed="-S <script>" />
- <content type="string" />
- <shortdesc lang="en">Script to retrieve password</shortdesc>
- </parameter>
- <parameter name="port" unique="0" required="1">
- <getopt mixed="-n <id>" />
- <content type="string" />
- <shortdesc lang="en">Physical plug number or name of virtual machine</shortdesc>
- </parameter>
- <parameter name="help" unique="0" required="0">
- <getopt mixed="-h" />
- <content type="string" />
- <shortdesc lang="en">Display help and exit</shortdesc>
- </parameter>
-</parameters>
-<actions>
- <action name="enable" />
- <action name="disable" />
- <action name="status" />
- <action name="metadata" />
-</actions>
-</resource-agent>
-';
-}
-
-
-if (@ARGV > 0) {
- getopts("a:hl:n:o:p:S:qV") || fail_usage ;
-
- usage if defined $opt_h;
- version if defined $opt_V;
-
- fail_usage "Unknown parameter." if (@ARGV > 0);
-
- if ((defined $opt_o) && ($opt_o =~ /metadata/i)) {
- print_metadata();
- exit 0;
- }
-
- if (defined $opt_S) {
- $pwd_script_out = `$opt_S`;
- chomp($pwd_script_out);
- if ($pwd_script_out) {
- $opt_p = $pwd_script_out;
- }
- }
-
- fail_usage "No '-a' flag specified." unless defined $opt_a;
- fail_usage "No '-n' flag specified." unless defined $opt_n;
- fail_usage "No '-l' flag specified." unless defined $opt_l;
- fail_usage "No '-p' or '-S' flag specified." unless defined $opt_p;
- fail_usage "Unrecognised action '$opt_o' for '-o' flag"
- unless $opt_o =~ /^(disable|enable)$/i;
-
-} else {
- get_options_stdin();
-
- if ((defined $opt_o) && ($opt_o =~ /metadata/i)) {
- print_metadata();
- exit 0;
- }
-
- fail "failed: no IP address" unless defined $opt_a;
- fail "failed: no plug number" unless defined $opt_n;
- fail "failed: no login name" unless defined $opt_l;
-
- if (defined $opt_S) {
- $pwd_script_out = `$opt_S`;
- chomp($pwd_script_out);
- if ($pwd_script_out) {
- $opt_p = $pwd_script_out;
- }
- }
-
- fail "failed: no password" unless defined $opt_p;
- fail "failed: unrecognised action: $opt_o"
- unless $opt_o =~ /^(disable|enable)$/i;
-}
-
-if ( $opt_o =~ /^(disable|enable)$/i )
-{
- $opt_o = "port".$1;
-}
-
-
-#
-# Set up and log in
-#
-
-$t = new Net::Telnet;
-
-$t->open($opt_a);
-
-$t->waitfor('/login:/');
-
-$t->print($opt_l);
-
-$t->waitfor('/assword:/');
-
-$t->print($opt_p);
-
-$t->waitfor('/\>/');
-
-
-
-#
-# Do the command
-#
-
-$cmd = "$opt_o $opt_n";
-$t->print($cmd);
-
-
-#
-# Assume here that the word "error" will appear after errors (bad assumption! see next check)
-#
-
-($text, $match) = $t->waitfor('/\>/');
-if ($text =~ /error/)
-{
- fail "failed: error from switch\n";
-}
-
-
-#
-# Do a portshow on the port and look for the DISABLED string to verify success
-#
-
-$t->print("portshow $opt_n");
-($text, $match) = $t->waitfor('/\>/');
-
-if ( $opt_o eq "portdisable" && !($text =~ /DISABLED/) )
-{
- fail "failed: portshow $opt_n does not show DISABLED\n";
-}
-elsif ( $opt_o eq "portenable" && ($text =~ /DISABLED/) )
-{
- fail "failed: portshow $opt_n shows DISABLED\n";
-}
-
-
-print "success: $opt_o $opt_n\n" unless defined $opt_q;
-exit 0;
-
-sub get_options_stdin
-{
- my $opt;
- my $line = 0;
- while( defined($in = <>) )
- {
- $_ = $in;
- chomp;
-
- # strip leading and trailing whitespace
- s/^\s*//;
- s/\s*$//;
-
- # skip comments
- next if /^#/;
-
- $line+=1;
- $opt=$_;
- next unless $opt;
-
- ($name,$val)=split /\s*=\s*/, $opt;
-
- if ( $name eq "" )
- {
- print STDERR "parse error: illegal name in option $line\n";
- exit 2;
- }
-
- # DO NOTHING -- this field is used by fenced
- elsif ($name eq "agent" ) { }
-
- # FIXME -- depricated. use "port" instead.
- elsif ($name eq "fm" )
- {
- (my $dummy,$opt_n) = split /\s+/,$val;
- print STDERR "Depricated \"fm\" entry detected. refer to man page.\n";
- }
-
- elsif ($name eq "ipaddr" )
- {
- $opt_a = $val;
- }
- elsif ($name eq "login" )
- {
- $opt_l = $val;
- }
-
- # FIXME -- depreicated residue of old fencing system
- elsif ($name eq "name" ) { }
-
- elsif (($name eq "option" ) || ($name eq "action"))
- {
- $opt_o = $val;
- }
- elsif ($name eq "passwd" )
- {
- $opt_p = $val;
- }
- elsif ($name eq "passwd_script") {
- $opt_S = $val;
- }
- elsif ($name eq "port" )
- {
- $opt_n = $val;
- }
- # elsif ($name eq "test" )
- # {
- # $opt_T = $val;
- # }
- }
-}
diff --git a/fence/agents/brocade/fence_brocade.py b/fence/agents/brocade/fence_brocade.py
new file mode 100644
index 0000000..c3fde30
--- /dev/null
+++ b/fence/agents/brocade/fence_brocade.py
@@ -0,0 +1,82 @@
+#!/usr/bin/python
+
+import sys, re
+import atexit
+sys.path.append("@FENCEAGENTSLIBDIR@")
+from fencing import *
+from fencing import fail, EC_STATUS
+
+#BEGIN_VERSION_GENERATION
+RELEASE_VERSION="New Brocade Agent - test release on steroids"
+REDHAT_COPYRIGHT=""
+BUILD_DATE="March, 20013"
+#END_VERSION_GENERATION
+
+def get_power_status(conn, options):
+ conn.send_eol("portCfgShow " + options["-n"])
+
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
+
+ show_re = re.compile(r'^\s*Persistent Disable\s*(ON|OFF)\s*$', re.IGNORECASE)
+ lines = conn.before.split("\n")
+
+ for line in lines:
+ res = show_re.search(line)
+ if res != None:
+ # We queried if it is disabled, so we have to negate answer
+ if res.group(1) == "ON":
+ return "off"
+ else:
+ return "on"
+
+ fail(EC_STATUS)
+def set_power_status(conn, options):
+ action = {
+ 'on' : "portCfgPersistentEnable",
+ 'off': "portCfgPersistentDisable"
+ }[options["-o"]]
+
+ conn.send_eol(action + " " + options["-n"])
+ conn.log_expect(options, options["-c"], int(options["-Y"]))
+
+def main():
+ device_opt = ["help", "version", "agent", "quiet", "verbose", "debug",
+ "action", "ipaddr", "login", "passwd", "passwd_script",
+ "secure", "identity_file", "separator", "cmd_prompt",
+ "inet4_only", "inet6_only", "ipport", "io_fencing", "port",
+ "power_timeout", "shell_timeout", "login_timeout", "power_wait"]
+
+ atexit.register(atexit_handler)
+
+ all_opt["cmd_prompt"]["default"] = ["> "]
+
+ options = check_input(device_opt, process_input(device_opt))
+ options["eol"] = "\n"
+
+ docs = {}
+ docs["shortdesc"] = "Fence agent for HP Brocade over telnet/ssh"
+ docs["longdesc"] = "fence_brocade is an I/O Fencing agent which can be used with Brocade FC switches. \
+It logs into a Brocade switch via telnet and disables a specified port. Disabling the port which a machine is \
+connected to effectively fences that machine. Lengthy telnet connections to the switch should be avoided while \
+a GFS cluster is running because the connection will block any necessary fencing actions. \
+\
+After a fence operation has taken place the fenced machine can no longer connect to the Brocade FC switch. \
+When the fenced machine is ready to be brought back into the GFS cluster (after reboot) the port on the Brocade \
+FC switch needs to be enabled. This can be done by running fence_brocade and specifying the enable action"
+ docs["vendorurl"] = "http://www.brocade.com"
+ show_docs(options, docs)
+
+ ##
+ ## Operate the fencing device
+ ####
+ conn = fence_login(options)
+ result = fence_action(conn, options, set_power_status, get_power_status, None)
+ try:
+ fence_logout(conn, "exit")
+ except:
+ pass
+
+ sys.exit(result)
+
+if __name__ == "__main__":
+ main()
9 years, 10 months
cluster: STABLE32 - cman: fix cman.5 man page to indicate only 1 altname is allowed
by Christine Caulfield
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=2f05327bd8e...
Commit: 2f05327bd8e7a072418dca45988ab5a814109258
Parent: 8fd4192e154384a4e5a7f4b16dc5365118ac98d1
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Fri Jun 20 08:58:45 2014 +0100
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Fri Jun 20 08:58:45 2014 +0100
cman: fix cman.5 man page to indicate only 1 altname is allowed
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
cman/man/cman.5 | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/cman/man/cman.5 b/cman/man/cman.5
index 84c86be..0311412 100644
--- a/cman/man/cman.5
+++ b/cman/man/cman.5
@@ -97,8 +97,8 @@ ethernet bonding. Alternatively you can get corosync to run in redundant ring
mode by specifying an 'altname' for the node. This is an alternative name by
which the node is known, that resolves to another IP address used on the
other ethernet adapter(s). You can optionally specify a different port and/or
-multicast address for each altname in use. Up to 9 altnames (10 interfaces
-in total) can be used.
+multicast address for each altname in use. Only one altname (2 interfaces
+in total) is valid for each node.
Note that if you are using the DLM with cman/corosync then you MUST tell it
to use SCTP as it's communications protocol as TCP does not support multihoming.
@@ -192,7 +192,7 @@ default values:
join="60"
consensus="4800"
rrp_mode="none"
- <!-- or rrp_mode="active" if altnames are present >
+ <!-- or rrp_mode="active" if altname is present >
/>
<aisexec user="root" group="root" />
9 years, 10 months
fence-agents: RHEL6 - fencing: Do not use public keys when identity-file is not defined
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=8fc75f...
Commit: 8fc75f57798be791b13208ac2f2d872c44c70116
Parent: f49052ae6f385e473e5acc062bee1c2c74159c99
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jun 18 14:42:20 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jun 18 14:42:20 2014 +0200
fencing: Do not use public keys when identity-file is not defined
Previously, fence agent (ssh) tried to use keys before it asks for password. This lead to a situation
when fence agent did not work correctly as it was waiting for 'Password' which did not occur.
Resolves: rhbz#1048842
Based on: cfd1f7490d7958ee25ad5937c9f2072adaa9862e
---
fence/agents/lib/fencing.py.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 8c4a19b..775b567 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -908,7 +908,7 @@ def fence_login(options, re_login_string = "(login\s*: )|(Login Name: )|(userna
sys.stderr.write(str(ex) + "\n")
sys.exit(EC_GENERIC_ERROR)
elif options.has_key("-x") and 0 == options.has_key("-k"):
- command = '%s %s %s@%s -p %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-u"])
+ command = '%s %s %s@%s -p %s -o PubkeyAuthentication=no' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-u"])
if options.has_key("-X"):
command += ' ' + options["-X"]
try:
9 years, 10 months
fence-agents: RHEL6 - fence_vmware_soap: Correct error message when user does not have privileges
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=f49052...
Commit: f49052ae6f385e473e5acc062bee1c2c74159c99
Parent: b8cdfec7e67ca7ef816f0e138b849a0b32bab479
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jun 18 14:22:51 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jun 18 14:22:51 2014 +0200
fence_vmware_soap: Correct error message when user does not have privileges
Previously, when an user does not have privileges to reboot a virtual machine, the
fence agent fails with python traceback. After applying this patch (by Shane Bradley),
the fence_vmware_soap fails with human readable error message.
Based on: be464e49a941f727812615107cbeeda119cf5669
Resolved: rhbz#1018263
---
fence/agents/lib/fencing.py.py | 4 +++-
fence/agents/vmware_soap/fence_vmware_soap.py | 17 +++++++++++++----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 576140e..8c4a19b 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -26,6 +26,7 @@ EC_WAITING_OFF = 7
EC_STATUS = 8
EC_STATUS_HMC = 9
EC_PASSWORD_MISSING = 10
+EC_INVALID_PRIVILEGES = 11
TELNET_PATH = "/usr/bin/telnet"
SSH_PATH = "/usr/bin/ssh"
@@ -451,7 +452,8 @@ def fail(error_code):
EC_WAITING_OFF : "Failed: Timed out waiting to power OFF",
EC_STATUS : "Failed: Unable to obtain correct plug status or plug is not available",
EC_STATUS_HMC : "Failed: Either unable to obtaion correct plug status, partition is not available or incorrect HMC version used",
- EC_PASSWORD_MISSING : "Failed: You have to set login password"
+ EC_PASSWORD_MISSING : "Failed: You have to set login password",
+ EC_INVALID_PRIVILEGES : "Failed: The user does not have the correct privileges to do the requested action."
}[error_code] + "\n"
sys.stderr.write(message)
sys.exit(EC_GENERIC_ERROR)
diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index e6e62ac..efdb8ff 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -161,10 +161,19 @@ def set_power_status(conn, options):
mo_machine = Property(vm.value)
mo_machine._type = "VirtualMachine"
- if options["-o"] == "on":
- conn.service.PowerOnVM_Task(mo_machine)
- else:
- conn.service.PowerOffVM_Task(mo_machine)
+ try:
+ if options["-o"] == "on":
+ conn.service.PowerOnVM_Task(mo_machine)
+ else:
+ conn.service.PowerOffVM_Task(mo_machine)
+ except WebFault, ex:
+ if ((str(ex).find("Permission to perform this operation was denied")) >= 0):
+ fail(EC_INVALID_PRIVILEGES)
+ else:
+ if options["-o"] == "on":
+ fail(EC_WAITING_ON)
+ else:
+ fail(EC_WAITING_OFF)
def remove_tmp_dir(tmp_dir):
shutil.rmtree(tmp_dir)
9 years, 10 months
fence-agents: RHEL6 - fence_wti: Respect --delay in telnet connection
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=b8cdfe...
Commit: b8cdfec7e67ca7ef816f0e138b849a0b32bab479
Parent: 08c1e2ab3a725da2e192a245a078f09517256f98
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jun 18 14:19:02 2014 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jun 18 14:19:02 2014 +0200
fence_wti: Respect --delay in telnet connection
Previously --delay was respected only in ssh connection because fence_wti uses different login
mechanism.
Based on: ab73cbc40309f16025669f754811c8e82ea8265b
Resolves: rhbz#1079291
---
fence/agents/wti/fence_wti.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index b7c41f3..465bef9 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -123,6 +123,9 @@ is running because the connection will block any necessary fencing actions."
#####
if 0 == options.has_key("-x"):
try:
+ if options["-o"] in ["off", "reboot"]:
+ time.sleep(int(options["-f"]))
+
try:
conn = fspawn(options, TELNET_PATH)
conn.send("set binary\n")
9 years, 10 months
fence-agents: RHEL6 - fence_ilo2: Unable to login when password contains "
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=08c1e2...
Commit: 08c1e2ab3a725da2e192a245a078f09517256f98
Parent: b06d381452aa739e47682644bfea80ef1b834bcb
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Wed Jul 31 14:15:58 2013 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Wed Jun 18 14:06:38 2014 +0200
fence_ilo2: Unable to login when password contains "
Resolves: rhbz#990537
Based on: 3a185569e825ee8e948a6cbef8bf847f6a7632dc
Conflicts:
fence/agents/ilo/fence_ilo.py
---
fence/agents/ilo/fence_ilo.py | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index d4e34df..2541729 100644
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -12,6 +12,7 @@
#####
import sys, re, pexpect, socket
+from xml.sax.saxutils import quoteattr
sys.path.append("@FENCEAGENTSLIBDIR@")
from fencing import *
@@ -22,8 +23,8 @@ BUILD_DATE="March, 2008"
#END_VERSION_GENERATION
def get_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
+ " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
conn.send("<SERVER_INFO MODE = \"read\"><GET_HOST_POWER_STATUS/>\r\n")
conn.send("</SERVER_INFO></LOGIN>\r\n")
try:
@@ -37,8 +38,8 @@ def get_power_status(conn, options):
return status.lower().strip()
def set_power_status(conn, options):
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
+ " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
conn.send("<SERVER_INFO MODE = \"write\">")
if options.has_key("fw_processor") and options["fw_processor"] == "iLO2":
@@ -101,8 +102,8 @@ the iLO card through an XML stream."
else:
conn.send("<RIBCL VERSION=\"1.2\">\r\n")
- conn.send("<LOGIN USER_LOGIN = \"" + options["-l"] + "\"" + \
- " PASSWORD = \"" + options["-p"] + "\">\r\n")
+ conn.send("<LOGIN USER_LOGIN = \"" + quoteattr(options["-l"]) + "\"" + \
+ " PASSWORD = \"" + quoteattr(options["-p"]) + "\">\r\n")
if options["-r"] >= 2:
conn.send("<RIB_INFO MODE=\"read\"><GET_FW_VERSION />\r\n")
conn.send("</RIB_INFO>\r\n")
9 years, 10 months
cluster: RHEL6 - mount.gfs2: Don't leave mount group if mount returns EBUSY
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=cluster.git;a=commitdiff;h=0e5ba8bc593...
Commit: 0e5ba8bc5938c8b92d28d1a807616d08bd3ce47e
Parent: 5c24c7c155e0f06f8ad9ca739835eefcda0d6106
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Mar 27 00:48:00 2014 -0500
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Jun 16 16:23:16 2014 +0100
mount.gfs2: Don't leave mount group if mount returns EBUSY
On attempting to mount a gfs2 fs a second time, mount.gfs2 would leave the
mount group causing problems for the first mounted fs. This patch adds a check
for EBUSY so that mount.gfs2 no longer leaves when the fs is already mounted.
Also the existing code was expecting errno to stay the same across library
calls so a new variable is added to store the value to prevent future errno
confusion.
Based on the original EBUSY fix by John Ruemker.
Resolves: rhbz#1080174
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mount/mount.gfs2.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/gfs2/mount/mount.gfs2.c b/gfs2/mount/mount.gfs2.c
index d8e19a7..f1d6cfd 100644
--- a/gfs2/mount/mount.gfs2.c
+++ b/gfs2/mount/mount.gfs2.c
@@ -161,6 +161,7 @@ int main(int argc, char **argv)
struct gen_sb sb;
char *proto;
int rv = 0;
+ int mnterr = 0;
memset(&mo, 0, sizeof(mo));
memset(&sb, 0, sizeof(sb));
@@ -202,19 +203,19 @@ int main(int argc, char **argv)
die("error mounting lockproto %s\n", proto);
rv = mount(mo.dev, mo.dir, fsname, mo.flags, mo.extra_plus);
+ mnterr = errno;
if (rv) {
- log_debug("mount(2) failed error %d errno %d", rv, errno);
+ log_debug("mount(2) failed error %d errno %d", rv, mnterr);
mount_done_lockproto(proto, &mo, &sb, rv);
- if (!(mo.flags & MS_REMOUNT))
- umount_lockproto(proto, &mo, &sb, errno);
+ if (!(mo.flags & MS_REMOUNT) && mnterr != EBUSY)
+ umount_lockproto(proto, &mo, &sb, mnterr);
- if (errno == EBUSY)
+ if (mnterr == EBUSY)
die("%s already mounted or %s busy\n", mo.dev, mo.dir);
- else if (errno == EUSERS)
+ else if (mnterr == EUSERS)
die("Too many nodes mounting filesystem, no free journals\n");
- die("error mounting %s on %s: %s\n", mo.dev, mo.dir,
- strerror(errno));
+ die("error mounting %s on %s: %s\n", mo.dev, mo.dir, strerror(mnterr));
}
log_debug("mount(2) ok");
mount_done_lockproto(proto, &mo, &sb, 0);
9 years, 10 months