cluster: RHEL4 - rgmanager: randomize svclib_nfslock temp dir
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 0e3074ee3666bef630884c323028486aeed28e62
Parent: 1eb1c1db6b2d7b8671568c05ef8e01e64620842c
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Oct 30 12:36:05 2008 +0100
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:21:02 2010 -0400
rgmanager: randomize svclib_nfslock temp dir
by using a static path to /tmp, the operation can be used to trigger
a local DoS by a normal user.
Randomize temp dir via mktemp.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/src/resources/svclib_nfslock | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/rgmanager/src/resources/svclib_nfslock b/rgmanager/src/resources/svclib_nfslock
index 2101e1e..a0250b2 100644
--- a/rgmanager/src/resources/svclib_nfslock
+++ b/rgmanager/src/resources/svclib_nfslock
@@ -37,7 +37,7 @@
#
nfslock_statd_notify()
{
- declare tmpdir=/tmp/statd-$2.$$
+ declare tmpdir=$(mktemp -d /tmp/statd-$2.XXXXXX)
declare nl_dir=$1
declare nl_ip=$2
declare command # Work around bugs in rpc.statd
@@ -55,7 +55,6 @@ nfslock_statd_notify()
fi
# Ok, copy the HA directory to something we can use.
- rm -rf $tmpdir
mkdir -p $tmpdir/sm
# Copy in our specified entries
13 years, 6 months
cluster: RHEL4 - rgmanager: randomize SAPDatabase temp file even more
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 1eb1c1db6b2d7b8671568c05ef8e01e64620842c
Parent: c5905887eca9ee0e6a1ea6673300b73433b5035e
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Oct 30 10:32:11 2008 +0100
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:20:26 2010 -0400
rgmanager: randomize SAPDatabase temp file even more
ad4d9bd9216d6fa259118017bac8b5c032b7b3b9 didn't introduce enough
security.
Switch to mktemp(1).
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/src/resources/SAPDatabase | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/SAPDatabase b/rgmanager/src/resources/SAPDatabase
index 5e2aa83..c06f227 100755
--- a/rgmanager/src/resources/SAPDatabase
+++ b/rgmanager/src/resources/SAPDatabase
@@ -553,7 +553,7 @@ then
fi
# Set a tempfile and make sure to clean it up again
-TEMPFILE="/tmp/SAPDatabase.tmp"
+TEMPFILE="$(mktemp -t /tmp/SAPDatabase.tmp.XXXXXX)"
trap trap_handler INT TERM
# These operations don't require OCF instance parameters to be set
13 years, 6 months
cluster: RHEL4 - rgmanager: randomize smb.sh temp file
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c5905887eca9ee0e6a1ea6673300b73433b5035e
Parent: d9af8f86af3749fbc69bc1c22c61149fc6e75ca8
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Oct 30 12:32:08 2008 +0100
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:19:13 2010 -0400
rgmanager: randomize smb.sh temp file
by using a static path to /tmp, the operation can be used to trigger
a local DoS by a normal user.
Randomize temp files via mktemp.
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/src/resources/smb.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rgmanager/src/resources/smb.sh b/rgmanager/src/resources/smb.sh
index f419f43..71ff4fd 100755
--- a/rgmanager/src/resources/smb.sh
+++ b/rgmanager/src/resources/smb.sh
@@ -350,7 +350,7 @@ add_sha1()
verify_sha1()
{
- declare tmpfile="/tmp/smb-$OCF_RESKEY_name.tmp.$$"
+ declare tmpfile="$(mktemp /tmp/smb-${OCF_RESKEY}_name.tmp.XXXXXX)"
declare current exp
exp=$(grep "^# rgmanager-sha1.*$1" "$1" | head -1)
13 years, 6 months
cluster: RHEL4 - rgmanager: Randomize tmp file names in Oracle agent
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d9af8f86af3749fbc69bc1c22c61149fc6e75ca8
Parent: 65a091eb4fe190cf1063c1f6d3e559cd1a836e7c
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed May 20 18:17:25 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:18:43 2010 -0400
rgmanager: Randomize tmp file names in Oracle agent
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/oracledb.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/rgmanager/src/resources/oracledb.sh b/rgmanager/src/resources/oracledb.sh
index 5b8e113..a415dc0 100755
--- a/rgmanager/src/resources/oracledb.sh
+++ b/rgmanager/src/resources/oracledb.sh
@@ -258,8 +258,8 @@ start_db()
declare logfile
declare -i rv
- tmpfile=/tmp/$SCRIPT-start.$$
- logfile=/tmp/$SCRIPT-start.log
+ tmpfile=$(mktemp /tmp/$SCRIPT-start.tmp.XXXXXX)
+ logfile=$(mktemp /tmp/$SCRIPT-start.log.XXXXXX)
#
# Set up our sqlplus script. Basically, we're trying to
@@ -308,8 +308,8 @@ stop_db()
declare logfile
declare -i rv
- tmpfile=/tmp/$SCRIPT-stop.$$
- logfile=/tmp/$SCRIPT-stop.log
+ tmpfile=$(mktemp /tmp/$SCRIPT-stop.tmp.XXXXXX)
+ logfile=$(mktemp /tmp/$SCRIPT-stop.log.XXXXXX)
# Setup for Stop ...
echo "shutdown abort" > $tmpfile
13 years, 6 months
cluster: RHEL4 - resource-agents: Fix magma_tool return code checking
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 65a091eb4fe190cf1063c1f6d3e559cd1a836e7c
Parent: 44a5db04457aa4003f551b0debf2bb0a996d8e99
Author: Eduardo Damato <edamato(a)redhat.com>
AuthorDate: Thu Oct 21 18:08:16 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:09:22 2010 -0400
resource-agents: Fix magma_tool return code checking
Resolves: rhbz#516758
Reviewed-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/utils/member_util.sh | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/resources/utils/member_util.sh b/rgmanager/src/resources/utils/member_util.sh
index 695c8da..4026e59 100644
--- a/rgmanager/src/resources/utils/member_util.sh
+++ b/rgmanager/src/resources/utils/member_util.sh
@@ -69,6 +69,12 @@ local_node_name()
if which magma_tool &> /dev/null; then
# Use magma_tool, if available.
line=$(magma_tool localname | grep "^Local")
+ res=$?
+
+ if [ $res -ne 0 ]; then
+ # magma_tool failed.
+ return 2
+ fi
if [ -n "$line" ]; then
echo ${line/* = /}
13 years, 6 months
cluster: RHEL4 - rgmanager: isAlive error logging for file systems
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 44a5db04457aa4003f551b0debf2bb0a996d8e99
Parent: bf3e09fcbcf0b661df5b45febd825569d31ac74d
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Wed Feb 10 12:11:33 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 18:02:14 2010 -0400
rgmanager: isAlive error logging for file systems
This change adapts two different patch sets, one
contributed by Nick Downs.
It fixes:
- isAlive logging for all file systems
- file naming during isAlive checks for cluster
file systems
Resolves: rhbz#469815
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/clusterfs.sh | 15 +++++++++++----
rgmanager/src/resources/fs.sh | 13 ++++++++++---
2 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/rgmanager/src/resources/clusterfs.sh b/rgmanager/src/resources/clusterfs.sh
index 3fa35b1..fa2994d 100755
--- a/rgmanager/src/resources/clusterfs.sh
+++ b/rgmanager/src/resources/clusterfs.sh
@@ -439,8 +439,9 @@ Device $dev is mounted on $tmp_mp instead of $mp"
#
isAlive()
{
+ declare errcode
declare mount_point
- declare file=".writable_test"
+ declare file=".writable_test.$(hostname)"
declare rw
if [ $# -ne 1 ]; then
@@ -459,8 +460,10 @@ isAlive()
# depth 10 test (read test)
ls $mount_point > /dev/null 2> /dev/null
- if [ $? -ne 0 ]; then
- return $NO
+ errcode=$?
+ if [ $errcode -ne 0 ]; then
+ ocf_log err "clusterfs:${OCF_RESKEY_name}: isAlive failed read test on [$mount_point]. Return code: $errcode"
+ return $NO
fi
[ $OCF_CHECK_LEVEL -lt 20 ] && return $YES
@@ -483,7 +486,11 @@ isAlive()
fi
done
touch $file > /dev/null 2> /dev/null
- [ $? -ne 0 ] && return $NO
+ errcode=$?
+ if [ $errcode -ne 0 ]; then
+ ocf_log err "clusterfs:${OCF_RESKEY_name}: isAlive failed write test on [$mount_point]. Return code: $errcode"
+ return $NO
+ fi
rm -f $file > /dev/null 2> /dev/null
fi
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 0490c3b..2c380b7 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -635,6 +635,7 @@ isMounted () {
#
isAlive()
{
+ declare errcode
declare mount_point
declare file=".writable_test"
declare rw
@@ -655,8 +656,10 @@ isAlive()
# depth 10 test (read test)
ls $mount_point > /dev/null 2> /dev/null
- if [ $? -ne 0 ]; then
- return $NO
+ errcode=$?
+ if [ $errcode -ne 0 ]; then
+ ocf_log err "fs:${OCF_RESKEY_name}: isAlive failed read test on [$mount_point]. Return code: $errcode"
+ return $NO
fi
[ $OCF_CHECK_LEVEL -lt 20 ] && return $YES
@@ -679,7 +682,11 @@ isAlive()
fi
done
touch $file > /dev/null 2> /dev/null
- [ $? -ne 0 ] && return $NO
+ errcode=$?
+ if [ $errcode -ne 0 ]; then
+ ocf_log err "fs:${OCF_RESKEY_name}: isAlive failed write test on [$mount_point]. Return code: $errcode"
+ return $NO
+ fi
rm -f $file > /dev/null 2> /dev/null
fi
13 years, 6 months
cluster: RHEL4 - qdisk: Implement I/O timeout for read
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: bf3e09fcbcf0b661df5b45febd825569d31ac74d
Parent: d586efd354c0df2507a293d2fd9f472610928006
Author: Eduardo Damato <edamato(a)redhat.com>
AuthorDate: Tue Sep 29 10:06:26 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 17:31:11 2010 -0400
qdisk: Implement I/O timeout for read
This patch creates a timer for last successful read and
reboots the system if last successful read was more than
interval*tko ago.
Resolves: rhbz#510611
Part 2/2
Signed-off-by: Eduardo Damato <edamato(a)redhat.com>
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/qdisk/main.c | 39 +++++++++++++++++++++++++++++++--------
1 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 8b79916..10ec337 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -138,10 +138,10 @@ check_self(qd_ctx *ctx, status_block_t *sb)
or has not updated their timestamp recently. See check_transitions as
well.
*/
-void
+int
read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
{
- int x;
+ int x, errors = 0;
status_block_t *sb;
for (x = 0; x < max; x++) {
@@ -153,6 +153,7 @@ read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
sb, sizeof(*sb)) < 0) {
clulog(LOG_WARNING,"Error reading node ID block %d\n",
x+1);
+ errors++;
continue;
}
swab_status_block_t(sb);
@@ -188,6 +189,8 @@ read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
ni[x].ni_seen++;
ni[x].ni_last_seen = sb->ps_timestamp;
}
+
+ return errors;
}
@@ -879,7 +882,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
int low_id, bid_pending = 0, score, score_max, score_req,
upgrade = 0, count;
memb_mask_t mask, master_mask;
- struct timeval maxtime, oldtime, newtime, diff, sleeptime, interval, lastok;
+ struct timeval maxtime, oldtime, newtime, diff, sleeptime, interval, rd_lastok, wr_lastok;
ctx->qc_status = S_NONE;
@@ -889,8 +892,11 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
interval.tv_usec = 0;
interval.tv_sec = ctx->qc_interval;
- lastok.tv_usec = 0;
- lastok.tv_sec = 0;
+ rd_lastok.tv_usec = 0;
+ rd_lastok.tv_sec = 0;
+
+ wr_lastok.tv_usec = 0;
+ wr_lastok.tv_sec = 0;
get_my_score(&score, &score_max);
if (score_max < ctx->qc_scoremin) {
@@ -905,7 +911,8 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
get_time(&oldtime, (ctx->qc_flags&RF_UPTIME));
/* Read everyone else's status */
- read_node_blocks(ctx, ni, max);
+ if ( read_node_blocks(ctx, ni, max) == 0 )
+ get_time(&rd_lastok, ctx->qc_flags&RF_UPTIME);
/* Check for node transitions */
check_transitions(ctx, ni, max, mask);
@@ -1077,7 +1084,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
&msg, mask, master_mask) != 0) {
clulog(LOG_ERR, "Error writing to quorum disk\n");
} else {
- get_time(&lastok, ctx->qc_flags&RF_UPTIME);
+ get_time(&wr_lastok, ctx->qc_flags&RF_UPTIME);
}
/* write out our local status */
@@ -1090,7 +1097,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
/*
* Reboot if the last successful hearbeat was longer ago than interval*TKO_COUNT
*/
- _diff_tv(&diff, &lastok, &newtime);
+ _diff_tv(&diff, &wr_lastok, &newtime);
if (_cmp_tv(&maxtime, &diff) == 1 &&
ctx->qc_flags & RF_IOTIMEOUT) {
clulog(LOG_EMERG, "Failed to send a heartbeat within "
@@ -1102,6 +1109,22 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
if (!(ctx->qc_flags & RF_DEBUG))
reboot(RB_AUTOBOOT);
}
+
+ /*
+ * Reboot if the last successful hearbeat was longer ago than interval*TKO_COUNT
+ */
+ _diff_tv(&diff, &rd_lastok, &newtime);
+ if (_cmp_tv(&maxtime, &diff) == 1 &&
+ ctx->qc_flags & RF_IOTIMEOUT) {
+ clulog(LOG_EMERG, "Failed to read from qdisk within "
+ "%d second%s (%d.%06d) - REBOOTING\n",
+ (int)maxtime.tv_sec,
+ maxtime.tv_sec==1?"":"s",
+ (int)diff.tv_sec,
+ (int)diff.tv_usec);
+ if (!(ctx->qc_flags & RF_DEBUG))
+ reboot(RB_AUTOBOOT);
+ }
/*
* Reboot if we didn't send a heartbeat in interval*TKO_COUNT
13 years, 6 months
cluster: RHEL4 - qdisk: Implement I/O timeouts in qdiskd
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d586efd354c0df2507a293d2fd9f472610928006
Parent: f8dd196ce653f532bca859f1729bb332346dd5af
Author: Eduardo Damato <edamato(a)redhat.com>
AuthorDate: Tue Sep 29 09:58:18 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Oct 21 17:31:08 2010 -0400
qdisk: Implement I/O timeouts in qdiskd
This allows administrators to make qdiskd reboot the
system if it can not write its status out for interval*tko
seconds.
Resolves: rhbz#510611
Part 1/2
Signed-off-by: Eduardo Damato <edamato(a)redhat.com>
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/man/qdisk.5 | 7 +++++++
cman/qdisk/disk.h | 3 ++-
cman/qdisk/main.c | 34 ++++++++++++++++++++++++++++++++--
3 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/cman/man/qdisk.5 b/cman/man/qdisk.5
index 336dd6e..e5c5947 100644
--- a/cman/man/qdisk.5
+++ b/cman/man/qdisk.5
@@ -291,6 +291,13 @@ if it takes more than (interval * tko) seconds to complete a quorum disk
pass. The default for this value is 0 (off).
.in 9
+\fIio_timeout\fP\fB="\fP0\fB"\fP
+.in 12
+If set to 1 (on), qdiskd will watch internal timers and reboot the node
+if qdisk is not able to write to disk after (interval * tko) seconds.
+The default for this value is 0 (off).
+
+.in 9
\fIscheduler\fP\fB="\fPrr\fB"\fP
.in 12
Valid values are 'rr', 'fifo', and 'other'. Selects the scheduling queue
diff --git a/cman/qdisk/disk.h b/cman/qdisk/disk.h
index abc870e..f6d1212 100644
--- a/cman/qdisk/disk.h
+++ b/cman/qdisk/disk.h
@@ -73,7 +73,8 @@ typedef enum {
RF_PARANOID = 0x8,
RF_ALLOW_KILL = 0x10,
RF_UPTIME = 0x20,
- RF_CMAN_LABEL = 0x40
+ RF_CMAN_LABEL = 0x40,
+ RF_IOTIMEOUT = 0x80
} run_flag_t;
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 2cc2530..8b79916 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -879,7 +879,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
int low_id, bid_pending = 0, score, score_max, score_req,
upgrade = 0, count;
memb_mask_t mask, master_mask;
- struct timeval maxtime, oldtime, newtime, diff, sleeptime, interval;
+ struct timeval maxtime, oldtime, newtime, diff, sleeptime, interval, lastok;
ctx->qc_status = S_NONE;
@@ -889,6 +889,9 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
interval.tv_usec = 0;
interval.tv_sec = ctx->qc_interval;
+ lastok.tv_usec = 0;
+ lastok.tv_sec = 0;
+
get_my_score(&score, &score_max);
if (score_max < ctx->qc_scoremin) {
clulog(LOG_WARNING, "Minimum score (%d) is impossible to "
@@ -1073,6 +1076,8 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
if (qd_write_status(ctx, ctx->qc_my_id, ctx->qc_status,
&msg, mask, master_mask) != 0) {
clulog(LOG_ERR, "Error writing to quorum disk\n");
+ } else {
+ get_time(&lastok, ctx->qc_flags&RF_UPTIME);
}
/* write out our local status */
@@ -1081,11 +1086,27 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
/* Cycle. We could time the loop and sleep
usleep(interval-looptime), but this is fine for now.*/
get_time(&newtime, ctx->qc_flags&RF_UPTIME);
- _diff_tv(&diff, &oldtime, &newtime);
+ /*
+ * Reboot if the last successful hearbeat was longer ago than interval*TKO_COUNT
+ */
+ _diff_tv(&diff, &lastok, &newtime);
+ if (_cmp_tv(&maxtime, &diff) == 1 &&
+ ctx->qc_flags & RF_IOTIMEOUT) {
+ clulog(LOG_EMERG, "Failed to send a heartbeat within "
+ "%d second%s (%d.%06d) - REBOOTING\n",
+ (int)maxtime.tv_sec,
+ maxtime.tv_sec==1?"":"s",
+ (int)diff.tv_sec,
+ (int)diff.tv_usec);
+ if (!(ctx->qc_flags & RF_DEBUG))
+ reboot(RB_AUTOBOOT);
+ }
+
/*
* Reboot if we didn't send a heartbeat in interval*TKO_COUNT
*/
+ _diff_tv(&diff, &oldtime, &newtime);
if (_cmp_tv(&maxtime, &diff) == 1 &&
ctx->qc_flags & RF_PARANOID) {
clulog(LOG_EMERG, "Failed to complete a cycle within "
@@ -1353,6 +1374,15 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
free(val);
}
+ /* default = off, so, 1 to turn on */
+ snprintf(query, sizeof(query), "/cluster/quorumd/@io_timeout");
+ if (ccs_get(ccsfd, query, &val) == 0) {
+ if (!atoi(val))
+ ctx->qc_flags &= ~RF_IOTIMEOUT;
+ else
+ ctx->qc_flags |= RF_IOTIMEOUT;
+ free(val);
+ }
/*
* Get flag to see if we're supposed to reboot if we can't complete
13 years, 6 months
cluster: RHEL55 - fence-agents: Add power_wait to fence_ipmilan
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: a6ada12cf1843daeb506957e52399c20937be000
Parent: bbb7969d9cdcfa2b5a129b69148dde8034d071df
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Oct 18 21:58:30 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Oct 18 21:58:30 2010 +0200
fence-agents: Add power_wait to fence_ipmilan
Previous patch used power-wait which was inconsistent with
the rest of the fencing agents. Also, help information
for the new option was missing.
Resolves: rhbz#642700
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Signed-off-by: Shane Bradley <sbradley(a)redhat.com>
---
fence/agents/ipmilan/ipmilan.c | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index d8d76ff..ca45fe5 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -54,6 +54,7 @@ do { \
#define ST_CYCLE 4
#define DEFAULT_TIMEOUT 20
+#define DEFAULT_POWER_WAIT 2
#define DEFAULT_METHOD "onoff"
@@ -99,6 +100,7 @@ struct ipmi {
int i_verbose;
int i_lanplus;
int i_timeout;
+ int i_power_wait;
int i_cipher;
};
@@ -441,7 +443,7 @@ ipmi_off(struct ipmi *ipmi)
if (ret != 0)
return ret;
- sleep(2);
+ sleep(ipmi->i_power_wait);
--retries;
ret = ipmi_op(ipmi, ST_STATUS, power_status);
@@ -546,6 +548,7 @@ ipmi_destroy(struct ipmi *i)
static struct ipmi *
ipmi_init(struct ipmi *i, char *host, char *authtype,
char *user, char *password, int lanplus, int verbose,int timeout,
+ int power_wait,
int cipher)
{
const char *p;
@@ -618,6 +621,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
i->i_verbose = verbose;
i->i_lanplus = lanplus;
i->i_timeout = timeout;
+ i->i_power_wait = power_wait;
i->i_cipher = cipher;
return i;
@@ -904,6 +908,7 @@ get_options_stdin(char *ip, size_t iplen,
char *user, size_t userlen,
char *op, size_t oplen,
int *lanplus, int *verbose,int *timeout,
+ int *power_wait,
int *cipher, char *method, int methodlen)
{
char in[256];
@@ -971,6 +976,10 @@ get_options_stdin(char *ip, size_t iplen,
if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
*timeout=DEFAULT_TIMEOUT;
}
+ } else if (!strcasecmp(name,"power_wait")) {
+ if ((sscanf(val,"%d",power_wait)!=1) || *power_wait<1) {
+ *power_wait=DEFAULT_POWER_WAIT;
+ }
} else if (!strcasecmp(name,"cipher")) {
if ((sscanf(val,"%d",cipher)!=1) || *cipher<0) {
*cipher=-1;
@@ -1017,6 +1026,7 @@ printf(" -l <login> Username/Login (if required) to control power\n"
printf(" -o <op> Operation to perform.\n");
printf(" Valid operations: on, off, reboot, status\n");
printf(" -t <timeout> Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
+printf(" -T <timeout> Wait X seconds after on/off operation\n");
printf(" -C <cipher> Ciphersuite to use (same as ipmitool -C parameter)\n");
printf(" -M <method> Method to fence (onoff or cycle (default %s)\n", DEFAULT_METHOD);
printf(" -V Print version and exit\n");
@@ -1033,6 +1043,7 @@ printf(" option=<op> Same as -o\n");
printf(" operation=<op> Same as -o\n");
printf(" action=<op> Same as -o\n");
printf(" timeout=<timeout> Same as -t\n");
+printf(" power_wait=<time> Same as -T\n");
printf(" cipher=<cipher> Same as -C\n");
printf(" method=<method> Same as -M\n");
printf(" verbose Same as -v\n\n");
@@ -1057,6 +1068,7 @@ main(int argc, char **argv)
char *pname = basename(argv[0]);
struct ipmi *i;
int timeout=DEFAULT_TIMEOUT;
+ int down_sleep=DEFAULT_POWER_WAIT;
int cipher=-1;
memset(ip, 0, sizeof(ip));
@@ -1070,7 +1082,7 @@ main(int argc, char **argv)
/*
Parse command line options if any were specified
*/
- while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:T:C:M:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -1106,6 +1118,12 @@ main(int argc, char **argv)
fail_exit("Timeout option expects positive number parameter");
}
break;
+ case 'T':
+ /* Shutdown Sleep Time */
+ if ((sscanf(optarg,"%d",&down_sleep)!=1) || down_sleep<1) {
+ fail_exit("Shutdown time option expects positive number parameter");
+ }
+ break;
case 'C':
/* Ciphersuite */
if ((sscanf(optarg,"%d",&cipher)!=1) || cipher<0) {
@@ -1140,6 +1158,7 @@ main(int argc, char **argv)
pwd_script, sizeof(pwd_script),
user, sizeof(user),
op, sizeof(op), &lanplus, &verbose,&timeout,
+ &down_sleep,
&cipher, method, sizeof(method)) != 0)
return 1;
}
@@ -1202,7 +1221,7 @@ main(int argc, char **argv)
}
/* Ok, set up the IPMI struct */
- i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
+ i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, down_sleep, cipher);
if (!i)
fail_exit("Failed to initialize\n");
13 years, 6 months
cluster: RHEL60 - fence-agents: Add power_wait to fence_ipmilan
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: add3241e26811a0c98524add304312609166f7ae
Parent: 6e4a860937034b8263f966660ef35c2231aa0c0e
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Oct 14 21:53:07 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Oct 18 21:48:12 2010 +0200
fence-agents: Add power_wait to fence_ipmilan
Previous patch used power-wait which was inconsistent with
the rest of the fencing agents. Also, help information
for the new option was missing.
Resolves: rhbz#643340
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Signed-off-by: Shane Bradley <sbradley(a)redhat.com>
---
fence/agents/ipmilan/ipmilan.c | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 58a86c9..beffdb6 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -28,6 +28,7 @@
#define ST_CYCLE 4
#define DEFAULT_TIMEOUT 20
+#define DEFAULT_POWER_WAIT 2
#define DEFAULT_METHOD "onoff"
@@ -78,6 +79,7 @@ struct ipmi {
int i_verbose;
int i_lanplus;
int i_timeout;
+ int i_power_wait;
int i_cipher;
};
@@ -166,6 +168,7 @@ struct xml_parameter_s xml_parameters[]={
{"timeout","-t",0,"string",NULL,"Timeout (sec) for IPMI operation"},
{"cipher","-C",0,"string",NULL,"Ciphersuite to use (same as ipmitool -C parameter)"},
{"method","-M",0,"string",DEFAULT_METHOD,"Method to fence (onoff or cycle)"},
+ {"power_wait","-T",0,"string","2","Wait X seconds after on/off operation"},
{"verbose","-v",0,"boolean",NULL,"Verbose mode"}};
/*
@@ -485,7 +488,7 @@ ipmi_on(struct ipmi *ipmi)
if (ret != 0)
return ret;
- sleep(2);
+ sleep(ipmi->i_power_wait);
--retries;
ret = ipmi_op(ipmi, ST_STATUS, power_status);
@@ -548,6 +551,7 @@ ipmi_destroy(struct ipmi *i)
static struct ipmi *
ipmi_init(struct ipmi *i, char *host, char *authtype,
char *user, char *password, int lanplus, int verbose,int timeout,
+ int power_wait,
int cipher)
{
const char *p;
@@ -620,6 +624,7 @@ ipmi_init(struct ipmi *i, char *host, char *authtype,
i->i_verbose = verbose;
i->i_lanplus = lanplus;
i->i_timeout = timeout;
+ i->i_power_wait = power_wait;
i->i_cipher = cipher;
return i;
@@ -684,6 +689,7 @@ get_options_stdin(char *ip, size_t iplen,
char *user, size_t userlen,
char *op, size_t oplen,
int *lanplus, int *verbose,int *timeout,
+ int *power_wait,
int *cipher, char *method, int methodlen)
{
char in[256];
@@ -751,6 +757,10 @@ get_options_stdin(char *ip, size_t iplen,
if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
*timeout=DEFAULT_TIMEOUT;
}
+ } else if (!strcasecmp(name,"power_wait")) {
+ if ((sscanf(val,"%d",power_wait)!=1) || *power_wait<1) {
+ *power_wait=DEFAULT_POWER_WAIT;
+ }
} else if (!strcasecmp(name,"cipher")) {
if ((sscanf(val,"%d",cipher)!=1) || *cipher<0) {
*cipher=-1;
@@ -797,6 +807,7 @@ printf(" -l <login> Username/Login (if required) to control power\n"
printf(" -o <op> Operation to perform.\n");
printf(" Valid operations: on, off, reboot, status, list or monitor\n");
printf(" -t <timeout> Timeout (sec) for IPMI operation (default %d)\n",DEFAULT_TIMEOUT);
+printf(" -T <timeout> Wait X seconds after on/off operation\n");
printf(" -C <cipher> Ciphersuite to use (same as ipmitool -C parameter)\n");
printf(" -M <method> Method to fence (onoff or cycle (default %s)\n", DEFAULT_METHOD);
printf(" -V Print version and exit\n");
@@ -813,6 +824,7 @@ printf(" option=<op> Same as -o\n");
printf(" operation=<op> Same as -o\n");
printf(" action=<op> Same as -o\n");
printf(" timeout=<timeout> Same as -t\n");
+printf(" power_wait=<time> Same as -T\n");
printf(" cipher=<cipher> Same as -C\n");
printf(" method=<method> Same as -M\n");
printf(" verbose Same as -v\n\n");
@@ -880,6 +892,7 @@ main(int argc, char **argv)
char *pname = basename(argv[0]);
struct ipmi *i;
int timeout=DEFAULT_TIMEOUT;
+ int down_sleep=DEFAULT_POWER_WAIT;
int cipher=-1;
int print_final_status=1;
int translated_ret = -1;
@@ -895,7 +908,7 @@ main(int argc, char **argv)
/*
Parse command line options if any were specified
*/
- while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:C:M:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:T:C:M:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -931,6 +944,12 @@ main(int argc, char **argv)
fail_exit("Timeout option expects positive number parameter");
}
break;
+ case 'T':
+ /* Shutdown Sleep Time */
+ if ((sscanf(optarg,"%d",&down_sleep)!=1) || down_sleep<1) {
+ fail_exit("Shutdown time option expects positive number parameter");
+ }
+ break;
case 'C':
/* Ciphersuite */
if ((sscanf(optarg,"%d",&cipher)!=1) || cipher<0) {
@@ -965,6 +984,7 @@ main(int argc, char **argv)
pwd_script, sizeof(pwd_script),
user, sizeof(user),
op, sizeof(op), &lanplus, &verbose,&timeout,
+ &down_sleep,
&cipher, method, sizeof(method)) != 0)
return 1;
}
@@ -1037,7 +1057,7 @@ main(int argc, char **argv)
}
/* Ok, set up the IPMI struct */
- i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
+ i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, down_sleep, cipher);
if (!i)
fail_exit("Failed to initialize\n");
13 years, 6 months