mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-30 17:46:38 +00:00
moved get_nic_extra_params and parse_nic_extra_params functions to xcatlib.sh
This commit is contained in:
parent
53b4d81a4f
commit
dfb2bbe249
@ -3,86 +3,6 @@
|
||||
# Internal script used by confignics only.
|
||||
# It configs the Ethernet adpaters on the node
|
||||
|
||||
# The extra parameter NICEXTRAPARAMS are specified in the nics.nicextraparams.
|
||||
# It has the following format:
|
||||
# eth2!MTU=65520 somethingelse=yes,eth3!MTU=1500
|
||||
# This function gets the values for the given nic,
|
||||
# It stores each parameter values in a separate array.
|
||||
|
||||
|
||||
# This function parse the NICEXTRAPARAMS into an array.
|
||||
# Each arry element contains all the extra params for an ip
|
||||
# For example:
|
||||
# NICEXTRAPARAMS="eth0!MTU=1500 sonething=x|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes".
|
||||
# After calling this function with eth0:
|
||||
# array_extra_param[0]="MTU=1500 sonething=x"
|
||||
# array_extra_param[1]="MTU=1460"
|
||||
function get_nic_extra_params() {
|
||||
nic=$1
|
||||
if [ ! "$NICEXTRAPARAMS" ];then
|
||||
return
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$','
|
||||
array_conf_temp=($NICEXTRAPARAMS)
|
||||
IFS=$old_ifs
|
||||
#echo "NICEXTRA=$NICEXTRAPARAMS"
|
||||
|
||||
i=0
|
||||
while [ $i -lt ${#array_conf_temp[@]} ]
|
||||
do
|
||||
token="${array_conf_temp[$i]}"
|
||||
D=
|
||||
if echo "$token" | grep "!"; then
|
||||
D="!"
|
||||
else
|
||||
D=":"
|
||||
fi
|
||||
key=`echo "$token" | cut -d"$D" -f 1`
|
||||
#echo "key=$key nic=$nic"
|
||||
if [ "$key" == "$nic" ]; then
|
||||
str_temp_value=`echo "$token" | cut -d"$D" -f 2`
|
||||
#echo "token=$token, str_temp_value=$str_temp_value"
|
||||
old_ifs=$IFS
|
||||
IFS=$'|'
|
||||
array_nic_params=($str_temp_value)
|
||||
IFS=$old_ifs
|
||||
return
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
}
|
||||
|
||||
# This functions parse the extra parameters for an ip address of a nic
|
||||
# Input is like this:
|
||||
# MTU=65520 something=yes
|
||||
# After the function is called:
|
||||
# array_extra_param_names[0]="MTU"
|
||||
# array_extra_param_values[0]="65520"
|
||||
# array_extra_param_names[1]="something"
|
||||
# array_extra_param_values[0]="yes"
|
||||
#
|
||||
function parse_nic_extra_params() {
|
||||
str_extra=$1
|
||||
|
||||
unset array_extra_param_names
|
||||
unset array_extra_param_values
|
||||
|
||||
old_ifs=$IFS
|
||||
IFS=$' '
|
||||
params_temp=($str_extra)
|
||||
IFS=$old_ifs
|
||||
k=0
|
||||
while [ $k -lt ${#params_temp[@]} ]
|
||||
do
|
||||
token2="${params_temp[$k]}"
|
||||
array_extra_param_names[$k]=`echo "$token2" | cut -d'=' -f 1`
|
||||
array_extra_param_values[$k]=`echo "$token2" | cut -d'=' -f 2`
|
||||
k=$((k+1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
|
||||
str_dir_name=`dirname $0`
|
||||
. $str_dir_name/xcatlib.sh
|
||||
@ -393,9 +313,6 @@ function add_ip_temporary(){
|
||||
}
|
||||
|
||||
|
||||
declare -a array_nic_params
|
||||
declare -a array_extra_param_names
|
||||
declare -a array_extra_param_values
|
||||
|
||||
# This token is used for the value of an attributes that has not been assigned any value.
|
||||
str_default_token="default"
|
||||
@ -579,7 +496,7 @@ elif [ "$1" = "-s" ];then
|
||||
|
||||
#get extra configration parameters for each nic
|
||||
#echo "str_inst_nic=$str_inst_nic, str_inst_ip=$str_inst_ip"
|
||||
get_nic_extra_params $str_inst_nic
|
||||
get_nic_extra_params $str_inst_nic "$NICEXTRAPARAMS"
|
||||
if [ ${#array_nic_params[@]} -gt 0 ]; then
|
||||
str_extra_params=${array_nic_params[0]}
|
||||
parse_nic_extra_params "$str_extra_params"
|
||||
@ -720,7 +637,7 @@ declare -a array_nic_netmask
|
||||
declare -a array_nic_gateway
|
||||
|
||||
#get extra configration parameters for each nic
|
||||
get_nic_extra_params $str_nic_name
|
||||
get_nic_extra_params $str_nic_name "$NICEXTRAPARAMS"
|
||||
j=0
|
||||
while [ $j -lt ${#array_nic_params[@]} ]
|
||||
do
|
||||
|
@ -61,77 +61,6 @@ convert_netmask_to_cidr() {
|
||||
echo $cidrnum
|
||||
}
|
||||
|
||||
# This function parse the NICEXTRAPARAMS into an array.
|
||||
# Each arry element contains all the extra params for an ip
|
||||
# For example:
|
||||
# NICEXTRAPARAMS="eth0!MTU=1500 sonething=x|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes".
|
||||
# After calling this function with eth0:
|
||||
# array_extra_param[0]="MTU=1500 sonething=x"
|
||||
# array_extra_param[1]="MTU=1460"
|
||||
function get_nic_extra_params() {
|
||||
nic=$1
|
||||
if [ ! "$NICEXTRAPARAMS" ];then
|
||||
return
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$','
|
||||
array_conf_temp=($NICEXTRAPARAMS)
|
||||
IFS=$old_ifs
|
||||
#echo "NICEXTRA=$NICEXTRAPARAMS"
|
||||
|
||||
i=0
|
||||
while [ $i -lt ${#array_conf_temp[@]} ]
|
||||
do
|
||||
token="${array_conf_temp[$i]}"
|
||||
D=
|
||||
if echo "$token" | grep "!"; then
|
||||
D="!"
|
||||
else
|
||||
D=":"
|
||||
fi
|
||||
key=`echo "$token" | cut -d"$D" -f 1`
|
||||
#echo "key=$key nic=$nic"
|
||||
if [ "$key" == "$nic" ]; then
|
||||
str_temp_value=`echo "$token" | cut -d"$D" -f 2`
|
||||
#echo "token=$token, str_temp_value=$str_temp_value"
|
||||
old_ifs=$IFS
|
||||
IFS=$'|'
|
||||
array_nic_params=($str_temp_value)
|
||||
IFS=$old_ifs
|
||||
return
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
}
|
||||
|
||||
# This functions parse the extra parameters for an ip address of a nic
|
||||
# Input is like this:
|
||||
# MTU=65520 something=yes
|
||||
# After the function is called:
|
||||
# array_extra_param_names[0]="MTU"
|
||||
# array_extra_param_values[0]="65520"
|
||||
# array_extra_param_names[1]="something"
|
||||
# array_extra_param_values[0]="yes"
|
||||
#
|
||||
function parse_nic_extra_params() {
|
||||
str_extra=$1
|
||||
|
||||
unset array_extra_param_names
|
||||
unset array_extra_param_values
|
||||
|
||||
old_ifs=$IFS
|
||||
IFS=$' '
|
||||
params_temp=($str_extra)
|
||||
IFS=$old_ifs
|
||||
k=0
|
||||
while [ $k -lt ${#params_temp[@]} ]
|
||||
do
|
||||
token2="${params_temp[$k]}"
|
||||
array_extra_param_names[$k]=`echo "$token2" | cut -d'=' -f 1`
|
||||
array_extra_param_values[$k]=`echo "$token2" | cut -d'=' -f 2`
|
||||
k=$((k+1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#if $NIC_IBNICS is not defined, all ib nics' configuration files will be deleted.
|
||||
@ -293,9 +222,6 @@ else
|
||||
fi
|
||||
|
||||
|
||||
declare -a array_nic_params
|
||||
declare -a array_extra_param_names
|
||||
declare -a array_extra_param_values
|
||||
|
||||
goodnics=""
|
||||
for nic in `echo "$NIC_IBNICS" | tr "," "\n"`
|
||||
@ -335,7 +261,7 @@ do
|
||||
unset array_nic_params
|
||||
unset array_extra_param_names
|
||||
unset array_extra_param_values
|
||||
get_nic_extra_params $nic
|
||||
get_nic_extra_params $nic "$NICEXTRAPARAMS"
|
||||
j=0
|
||||
while [ $j -lt ${#array_nic_params[@]} ]
|
||||
do
|
||||
|
@ -610,3 +610,85 @@ function disableservice {
|
||||
|
||||
eval $cmd
|
||||
}
|
||||
|
||||
declare -a array_nic_params
|
||||
declare -a array_extra_param_names
|
||||
declare -a array_extra_param_values
|
||||
|
||||
# This function parse the NICEXTRAPARAMS into an array.
|
||||
# Each arry element contains all the extra params for an ip
|
||||
# For example:
|
||||
#
|
||||
# NICEXTRAPARAMS="eth0!MTU=1500 sonething=x|MTU=1460,ib0!MTU=65520 CONNECTED_MODE=yes"
|
||||
# get_nic_extra_params $eth0 $NICEXTRAPARAMS
|
||||
# After the function is called:
|
||||
# array_nic_param[0]="MTU=1500 sonething=x"
|
||||
# array_nic_param[1]="MTU=1460"
|
||||
function get_nic_extra_params() {
|
||||
nic=$1
|
||||
nic_extra=$2
|
||||
|
||||
unset array_nic_params
|
||||
|
||||
if [ ! "$nic_extra" ];then
|
||||
return
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
IFS=$','
|
||||
array_conf_temp=($nic_extra)
|
||||
IFS=$old_ifs
|
||||
#echo "nic_extra=$nic_extra"
|
||||
|
||||
i=0
|
||||
while [ $i -lt ${#array_conf_temp[@]} ]
|
||||
do
|
||||
token="${array_conf_temp[$i]}"
|
||||
D=
|
||||
if echo "$token" | grep "!"; then
|
||||
D="!"
|
||||
else
|
||||
D=":"
|
||||
fi
|
||||
key=`echo "$token" | cut -d"$D" -f 1`
|
||||
#echo "key=$key nic=$nic"
|
||||
if [ "$key" == "$nic" ]; then
|
||||
str_temp_value=`echo "$token" | cut -d"$D" -f 2`
|
||||
#echo "token=$token, str_temp_value=$str_temp_value"
|
||||
old_ifs=$IFS
|
||||
IFS=$'|'
|
||||
array_nic_params=($str_temp_value)
|
||||
IFS=$old_ifs
|
||||
return
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
}
|
||||
|
||||
# This functions parse the extra parameters for an ip address of a nic
|
||||
# Input is like this:
|
||||
# MTU=65520 something=yes
|
||||
# After the function is called:
|
||||
# array_extra_param_names[0]="MTU"
|
||||
# array_extra_param_values[0]="65520"
|
||||
# array_extra_param_names[1]="something"
|
||||
# array_extra_param_values[0]="yes"
|
||||
#
|
||||
function parse_nic_extra_params() {
|
||||
str_extra=$1
|
||||
|
||||
unset array_extra_param_names
|
||||
unset array_extra_param_values
|
||||
|
||||
old_ifs=$IFS
|
||||
IFS=$' '
|
||||
params_temp=($str_extra)
|
||||
IFS=$old_ifs
|
||||
k=0
|
||||
while [ $k -lt ${#params_temp[@]} ]
|
||||
do
|
||||
token2="${params_temp[$k]}"
|
||||
array_extra_param_names[$k]=`echo "$token2" | cut -d'=' -f 1`
|
||||
array_extra_param_values[$k]=`echo "$token2" | cut -d'=' -f 2`
|
||||
k=$((k+1))
|
||||
done
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user