Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core

This commit is contained in:
John Simpson 2013-11-08 09:54:30 -05:00
commit 3698609370
2 changed files with 123 additions and 60 deletions

View File

@ -42,8 +42,13 @@ function splitconfig(){
}
function findnetwork(){
str_ip=$1
str_network=''
local str_ip=$1
local str_network=''
local flag_v6=0
echo "$str_ip" | grep ':' > /dev/null
if [ $? -eq 0 ];then
flag_v6=1
fi
local num_i=1
while [ $num_i -le $NETWORKS_LINES ];do
eval str_temp=\$NETWORKS_LINE$num_i
@ -51,13 +56,27 @@ function findnetwork(){
str_mask=`echo $str_temp | awk -F'mask=' '{print $2}' | awk -F'|' '{print $1}' | sed 's:^/::'`
echo $str_net | grep ':' > /dev/null
if [ $? -ne 0 ];then
str_temp_net1=$(v4calcnet $str_ip $str_mask)
str_temp_net2=$(v4calcnet $str_net $str_mask)
if [ "$str_temp_net1" = "$str_temp_net2" ];then
str_network=`echo $str_temp | awk -F'netname=' '{print $2}' | awk -F'|' '{print $1}'`
echo "$str_network"
return
if [ $flag_v6 -eq 0 ];then
str_temp_net1=$(v4calcnet $str_ip $str_mask)
str_temp_net2=$(v4calcnet $str_net $str_mask)
else
num_i=$((num_i+1))
continue
fi
else
if [ $flag_v6 -eq 1 ];then
str_temp_net1=$(v6calcnet $str_ip $str_mask)
str_temp_net2=$(v6calcnet $str_net $str_mask)
else
num_i=$((num_i+1))
continue
fi
fi
if [ "$str_temp_net1" = "$str_temp_net2" ];then
str_network=`echo $str_temp | awk -F'netname=' '{print $2}' | awk -F'|' '{print $1}'`
echo "$str_network"
return
fi
num_i=$((num_i+1))
done
@ -69,7 +88,6 @@ function checknetwork(){
old_ifs=$IFS
IFS=$'|'
array_ip=($1)
array_networkname=($2)
IFS=$old_ifs
str_ret=''
@ -78,25 +96,14 @@ function checknetwork(){
while [ $num_index -lt $num_length ]
do
str_ip=${array_ip[$num_index]}
str_networkname=${array_networkname[$num_index]}
echo "$str_ip" | grep ':' > /dev/null
if [ $? -ne 0 ];then
if [ -z "$str_networkname" ];then
str_networkname=$(findnetwork $str_ip)
echo "$str_networkname" | grep -i 'error' > /dev/null
if [ $? -eq 0 ];then
echo "$str_networkname"
return
fi
fi
str_ret="${str_ret}${str_networkname},"
else
if [ -z "$str_networkname" ];then
echo "Error: ipv6 address should define networks name, the ip is $str_ip ."
return
fi
str_ret="${str_ret}${str_networkname},"
str_networkname=$(findnetwork $str_ip)
echo "$str_networkname" | grep -i 'error' > /dev/null
if [ $? -eq 0 ];then
echo "$str_networkname"
return
fi
str_ret="${str_ret}${str_networkname},"
num_index=$((num_index+1))
done
@ -182,37 +189,12 @@ fi
bool_exit_flag=0
#check the required attributes
if [ -z "$NICIPS" ];then
if [ -n "$NICTYPES" ];then
logger -t xcat -p local4.info "confignics: nicips attribute is not defined. so the nictypes attribute can not be defined."
echo "confignics on $NODE: nicips attribute is not defined. so the nictypes attribute can not be defined."
bool_exit_flag=1
fi
if [ -n "$NICNETWORKS" ];then
logger -t xcat -p local4.info "confignics: nicips attribute is not defined. so the nicnetworks attribute can not be defined."
echo "confignics on $NODE: nicips attribute is not defined. so the nicnetworks attribute can not be defined."
bool_exit_flag=1
fi
else
if [ -z "$NICTYPES" ];then
logger -t xcat -p local4.info "confignics: nictypes attribute is not defined."
echo "confignics on $NODE: nictypes attribute is not defined."
bool_exit_flag=1
fi
if [ -z "$NICNETWORKS" ];then
logger -t xcat -p local4.info "confignics: nicnetworks attribute is not defined."
echo "confignics on $NODE: nicnetworks attribute is not defined."
bool_exit_flag=1
fi
fi
if [ $bool_exit_flag -eq 1 ];then
logger -t xcat -p local4.info "confignics: nicips attribute is not defined. "
echo "confignics on $NODE: nicips attribute is not defined. "
exit 0
fi
splitconfig $NICIPS
splitconfig $NICNETWORKS
splitconfig $NICCUSTOMSCRIPTS
if [ $boot_myscript -eq 1 ];then
@ -289,10 +271,10 @@ do
array_temp=($str_value)
IFS=$old_ifs
if [ -n "${array_temp[2]}" ];then
logger -t xcat -p local4.info "confignics: processing custom scripts: ${array_temp[2]} for interface $key"
echo "confignics on $NODE: processing custom scripts: ${array_temp[2]} for interface $key"
${array_temp[2]}
if [ -n "${array_temp[1]}" ];then
logger -t xcat -p local4.info "confignics: processing custom scripts: ${array_temp[1]} for interface $key"
echo "confignics on $NODE: processing custom scripts: ${array_temp[1]} for interface $key"
${array_temp[1]}
else
if [ `echo $key | grep -E '(eth|en)[0-9]+'` ];then
str_nic_type="ethernet"
@ -304,7 +286,7 @@ do
continue
fi
str_network=$(checknetwork ${array_temp[0]} ${array_temp[1]})
str_network=$(checknetwork ${array_temp[0]})
echo "$str_network" | grep -i 'error' > /dev/null
if [ $? -eq 0 ];then
logger -t xcat -p local4.info "$str_network"
@ -315,7 +297,7 @@ do
if [ "$str_nic_type" = "ethernet" ];then
logger -t xcat -p local4.info "confignics: call 'configeth $key ${array_temp[0]} $str_network'"
echo "confignics on $NODE: call 'configeth $key ${array_temp[0]} $str_network'"
#configeth $key ${array_temp[0]} $str_network
configeth $key ${array_temp[0]} $str_network
elif [ "$str_nic_type" = "infiniband" ];then
if [ $str_ib_nics ];then
str_ib_nics=$str_ib_nics","$key

View File

@ -185,3 +185,84 @@ function v4calcnet(){
str_net=`echo $str_net | sed 's/.$//'`
echo "$str_net"
}
function v6expand(){
local str_v6address=$1
str_v6address=${str_v6address%%/*}
echo "$str_v6address" | grep '::' > /dev/null
if [ $? -ne 0 ];then
echo "$str_v6address"
return
fi
local num_colon=`echo "$str_v6address" | grep -o ':' | wc -l`
local num_omit=$((7-num_colon))
local str_temp=0
local num_index=1
while [ $num_index -le $num_omit ];do
str_temp=$str_temp":0"
num_index=$((num_index+1))
done
str_v6address=`echo $str_v6address | sed "s/::/:$str_temp:/" | sed 's/^:/0:/' | sed 's/:$/:0/'`
echo "$str_v6address"
}
function v6prefix2mask(){
local num_v6prefix=$1
num_v6prefix=`echo $num_v6prefix | sed 's:/::g'`
if [ $num_v6prefix -gt 128 ];then
$num_v6prefix=128
fi
if [ $num_v6prefix -le 0 ];then
$num_v6prefix=1
fi
local num_i=1
local str_mask=''
while [ $num_i -le 8 ];do
if [ $num_v6prefix -ge 16 ];then
str_mask=$str_mask"ffff:"
num_v6prefix=$((num_v6prefix-16))
elif [ $num_v6prefix -eq 0 ];then
str_mask=$str_mask"0:"
else
local str_temp=$(((65535>>$num_v6prefix)^65535))
str_temp=`echo "$str_temp"|awk '{printf("%x\n",$0)}'`
str_mask=$str_mask"$str_temp:"
num_v6prefix=0
fi
num_i=$((num_i+1))
done
str_mask=`echo $str_mask | sed 's/.$//'`
echo "$str_mask"
}
function v6calcnet(){
local str_v6ip=$(v6expand $1)
local str_v6mask=$2
local str_v6net=''
echo "$str_v6maks " | grep ':' > /dev/null
if [ $? -ne 0 ];then
str_v6mask=$(v6prefix2mask $str_v6mask)
fi
local str_old_ifs=$IFS
IFS=$':'
local array_ip=($str_v6ip)
local array_mask=($str_v6mask)
IFS=$str_old_ifs
for num_i in {0..7}
do
str_temp=$(( 0x${array_ip[$num_i]} & 0x${array_mask[$num_i]} ))
str_temp=`echo $str_temp | awk '{printf("%x\n",$0)}'`
str_v6net=$str_v6net$str_temp":"
done
str_v6net=`echo $str_v6net | sed 's/.$//'`
echo "$str_v6net"
}