From 3d7a5105b33d303816e118a3bd171e3cac2a15bd Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Thu, 9 Feb 2012 11:17:00 +0000 Subject: [PATCH] Changed the description of this script, added traces to syslog for AIX and Linux, and make it more readable git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11522 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT/postscripts/confighfi | 154 +++++++++++++++++++++---------------- 1 file changed, 87 insertions(+), 67 deletions(-) diff --git a/xCAT/postscripts/confighfi b/xCAT/postscripts/confighfi index 7ebe34d7e..180f7cecb 100644 --- a/xCAT/postscripts/confighfi +++ b/xCAT/postscripts/confighfi @@ -4,103 +4,123 @@ #------------------------------------------------------------------------------- # Sample xCAT post script for configuring hfi settings and some conventions. # This scripts works for both diskfull installs, diskless boots on AIX or Linux. +# Input: +# IP address: Each hfi interface should be assigned its hostname and IP address. +# hostname should be resolable from either /etc/hosts or name +# resolution, with format: -hfx +# netmask: Netmask is hardcoded in this script. You have to manually modify it +# if it doesn't meet your requirement. #------------------------------------------------------------------------------- PLTFRM=`uname` +NETMASK=255.0.0.0 name=`echo $NODE | awk -F-hf '{print $1}'` if [ -z $name ] then -name=$NODE + name=$NODE fi if [[ $PLTFRM != AIX ]] && [[ $PLTFRM != aix ]] then -# A difference between service node and compute node is that service node is booted from -# ethernet, all the HFI interfaces should be configured. Compute node is booted from hf0 -# so hf0 on compute node should not be re-configured on compute node. -if [[ $NTYPE = service ]] -then + # A difference between service node and compute node is that service node is booted from + # ethernet, all the HFI interfaces should be configured. Compute node is booted from hf0 + # so hf0 on compute node should not be re-configured on compute node. + if [[ $NTYPE = service ]] + then -CLIENT_IP=`ping -c 3 $name-hf0 -I hf0 2>/dev/null | grep "data" | sed 's/.* (\([0-9.]*\)).*/\1/' | uniq 2>&1` + CLIENT_IP=`ping -c 3 $name-hf0 -I hf0 2>/dev/null | grep "data" | sed 's/.* (\([0-9.]*\)).*/\1/' | uniq 2>&1` -if [ -n "$CLIENT_IP" ] -then -echo "DEVICE=hf0 + if [ -n "$CLIENT_IP" ] + then + echo "DEVICE=hf0 NM_CONTROLLED=yes IPADDR=$CLIENT_IP -NETMASK=255.0.0.0 +NETMASK=$NETMASK ONBOOT=yes " >/etc/sysconfig/network-scripts/ifcfg-hf0 -ifdown hf0 -ifup hf0 -fi + ifdown hf0 + ifup hf0 + else + logger -t xcat "confighfi: cannot resolve hostname $name-hf0" + fi + elif [[ -z "$NTYPE" ]] + then + logger -t xcat "confighfi: cannot read node type definition" + fi -fi + # Configure hf0-hf interfaces one by one. + for i in 1 2 3 4 5 6 7 + do -# Configure hf0-hf interfaces one by one. -for i in 1 2 3 4 5 6 7 -do + CLIENT_IP=`ping -c 3 $name-hf$i -I hf$i 2>/dev/null | grep "data" | sed 's/.* (\([0-9.]*\)).*/\1/' | uniq 2>&1` -CLIENT_IP=`ping -c 3 $name-hf$i -I hf$i 2>/dev/null | grep "data" | sed 's/.* (\([0-9.]*\)).*/\1/' | uniq 2>&1` - -if [ -n "$CLIENT_IP" ] -then -echo "DEVICE=hf$i + if [ -n "$CLIENT_IP" ] + then + echo "DEVICE=hf$i NM_CONTROLLED=yes IPADDR=$CLIENT_IP -NETMASK=255.0.0.0 +NETMASK=$NETMASK ONBOOT=yes " >/etc/sysconfig/network-scripts/ifcfg-hf$i -ifdown hf$i -ifup hf$i -fi - -done + ifdown hf$i + ifup hf$i + else + logger -t xcat "confighfi: cannot resolve hostname $name-hf$i" + fi + done else -NETMASK=255.0.0.0 + # Configurartion for AIX + if [[ $NTYPE = service ]] + then -if [[ $NTYPE = service ]] -then + CLIENT_IP=`ping -q -n -c 1 -w 1 $name-hf0 | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` -CLIENT_IP=`ping -q -n -c 1 -w 1 $name-hf0 | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` + if [ -n "$CLIENT_IP" ] + then + mkhfi -i hf0 -a $CLIENT_IP -m $NETMASK + else + logger -t xcat "confighfi: cannot resolve hostname $name-hf0" + fi + elif [[ -z "$NTYPE" ]] + then + logger -t xcat "confighfi: cannot read node type definition" + fi -if [ -n $CLIENT_IP ] -then -mkhfi -i hf0 -a $CLIENT_IP -m $NETMASK -fi - -fi - -for i in 1 2 3 -do -CLIENT_IP=`ping -q -n -c 1 -w 1 $name-hf$i | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` - -if [ -n "$CLIENT_IP" ] -then -mkhfi -i hf$i -a $CLIENT_IP -m $NETMASK -fi - -done - -# Configure ml0 for AIX. -CLIENT_IP=`ping -q -n -c 1 -w 1 $name-ml0 | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` - -if [ -n "$CLIENT_IP" ] -then - #Check whether the mlt0 is available - `lsdev -C | grep mlt0 | grep Available 2>&1 >/dev/null` - - chdev -l ml0 -a state=detach - - # Reconfig ml0 since HFx are configured after ml0 is available - rmdev -l mlt0 - mkdev -l mlt0 - - chdev -l ml0 -a netaddr=$CLIENT_IP -a netmask=$NETMASK -a state=up -fi + for i in 1 2 3 + do + CLIENT_IP=`ping -q -n -c 1 -w 1 $name-hf$i | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` + + if [ -n "$CLIENT_IP" ] + then + mkhfi -i hf$i -a $CLIENT_IP -m $NETMASK + else + logger -t xcat "confighfi: cannot resolve hostname $name-hf$i" + fi + + done + + # Configure ml0 for AIX. + CLIENT_IP=`ping -q -n -c 1 -w 1 $name-ml0 | grep PING |awk '{print $3}' | sed 's/(\(.*\)):/\1/' ` + + if [ -n "$CLIENT_IP" ] + then + #Check whether the mlt0 is available + `lsdev -C | grep mlt0 | grep Available 2>&1 >/dev/null` + + chdev -l ml0 -a state=detach + + # Reconfig ml0 since HFx are configured after ml0 is available + rmdev -l mlt0 + mkdev -l mlt0 + + sleep 2 + chdev -l ml0 -a netaddr=$CLIENT_IP -a netmask=$NETMASK -a state=up + else + logger -t xcat "confighfi: cannot resolve hostname $name-ml0" + fi fi