Sophie

Sophie

distrib > * > 2010.0 > * > by-pkgid > 6c7dbab78d6480e53143ded5c0c7caeb > files > 3

ka-deploy-server-host-0.92-23mdv2010.0.x86_64.rpm


# list of sh functions for the ka scripts

# print the IP for the hostname given as parameter 
get_ip()
{
	# return the ip address for a node of the cluster

	# general method :

	ip=`host $1 | grep "has address" | sed 's/.* has address //' | head -n 1`

	# faster method for our cluster
#	ip=`echo $1 | sed 's/icluster/129\.88\.96\./'`

	if [ -z "$ip" ]; then
        	echo '** ERROR **' get_ip : could not find host $1 1>&2
		exit 1
	fi
	echo "$ip"
}

# print the hostname for the node number given in $1
get_hostname_for_num()
{
		printf "%s"$num_format"\n" $node_basename $1
}

# print the hostname for the node numbers given in stdin
get_hostname_for_num_list()
{
		while read number; do
				printf "%s"$num_format"\n" $node_basename $number
		done
}

# print the IP for the node names given in stdin
get_ip_for_name_list()
{
	# general method : use get_ip
	while read hostname; do
			get_ip $hostname || exit 1
	done

	# faster method for our cluster -- MUCH faster even :)
	#sed 's/icluster/129\.88\.96\./'
}

# print the IP for the range of nodes between $1 and $2
get_ip_list_range()
{
		start=$1
		end=$2
		seq $start $end | get_hostname_for_num_list | get_ip_for_name_list 
}