cluster: RHEL56 - rgmanager: Honor restricted FDs during migrations
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: c5c968af388618038ca132cd0dbb01b66f1533b5
Parent: a02d38b1576261ae7ff58316b918587c3ab402f5
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Aug 5 16:02:11 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 16:30:57 2010 -0400
rgmanager: Honor restricted FDs during migrations
Rgmanager was ignoring restricted failover domain
rules when processing -M commands from clusvcadm.
Resolves: rhbz#592380
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/rg_state.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/rg_state.c b/rgmanager/src/daemons/rg_state.c
index 3e57748..66ed85f 100644
--- a/rgmanager/src/daemons/rg_state.c
+++ b/rgmanager/src/daemons/rg_state.c
@@ -892,6 +892,11 @@ svc_migrate(char *svcName, int target)
return RG_ENODE;
}
+ if (node_should_start_safe(target, membership, svcName) == FOD_ILLEGAL) {
+ free_member_list(membership);
+ return RG_EDEPEND;
+ }
+
count_resource_groups_local(m);
if (m->cn_svcexcl ||
(m->cn_svccount && is_exclusive(svcName))) {
13 years, 9 months
cluster: STABLE3 - rgmanager: Honor restricted FDs during migrations
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9a5de317a9bf9f9dfc57c6b98ed58a988978c94d
Parent: d49617f50929309b98e860f2b4b9ddfb60a80782
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Aug 5 16:02:11 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 16:28:42 2010 -0400
rgmanager: Honor restricted FDs during migrations
Rgmanager was ignoring restricted failover domain
rules when processing -M commands from clusvcadm.
Resolves: rhbz#621694
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/rg_state.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/rgmanager/src/daemons/rg_state.c b/rgmanager/src/daemons/rg_state.c
index d23772f..ee1b6eb 100644
--- a/rgmanager/src/daemons/rg_state.c
+++ b/rgmanager/src/daemons/rg_state.c
@@ -829,6 +829,11 @@ svc_migrate(const char *svcName, int target)
return RG_ENODE;
}
+ if (node_should_start_safe(target, membership, svcName) == FOD_ILLEGAL) {
+ free_member_list(membership);
+ return RG_EDEPEND;
+ }
+
count_resource_groups_local(m);
if (m->cn_svcexcl ||
(m->cn_svccount && is_exclusive(svcName))) {
13 years, 9 months
cluster: STABLE3 - rgmanager: Fix clustat return code
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: d49617f50929309b98e860f2b4b9ddfb60a80782
Parent: 3ac0bdfccc5c8b6883e3c331dfa3fca7eeb1b4c5
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Aug 5 14:58:18 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 14:58:18 2010 -0400
rgmanager: Fix clustat return code
If rgmanager was not running, clustat would return -1 (255)
Resolves: rhbz#621562
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/utils/clustat.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/rgmanager/src/utils/clustat.c b/rgmanager/src/utils/clustat.c
index 077eaf5..2a93659 100644
--- a/rgmanager/src/utils/clustat.c
+++ b/rgmanager/src/utils/clustat.c
@@ -867,7 +867,7 @@ txt_cluster_status(cman_cluster_t *ci,
rg_state_list_t *rgs, char *name, char *svcname,
int flags)
{
- int ret = 0;
+ int ret1 = 0, ret2 = 0;
if (!svcname && !name) {
txt_cluster_info(ci);
@@ -879,14 +879,18 @@ txt_cluster_status(cman_cluster_t *ci,
}
}
- if (!svcname || (name && svcname))
- ret = txt_member_states(membership, name);
- if (name && !svcname)
- return ret;
- if (!name || (name && svcname))
- ret = txt_rg_states(rgs, membership, svcname, flags);
-
- return ret;
+ if (!svcname || (name && svcname))
+ ret1 = txt_member_states(membership, name);
+
+ if (rgs &&
+ (!name || (name && svcname)))
+ ret2 = txt_rg_states(rgs, membership, svcname, flags);
+
+ if (name && ret1)
+ return ret1;
+ if (svcname && ret2)
+ return ret2;
+ return 0;
}
13 years, 9 months
cluster: RHEL6 - cman: Clarify man page on config distribution
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: dbb67ee051f60b03d91cdf7ddba214c7af2db588
Parent: b42898305e61749c915ad2c3c6d66525820ea57b
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Aug 5 11:46:54 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 11:54:30 2010 -0400
cman: Clarify man page on config distribution
Resolves: rhbz#619680
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/man/cman_tool.8 | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/cman/man/cman_tool.8 b/cman/man/cman_tool.8
index 964ab44..5d38941 100644
--- a/cman/man/cman_tool.8
+++ b/cman/man/cman_tool.8
@@ -136,30 +136,28 @@ name as it appears in 'cman_tool nodes'.
.SH "VERSION" OPTIONS
.TP
-.I -r <config_version>
+.I -r
Update config version. You don't need to use this when adding a new node,
the new cman node will tell the rest of the cluster to read the latest
-version of the config file automatically.
-.br
-In fact the argument to -r might look as though it is ignored.
-Its presence simply tells cman to re-read the configuration file and look
-for that version in the file. cman will keep re-reading the file
-until a version number >= the passed version is found.
+version of the config file automatically. The version present in the
+new configuration must be higher than the one currently in use by cman.
.br
+
cman_tool version on its own will always show the current version
and not the one being looked for. So be aware that the display
-will possible not update immediately after you have run
+will possibly not update immediately after you have run
cman_tool version -r.
.TP
.I -D<option>
see "JOIN" options
.TP
.I -S
-By default cman_tool version will try to distribute the new cluster.conf file using
-ricci. If you have distributed the file yourself and/or do not have ricci
-installed then the -S option will skip this step.
-NOTE: it is still important that all nodes in the cluster have the same version of
-the file. Make sure that this is the case before using this option.
+By default cman_tool version will try to distribute the new cluster.conf
+file using ccs_sync and ricci. If you have distributed the file yourself
+and/or do not have ricci installed then the -S option will skip this step.
+NOTE: it is still important that all nodes in the cluster have the
+same version of the file. Make sure that this is the case before using
+this option.
.SH "WAIT" OPTIONS
.TP
.I -q
13 years, 9 months
cluster: RHEL6 - cman: do not propagate old configurations around
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: b42898305e61749c915ad2c3c6d66525820ea57b
Parent: 3a16ab778ddaa51d52994b615cab1522b938e5af
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Aug 5 16:32:18 2010 +0200
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 11:54:16 2010 -0400
cman: do not propagate old configurations around
Add a check in ccs_config_validate to make sure that the new
configuration we are about to load in the running cluster is newer
than the running config.
This avoids unnecessary ccs_sync of a bad config around.
Resolves: rhbz#619680
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/cman_tool/main.c | 37 +++++++++++++++++++++++++------
config/tools/xml/ccs_config_validate.in | 34 +++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index af1cc18..886e6a7 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -649,11 +649,12 @@ static void set_votes(commandline_t *comline)
cman_finish(h);
}
-static int validate_config(commandline_t *comline)
+static int validate_config(commandline_t *comline, int current_version)
{
struct stat st;
char command[PATH_MAX];
char validator[PATH_MAX];
+ char ccs_quiet[8];
int cmd_res;
/* Look for ccs_config_validate */
@@ -663,14 +664,26 @@ static int validate_config(commandline_t *comline)
return 0;
}
- snprintf(command, sizeof(command), "%s -q", validator);
+ if (comline->verbose > 1) {
+ snprintf(ccs_quiet, sizeof(ccs_quiet), " ");
+ } else {
+ snprintf(ccs_quiet, sizeof(ccs_quiet), "-q");
+ }
+
+ if (current_version) {
+ snprintf(command, sizeof(command), "%s %s -R %d",
+ validator, ccs_quiet, current_version);
+ } else {
+ snprintf(command, sizeof(command), "%s %s",
+ validator, ccs_quiet);
+ }
if (comline->verbose > 1)
printf("calling '%s'\n", command);
cmd_res = system(command);
- return cmd_res;
+ return WEXITSTATUS(cmd_res);
}
/* Here we set the COROSYNC_ variables that might be needed by the corosync
@@ -759,9 +772,19 @@ static void version(commandline_t *comline)
if (comline->verbose)
printf("Validating configuration\n");
- if (validate_config(comline) &&
- comline->config_validate_opt == VALIDATE_FAIL)
- die("Not reloading, configuration is not valid\n");
+ result = validate_config(comline, ver.cv_config);
+ if (result == 253)
+ /* Unable to find new config version */
+ die("Unable to retrive the new config version\n");
+ if (result == 254)
+ /* Config regression = fail. */
+ die("Not reloading, config version older or equal the running config");
+ if (result == 255)
+ /* Generic error from ccs_config_validate */
+ die("Not reloading, generic error running ccs_config_validate\n"
+ "Try re-running with -d options");
+ else if (result && comline->config_validate_opt == VALIDATE_FAIL)
+ die("Not reloading, configuration is not valid");
}
/* We don't bother looking for ccs_sync here - just assume it's in /usr/bin and
@@ -1176,7 +1199,7 @@ static void do_join(commandline_t *comline, char *envp[])
if (comline->verbose)
printf("Validating configuration\n");
- if (validate_config(comline) &&
+ if (validate_config(comline, 0) &&
comline->config_validate_opt == VALIDATE_FAIL)
die("Not joining, configuration is not valid\n");
}
diff --git a/config/tools/xml/ccs_config_validate.in b/config/tools/xml/ccs_config_validate.in
index 55ab4aa..f7d7c04 100644
--- a/config/tools/xml/ccs_config_validate.in
+++ b/config/tools/xml/ccs_config_validate.in
@@ -17,6 +17,15 @@ if [ -z "$COROSYNC_DEFAULT_CONFIG_IFACE" ]; then
export COROSYNC_DEFAULT_CONFIG_IFACE=$CONFIG_LOADER:cmanpreconfig
fi
+get_config_version() {
+ local file=$1
+
+ echo "xpath /cluster/@config_version" | \
+ xmllint --shell "$file" | \
+ grep content | \
+ cut -f2 -d=
+}
+
print_usage() {
echo "Usage:"
echo ""
@@ -38,6 +47,8 @@ print_usage() {
echo " -t tempfile Force temporay file to tempfile"
echo " -n Do not remove temporary file"
echo " -o Overwrite temporary file (dangerous)"
+ echo " -R version When validating configuration update, ensure the"
+ echo " new config is newer than the specified version."
}
check_opts() {
@@ -61,6 +72,10 @@ check_opts() {
-o)
overwritetempfile=1
;;
+ -R)
+ shift
+ old_version=$1
+ ;;
-C)
shift
export COROSYNC_DEFAULT_CONFIG_IFACE=$1:cmanpreconfig
@@ -131,7 +146,7 @@ lecho()
return 0
}
-opts=$(getopt t:hVnC:f:l:rovq $@)
+opts=$(getopt t:hVnC:f:l:rR:ovq $@)
if [ "$?" != 0 ]; then
print_usage >&2
exit 255
@@ -174,6 +189,23 @@ xmlout=$(xmllint --noout \
$tempfile 2>&1)
res=$?
+if [ -n "$old_version" ] && [ $old_version -ne 0 ] && [ $res -eq 0 ]; then
+ new_version=$(get_config_version $tempfile)
+ if [ -z "$new_version" ]; then
+ [ -z "$quiet" ] && \
+ echo "Error: Unable to determine new config version!" >&2
+ [ -z "$notempfilerm" ] && rm -f $tempfile
+ exit 253
+ fi
+ lecho "Old version: $old_version New version: $new_version"
+ if [ $new_version -le $old_version ]; then
+ [ -z "$quiet" ] && \
+ echo "Error: Configuration version is older than running config!" >&2
+ [ -z "$notempfilerm" ] && rm -f $tempfile
+ exit 254
+ fi
+fi
+
if [ -z "$quiet" ] || [ "$res" != "0" ]; then
echo "$xmlout" | sed \
-e 's#.*validates$#Configuration validates#g' \
13 years, 9 months
cluster: STABLE3 - cman: Clarify man page on config distribution
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 3ac0bdfccc5c8b6883e3c331dfa3fca7eeb1b4c5
Parent: 9cd607e41482b408aedb1afb53d56f5b05d05d7a
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Thu Aug 5 11:46:54 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Thu Aug 5 11:51:40 2010 -0400
cman: Clarify man page on config distribution
Resolves: rhbz#619680
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/man/cman_tool.8 | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/cman/man/cman_tool.8 b/cman/man/cman_tool.8
index 2ee2524..7bb9769 100644
--- a/cman/man/cman_tool.8
+++ b/cman/man/cman_tool.8
@@ -136,30 +136,28 @@ name as it appears in 'cman_tool nodes'.
.SH "VERSION" OPTIONS
.TP
-.I -r <config_version>
+.I -r
Update config version. You don't need to use this when adding a new node,
the new cman node will tell the rest of the cluster to read the latest
-version of the config file automatically.
-.br
-In fact the argument to -r might look as though it is ignored.
-Its presence simply tells cman to re-read the configuration file and look
-for that version in the file. cman will keep re-reading the file
-until a version number >= the passed version is found.
+version of the config file automatically. The version present in the
+new configuration must be higher than the one currently in use by cman.
.br
+
cman_tool version on its own will always show the current version
and not the one being looked for. So be aware that the display
-will possible not update immediately after you have run
+will possibly not update immediately after you have run
cman_tool version -r.
.TP
.I -D<option>
see "JOIN" options
.TP
.I -S
-By default cman_tool version will try to distribute the new cluster.conf file using
-ricci. If you have distributed the file yourself and/or do not have ricci
-installed then the -S option will skip this step.
-NOTE: it is still important that all nodes in the cluster have the same version of
-the file. Make sure that this is the case before using this option.
+By default cman_tool version will try to distribute the new cluster.conf
+file using ccs_sync and ricci. If you have distributed the file yourself
+and/or do not have ricci installed then the -S option will skip this step.
+NOTE: it is still important that all nodes in the cluster have the
+same version of the file. Make sure that this is the case before using
+this option.
.SH "WAIT" OPTIONS
.TP
.I -q
13 years, 9 months
cluster: STABLE3 - cman: do not propagate old configurations around
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 9cd607e41482b408aedb1afb53d56f5b05d05d7a
Parent: e118d34dce64325a93c92833b1e074fbabb1a516
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Thu Aug 5 16:32:18 2010 +0200
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Thu Aug 5 16:32:18 2010 +0200
cman: do not propagate old configurations around
Add a check in ccs_config_validate to make sure that the new
configuration we are about to load in the running cluster is newer
than the running config.
This avoids unnecessary ccs_sync of a bad config around.
Resolves: rhbz#619680
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
cman/cman_tool/main.c | 37 +++++++++++++++++++++++++------
config/tools/xml/ccs_config_validate.in | 34 +++++++++++++++++++++++++++-
2 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index af1cc18..886e6a7 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -649,11 +649,12 @@ static void set_votes(commandline_t *comline)
cman_finish(h);
}
-static int validate_config(commandline_t *comline)
+static int validate_config(commandline_t *comline, int current_version)
{
struct stat st;
char command[PATH_MAX];
char validator[PATH_MAX];
+ char ccs_quiet[8];
int cmd_res;
/* Look for ccs_config_validate */
@@ -663,14 +664,26 @@ static int validate_config(commandline_t *comline)
return 0;
}
- snprintf(command, sizeof(command), "%s -q", validator);
+ if (comline->verbose > 1) {
+ snprintf(ccs_quiet, sizeof(ccs_quiet), " ");
+ } else {
+ snprintf(ccs_quiet, sizeof(ccs_quiet), "-q");
+ }
+
+ if (current_version) {
+ snprintf(command, sizeof(command), "%s %s -R %d",
+ validator, ccs_quiet, current_version);
+ } else {
+ snprintf(command, sizeof(command), "%s %s",
+ validator, ccs_quiet);
+ }
if (comline->verbose > 1)
printf("calling '%s'\n", command);
cmd_res = system(command);
- return cmd_res;
+ return WEXITSTATUS(cmd_res);
}
/* Here we set the COROSYNC_ variables that might be needed by the corosync
@@ -759,9 +772,19 @@ static void version(commandline_t *comline)
if (comline->verbose)
printf("Validating configuration\n");
- if (validate_config(comline) &&
- comline->config_validate_opt == VALIDATE_FAIL)
- die("Not reloading, configuration is not valid\n");
+ result = validate_config(comline, ver.cv_config);
+ if (result == 253)
+ /* Unable to find new config version */
+ die("Unable to retrive the new config version\n");
+ if (result == 254)
+ /* Config regression = fail. */
+ die("Not reloading, config version older or equal the running config");
+ if (result == 255)
+ /* Generic error from ccs_config_validate */
+ die("Not reloading, generic error running ccs_config_validate\n"
+ "Try re-running with -d options");
+ else if (result && comline->config_validate_opt == VALIDATE_FAIL)
+ die("Not reloading, configuration is not valid");
}
/* We don't bother looking for ccs_sync here - just assume it's in /usr/bin and
@@ -1176,7 +1199,7 @@ static void do_join(commandline_t *comline, char *envp[])
if (comline->verbose)
printf("Validating configuration\n");
- if (validate_config(comline) &&
+ if (validate_config(comline, 0) &&
comline->config_validate_opt == VALIDATE_FAIL)
die("Not joining, configuration is not valid\n");
}
diff --git a/config/tools/xml/ccs_config_validate.in b/config/tools/xml/ccs_config_validate.in
index 55ab4aa..f7d7c04 100644
--- a/config/tools/xml/ccs_config_validate.in
+++ b/config/tools/xml/ccs_config_validate.in
@@ -17,6 +17,15 @@ if [ -z "$COROSYNC_DEFAULT_CONFIG_IFACE" ]; then
export COROSYNC_DEFAULT_CONFIG_IFACE=$CONFIG_LOADER:cmanpreconfig
fi
+get_config_version() {
+ local file=$1
+
+ echo "xpath /cluster/@config_version" | \
+ xmllint --shell "$file" | \
+ grep content | \
+ cut -f2 -d=
+}
+
print_usage() {
echo "Usage:"
echo ""
@@ -38,6 +47,8 @@ print_usage() {
echo " -t tempfile Force temporay file to tempfile"
echo " -n Do not remove temporary file"
echo " -o Overwrite temporary file (dangerous)"
+ echo " -R version When validating configuration update, ensure the"
+ echo " new config is newer than the specified version."
}
check_opts() {
@@ -61,6 +72,10 @@ check_opts() {
-o)
overwritetempfile=1
;;
+ -R)
+ shift
+ old_version=$1
+ ;;
-C)
shift
export COROSYNC_DEFAULT_CONFIG_IFACE=$1:cmanpreconfig
@@ -131,7 +146,7 @@ lecho()
return 0
}
-opts=$(getopt t:hVnC:f:l:rovq $@)
+opts=$(getopt t:hVnC:f:l:rR:ovq $@)
if [ "$?" != 0 ]; then
print_usage >&2
exit 255
@@ -174,6 +189,23 @@ xmlout=$(xmllint --noout \
$tempfile 2>&1)
res=$?
+if [ -n "$old_version" ] && [ $old_version -ne 0 ] && [ $res -eq 0 ]; then
+ new_version=$(get_config_version $tempfile)
+ if [ -z "$new_version" ]; then
+ [ -z "$quiet" ] && \
+ echo "Error: Unable to determine new config version!" >&2
+ [ -z "$notempfilerm" ] && rm -f $tempfile
+ exit 253
+ fi
+ lecho "Old version: $old_version New version: $new_version"
+ if [ $new_version -le $old_version ]; then
+ [ -z "$quiet" ] && \
+ echo "Error: Configuration version is older than running config!" >&2
+ [ -z "$notempfilerm" ] && rm -f $tempfile
+ exit 254
+ fi
+fi
+
if [ -z "$quiet" ] || [ "$res" != "0" ]; then
echo "$xmlout" | sed \
-e 's#.*validates$#Configuration validates#g' \
13 years, 9 months
cluster: RHEL4 - fence_ipmilan: Support for power cycle in fence ipmi
by Jan Friesse
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 517421acde2cb0d56368cfa508a95317d34f5ce7
Parent: c11570abe26008d5c5328932f2adf312978c2130
Author: Jan Friesse <jfriesse(a)redhat.com>
AuthorDate: Wed Aug 4 16:19:27 2010 +0200
Committer: Jan Friesse <jfriesse(a)redhat.com>
CommitterDate: Wed Aug 4 16:19:27 2010 +0200
fence_ipmilan: Support for power cycle in fence ipmi
Default behavior (off/get status/on) doesn't work on
some IPMI implementations, because chassis power off will
turn off IPMI management card. Next power on cannot be
done automatically. But it looks, like chassis power cycle
is supported and do what we need -> reset machine.
Patch add support for -M (method) option, which can have
values:
- onoff - default old behaviour
- cycle - use new power cycle
Resolves: rhbz#576036
---
fence/agents/ipmilan/ipmilan.c | 88 ++++++++++++++++++++++++++++++++++++----
fence/man/fence_ipmilan.8 | 10 +++++
2 files changed, 90 insertions(+), 8 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 2beb15a..a4c91d2 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -51,9 +51,12 @@ do { \
#define ST_POWERON 1
#define ST_POWEROFF 2
#define ST_GENERIC_RESET 3
+#define ST_CYCLE 4
#define DEFAULT_TIMEOUT 10
+#define DEFAULT_METHOD "onoff"
+
#define log(lvl, fmt, args...) fprintf(stderr, fmt, ##args)
#include <libgen.h>
@@ -113,7 +116,7 @@ const char *ipmitool_paths[] = {
NULL
};
-
+#define ESTATE (8192*2)
static struct Etoken power_on_complete[] = {
{"Password:", EPERM, 0},
{"Unable to establish LAN", EAGAIN, 0}, /* Retry */
@@ -130,6 +133,17 @@ static struct Etoken power_off_complete[] = {
{NULL, 0, 0}
};
+/** Powercycle operation */
+static struct Etoken power_cycle_complete[] = {
+ {"Password:", EPERM, 0},
+ {"Unable to establish LAN", EAGAIN, 0}, /* Retry */
+ {"IPMI mutex", EFAULT, 0}, /* Death */
+// {"Unsupported cipher suite ID", ECIPHER,0},
+// {"read_rakp2_message: no support for", ECIPHER,0},
+ {"Command not supported in present state", ESTATE, 0},
+ {": Cycle", 0, 0},
+ {NULL, 0, 0}
+};
#define STATE_OFF 4096
#define STATE_ON 8192
@@ -265,6 +279,10 @@ build_cmd(char *command, size_t cmdlen, struct ipmi *ipmi, int op)
snprintf(arg, sizeof(arg),
"%s chassis power status", cmd);
break;
+ case ST_CYCLE:
+ snprintf(arg, sizeof(arg),
+ "%s chassis power cycle", cmd);
+ break;
}
strncpy(command, arg, cmdlen);
@@ -367,6 +385,12 @@ ipmi_op(struct ipmi *ipmi, int op, struct Etoken *toklist)
return ret;
}
+ if (ret == ESTATE) {
+ log(LOG_CRIT, "ipmilan: ipmitool failed to complete "
+ "command in current state\n");
+ return ret;
+ }
+
if (ret == ETIMEDOUT) {
/*!!! Still couldn't get through?! */
log(LOG_WARNING,
@@ -460,6 +484,16 @@ ipmi_on(struct ipmi *ipmi)
return ret;
}
+static int
+ipmi_cycle(struct ipmi *ipmi)
+{
+ int ret;
+
+ ret = ipmi_op(ipmi, ST_CYCLE, power_cycle_complete);
+
+ return ret;
+}
+
/**
Squash all our private data
@@ -847,13 +881,15 @@ get_options_stdin(char *ip, size_t iplen,
char *pwd_script, size_t pwd_script_len,
char *user, size_t userlen,
char *op, size_t oplen,
- int *lanplus, int *verbose,int *timeout)
+ int *lanplus, int *verbose,int *timeout,
+ char *method, int methodlen)
{
char in[256];
int line = 0;
char *name, *val;
op[0] = 0;
+ method[0] = 0;
while (fgets(in, sizeof(in), stdin)) {
++line;
@@ -913,6 +949,8 @@ get_options_stdin(char *ip, size_t iplen,
if ((sscanf(val,"%d",timeout)!=1) || *timeout<1) {
*timeout=DEFAULT_TIMEOUT;
}
+ } else if (!strcasecmp(name,"method")) {
+ strncpy (method, val, methodlen);
} else if (!strcasecmp(name, "option") ||
!strcasecmp(name, "operation") ||
!strcasecmp(name, "action")) {
@@ -953,6 +991,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(" -M <method> Method to fence (onoff or cycle (default %s)\n", DEFAULT_METHOD);
printf(" -V Print version and exit\n");
printf(" -v Verbose mode\n\n");
printf("If no options are specified, the following options will be read\n");
@@ -967,6 +1006,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(" method=<method> Same as -M\n");
printf(" verbose Same as -v\n\n");
exit(1);
}
@@ -982,6 +1022,7 @@ main(int argc, char **argv)
char passwd[64];
char user[64];
char op[64];
+ char method[64];
char pwd_script[PATH_MAX] = { 0, };
int lanplus=0;
int verbose=0;
@@ -994,12 +1035,13 @@ main(int argc, char **argv)
memset(passwd, 0, sizeof(passwd));
memset(user, 0, sizeof(user));
memset(op, 0, sizeof(op));
+ memset(method, 0 ,sizeof(method));
if (argc > 1) {
/*
Parse command line options if any were specified
*/
- while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:")) != EOF) {
+ while ((opt = getopt(argc, argv, "A:a:i:l:p:S:Po:vV?hHt:M:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -1035,6 +1077,10 @@ main(int argc, char **argv)
fail_exit("Timeout option expects positive number parameter");
}
break;
+ case 'M':
+ /* Reboot method */
+ strncpy(method, optarg, sizeof(method));
+ break;
case 'v':
verbose++;
break;
@@ -1058,7 +1104,8 @@ main(int argc, char **argv)
passwd, sizeof(passwd),
pwd_script, sizeof(pwd_script),
user, sizeof(user),
- op, sizeof(op), &lanplus, &verbose,&timeout) != 0)
+ op, sizeof(op), &lanplus, &verbose,&timeout,
+ method, sizeof(method)) != 0)
return 1;
}
@@ -1092,6 +1139,9 @@ main(int argc, char **argv)
if (!strlen(op))
snprintf(op,sizeof(op), "reboot");
+ if (!strlen(method))
+ snprintf(method, sizeof(method), "onoff");
+
if (strcasecmp(op, "off") && strcasecmp(op, "on") &&
strcasecmp(op, "status") && strcasecmp(op, "reboot")) {
fail_exit("operation must be 'on', 'off', 'status', "
@@ -1106,6 +1156,15 @@ main(int argc, char **argv)
" 'none'.");
}
+ if (strcasecmp(method, "onoff") &&
+ strcasecmp(method, "cycle")) {
+ fail_exit("method, if included, muse be 'onoff', 'cycle'.");
+ }
+
+ if (!strcasecmp(method, "cycle") &&
+ (!strcasecmp(op, "on") || !strcasecmp(op, "off"))) {
+ fail_exit("cycle method supports only 'reboot' operation (not 'on' or 'off').");
+ }
/* Ok, set up the IPMI struct */
i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout);
@@ -1118,11 +1177,24 @@ main(int argc, char **argv)
if (!strcasecmp(op, "reboot")) {
printf("Rebooting machine @ IPMI:%s...", ip);
fflush(stdout);
- ret = ipmi_off(i);
- if (ret != 0)
- goto out;
- ret = ipmi_on(i);
+ if (!strcasecmp(method, "cycle")) {
+ ret = ipmi_op(i, ST_STATUS, power_status);
+ if (ret == STATE_OFF) {
+ /* State is off -> use onoff method because cycle is not able to turn on*/
+ snprintf(method, sizeof(method), "onoff");
+ }
+ }
+
+ if (!strcasecmp(method, "cycle")) {
+ ret = ipmi_cycle(i);
+ } else {
+ /* Original onoff method */
+ ret = ipmi_off(i);
+ if (ret != 0)
+ goto out;
+ ret = ipmi_on(i);
+ }
} else if (!strcasecmp(op, "on")) {
printf("Powering on machine @ IPMI:%s...", ip);
fflush(stdout);
diff --git a/fence/man/fence_ipmilan.8 b/fence/man/fence_ipmilan.8
index d6f3daf..5bcdf8c 100644
--- a/fence/man/fence_ipmilan.8
+++ b/fence/man/fence_ipmilan.8
@@ -48,6 +48,11 @@ Full path to an executable to generate the password for login.
\fB-A\fP \fIAuthentication Type\fP
Can be set to none, password, md2, or md5.
.TP
+\fB-M\fP \fImethod\fP
+Method to fence (onoff or cycle). Default is onoff. Use cycle in case your management
+card will power off with default method so there will be no chance to power machine
+on by IPMI.
+.TP
\fB-t\fP \fItimeout\fP
Timeout in seconds for IPMI operation. Default is 10, but in some cases it
must be set to higher value (anything above 30 is not recommended and may
@@ -86,6 +91,11 @@ Authentication type (none, password, md2, md5).
Timeout in seconds for IPMI operation. Default is 10, but in some cases it
must be set to higher value (anything above 30 is not recommended and may
cause strange problems).
+.TP
+\fImethod = < param >\fR
+Method to fence (onoff or cycle). Default is onoff. Use cycle in case your management
+card will power off with default method so there will be no chance to power machine
+on by IPMI.
.SH SEE ALSO
fence(8), fence_node(8)
13 years, 9 months
cluster: STABLE3 - cman: Make qdiskd exit if removed from configuration
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: e118d34dce64325a93c92833b1e074fbabb1a516
Parent: 274e85bc92fa3ffc5405dc2598b190d8470d0b32
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Aug 3 11:28:00 2010 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Aug 3 12:53:52 2010 -0400
cman: Make qdiskd exit if removed from configuration
If qdiskd was previously configured and a configuration
update removes the device & label fields, qdiskd will
now set its votes to 0, unregister from CMAN, and exit.
Correct logging about device registration and
configuration errors is also required in order for
users to understand what is going on when this happens
since the current logging from CMAN is a bit unclear.
Resolves: rhbz#620679
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
cman/qdisk/main.c | 33 +++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index 78dc3f0..4bb2b16 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -1430,13 +1430,36 @@ get_dynamic_config_data(qd_ctx *ctx, int ccsfd)
{
char *val = NULL;
char query[256];
- int old_votes = 0;
+ int old_votes = 0, found = 0;
if (ccsfd < 0)
return -1;
logt_print(LOG_DEBUG, "Loading dynamic configuration\n");
+ /* Check label / device presence. If it disappeared, we need to exit */
+ if (ctx->qc_config) {
+ val = NULL;
+ snprintf(query, sizeof(query), "/cluster/quorumd/@device");
+ found = ccs_get(ccsfd, query, &val);
+ if (found != 0) {
+ val = NULL;
+ snprintf(query, sizeof(query), "/cluster/quorumd/@label");
+ found = ccs_get(ccsfd, query, &val);
+ free(val);
+ }
+
+ if (found != 0) {
+ logt_print(LOG_NOTICE,
+ "Quorum device removed from the configuration."
+ " Shutting down.\n");
+ ctx->qc_votes = 0;
+ register_device(ctx);
+ _running = 0;
+ return -1;
+ }
+ }
+
/* Get status file */
snprintf(query, sizeof(query), "/cluster/quorumd/@status_file");
if (ccs_get(ccsfd, query, &val) == 0) {
@@ -1724,6 +1747,12 @@ get_static_config_data(qd_ctx *ctx, int ccsfd)
ctx->qc_label = val;
}
+ if (!ctx->qc_device && !ctx->qc_label) {
+ logt_print(LOG_ERR, "No device or label specified; cannot "
+ "run QDisk services.\n");
+ return -1;
+ }
+
/* Get min score */
snprintf(query, sizeof(query), "/cluster/quorumd/@min_score");
if (ccs_get(ccsfd, query, &val) == 0) {
@@ -1765,7 +1794,6 @@ get_static_config_data(qd_ctx *ctx, int ccsfd)
free(val);
}
-
return 0;
}
@@ -2049,6 +2077,7 @@ main(int argc, char **argv)
if (quorum_loop(&ctx, ni, MAX_NODES_DISK) == 0) {
/* Only clean up if we're exiting w/o error) */
+ logt_print(LOG_NOTICE, "Unregistering quorum device.\n");
cman_unregister_quorum_device(ctx.qc_cman_admin);
quorum_logout(&ctx);
}
13 years, 9 months
cluster: RHEL56 - fencing: Method to cause one node to delay fencing - ipmilan
by Marek Grác
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: a02d38b1576261ae7ff58316b918587c3ab402f5
Parent: 6402cd9db57ed2d2052132cf59f6e2450be3d964
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Mon Aug 2 15:26:31 2010 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Aug 2 16:01:45 2010 +0200
fencing: Method to cause one node to delay fencing - ipmilan
Resolves: rhbz#613064
---
fence/agents/ipmilan/ipmilan.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/fence/agents/ipmilan/ipmilan.c b/fence/agents/ipmilan/ipmilan.c
index 0bc59d4..163f0c6 100644
--- a/fence/agents/ipmilan/ipmilan.c
+++ b/fence/agents/ipmilan/ipmilan.c
@@ -200,6 +200,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)"},
+ {"delay","-f",0,"string",NULL,"Wait X seconds before fencing is started"},
{"verbose","-v",0,"boolean",NULL,"Verbose mode"}};
/*
@@ -940,7 +941,8 @@ 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 *cipher, char *method, int methodlen)
+ int *cipher, char *method, int methodlen,
+ char *delay, size_t delaylen)
{
char in[256];
int line = 0;
@@ -1020,6 +1022,11 @@ get_options_stdin(char *ip, size_t iplen,
strncpy(op, val, oplen);
else
op[0] = 0;
+ } else if (!strcasecmp(name,"delay")) {
+ if (val)
+ strncpy(delay, val, delaylen);
+ else
+ delay[0] = 0;
}
}
@@ -1053,6 +1060,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(" -f <timeout> Wait X seconds before fencing is started\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");
@@ -1068,6 +1076,7 @@ printf(" login=<login> Same as -u\n");
printf(" option=<op> Same as -o\n");
printf(" operation=<op> Same as -o\n");
printf(" action=<op> Same as -o\n");
+printf(" delay=<seconds> Same as -f\n");
printf(" timeout=<timeout> Same as -t\n");
printf(" cipher=<cipher> Same as -C\n");
printf(" method=<method> Same as -M\n");
@@ -1130,6 +1139,7 @@ main(int argc, char **argv)
char user[64];
char op[64];
char method[64];
+ char delay[64];
char pwd_script[PATH_MAX] = { 0, };
int lanplus=0;
int verbose=0;
@@ -1146,12 +1156,13 @@ main(int argc, char **argv)
memset(user, 0, sizeof(user));
memset(op, 0, sizeof(op));
memset(method, 0, sizeof(method));
+ memset(delay, 0, sizeof(delay));
if (argc > 1) {
/*
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:C:M:f:")) != EOF) {
switch(opt) {
case 'A':
/* Auth type */
@@ -1181,6 +1192,10 @@ main(int argc, char **argv)
/* Operation */
strncpy(op, optarg, sizeof(op));
break;
+ case 'f':
+ /* Delay */
+ strncpy(delay, optarg, sizeof(delay));
+ break;
case 't':
/* Timeout */
if ((sscanf(optarg,"%d",&timeout)!=1) || timeout<1) {
@@ -1221,7 +1236,8 @@ main(int argc, char **argv)
pwd_script, sizeof(pwd_script),
user, sizeof(user),
op, sizeof(op), &lanplus, &verbose,&timeout,
- &cipher, method, sizeof(method)) != 0)
+ &cipher, method, sizeof(method),
+ delay, sizeof(delay)) != 0)
return 1;
}
@@ -1292,6 +1308,13 @@ main(int argc, char **argv)
fail_exit("cycle method supports only 'reboot' operation (not 'on' or 'off').");
}
+ /* Delay fencing if requested */
+ if (delay) {
+ if (!strcasecmp(op, "reboot") || !strcasecmp(op, "off")) {
+ sleep(atoi(delay));
+ }
+ }
+
/* Ok, set up the IPMI struct */
i = ipmi_init(NULL, ip, authtype, user, passwd, lanplus, verbose, timeout, cipher);
if (!i)
13 years, 9 months