cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/rgmanager/src/resources/utils member_u ...
Date: 14 Feb 2007 19:10:34 -0000	[thread overview]
Message-ID: <20070214191034.18272.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL5
Changes by:	lhh at sourceware.org	2007-02-14 19:10:34

Added files:
	rgmanager/src/resources/utils: member_util.sh 

Log message:
	Add member_util.sh functions

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/utils/member_util.sh.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=NONE&r2=1.1.2.1

/cvs/cluster/cluster/rgmanager/src/resources/utils/member_util.sh,v  -->  standard output
revision 1.1.2.1
--- cluster/rgmanager/src/resources/utils/member_util.sh
+++ -	2007-02-14 19:10:34.676142000 +0000
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+#
+#  Copyright Red Hat, Inc. 2007
+#
+#  This program is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU General Public License as published by the
+#  Free Software Foundation; either version 2, or (at your option) any
+#  later version.
+#
+#  This program is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; see the file COPYING.  If not, write to the
+#  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge,
+#  MA 02139, USA.
+#
+#  Description:
+#	Utility functions to get membership information.
+#
+#  Author(s):
+#	Lon Hohberger (lhh at redhat.com)
+#
+
+#
+# Use clustat to figure out if the specified node is a member
+# of the cluster.  Returns 2 if not found, 1 if not a member, and
+# 0 if the node is happily running.
+# Tested on RHEL4 and RHEL5; requires RHCS 5.1 or 4.5 to operate
+# properly in all cases.
+#
+is_node_member_clustat()
+{
+	declare line=$(clustat -xm $1 | grep "name=\"$1\"")
+	declare tmp
+
+	# Done if there's no node in the list with that name: not a 
+	# cluster member, and not in the configuration.
+	[ -n "$line" ] || return 2
+
+	# Clear out xml tag seps.
+	line=${line/*</}
+	line=${line/\/>/}
+
+	# Make vars out of XML attributes.
+	for tmp in $line; do
+		eval declare __$tmp
+	done
+
+	# Flip the value.  clustat reports 1 for member, 0 for not;
+	# Exactly the opposite of what a shell script expects.
+	((__state = !__state))
+	return $__state
+}
+
+
+#
+# Print the local node name to stdout
+# Returns 0 if could be found, 1 if not
+# Tested on RHEL4 (magma) and RHEL5 (cman)
+#
+local_node_name()
+{
+	declare node state line
+
+	if which magma_tool &> /dev/null; then
+		# Use magma_tool, if available.
+		line=$(magma_tool localname | grep "^Local")
+
+		if [ -n "$line" ]; then
+			echo ${line/* = /}
+			return 0
+		fi
+	fi
+
+	if ! which cman_tool &> /dev/null; then
+		# No cman tool? :(
+		return 2
+	fi
+
+	# Use cman_tool
+
+	line=$(cman_tool status | grep -i "Node name: $1")
+	[ -n "$line" ] || return 1
+	echo ${line/*name: /}
+	return 0
+}
+



             reply	other threads:[~2007-02-14 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-14 19:10 lhh [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-02-14 19:13 [Cluster-devel] cluster/rgmanager/src/resources/utils member_u lhh
2007-02-14 19:12 lhh
2007-02-14 19:09 lhh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070214191034.18272.qmail@sourceware.org \
    --to=lhh@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).