diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index fd53c5dc9..745b4524c 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -8,7 +8,7 @@ if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then . $str_dir_name/xcatlib.sh . $str_dir_name/nicutils.sh fi - +error_code=0 function configipv4(){ str_if_name=$1 str_v4ip=$2 @@ -320,6 +320,10 @@ function add_ip_temporary(){ str_bcase=$(v4calcbcase $str_ip $str_mask) #the label is ready, add the ip address directly ip addr add $str_ip/${str_mask} broadcast $str_bcase dev $str_nic_name scope global label $str_label + if [ $? -ne 0 ]; then + log_error "add the ip address $str_ip/${str_mask} failed." + error_code=1 + fi fi fi } @@ -349,7 +353,7 @@ if [ "$str_os_type" = "linux" ];then fi else echo "configeth dose not support AIX in this build" - exit 0 + exit 1 fi @@ -409,7 +413,7 @@ if [ "$1" = "-r" ];then #delete the configuration files delete_nic_config_files $str_nic_name fi - exit 0 + exit $error_code elif [ "$1" = "-s" ];then if [ $# -lt 2 ];then logger -t xcat -p local4.err "configeth: config install nic, but the nic name is missed" @@ -472,7 +476,7 @@ elif [ "$1" = "-s" ];then fi fi else - str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep lease` + str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep lease >& /dev/null` if [ -e "$str_lease_file" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` @@ -504,7 +508,7 @@ elif [ "$1" = "-s" ];then if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then logger -t xcat -p local4.err "configeth: config install nic, can not find the information from lease file, return." log_info "configeth on $NODE: config install nic, can not find information from dhcp lease file, return." - exit 0 + exit 1 fi str_inst_net=$(v4calcnet $str_inst_ip $str_inst_mask) @@ -636,8 +640,12 @@ elif [ "$1" = "-s" ];then fi ifup $str_inst_nic + if [ $? -ne 0 ]; then + log_error "ifup $str_inst_nic failed." + error_code=1 + fi - exit 0 + exit $error_code fi #main prcess @@ -717,6 +725,7 @@ while [ $num_index -lt ${#array_nic_ips[*]} ];do if [ ! $str_netname ];then logger -t xcat -p local4.err "configeth: Network name is not defined on $str_nic_name for $str_ip." log_error "configeth on $NODE: Network name is not defined on $str_nic_name for $str_ip." + error_code=1 num_index=$((num_index+1)) continue fi @@ -726,6 +735,7 @@ while [ $num_index -lt ${#array_nic_ips[*]} ];do if [ ! $str_line ];then logger -t xcat -p local4.err "configeth: Network object $str_netname is not defined." log_error "configeth on $NODE: Network object $str_netname is not defined." + error_code=1 num_index=$((num_index+1)) continue fi @@ -739,6 +749,7 @@ while [ $num_index -lt ${#array_nic_ips[*]} ];do if [ ! $str_subnet -o ! $str_netmask ];then logger -t xcat -p local4.err "configeth: subnet or netmask is not defined in network object $str_netname." log_error "configeth on $NODE: subnet or netmask is not defined in network object $str_netname." + error_code=1 num_index=$((num_index+1)) continue fi @@ -770,6 +781,7 @@ while [ $num_index -lt ${#array_nic_ips[*]} ];do else logger -t xcat -p local4.err "configeth: the ipaddress( $str_ip ) for $str_nic_name is invalid." log_error "configeth on $NODE: the ipaddress( $str_ip ) for $str_nic_name is invalid." + error_code=1 fi num_index=$((num_index+1)) done @@ -790,6 +802,7 @@ if [ "$str_os_type" = "aix" ];then chdev -l $str_nic_name -a netaddr='' -a netmask='' logger -t xcat -p local4.err "configeth: delete undefined ip address $str_old_ip" log_error "configeth on $NODE: delete undefined ip address $str_old_ip" + error_code=1 fi fi @@ -864,6 +877,10 @@ if [ "$str_os_type" = "aix" ];then #change the nic status to up chdev -l $str_nic_name -a state=up + if [ $? -ne 0 ]; then + log_error "chdev -l $str_nic_name -a state=up failed." + error_code=1 + fi else str_history='' bool_restart_flag=0 @@ -895,6 +912,10 @@ else log_info "configeth on $NODE: delete $str_old_ip for $str_nic_name temporary." str_old_ip=`echo $str_old_ip | tr '_' '/'` ip addr del $str_old_ip dev $str_nic_name + if [ $? -ne 0 ]; then + log_error "ip addr del $str_old_ip dev $str_nic_name failed." + error_code=1 + fi fi done else @@ -1028,11 +1049,19 @@ else if [ $bool_restart_flag -eq 1 ];then if [ "$str_os_type" = "debian" ];then ifup -a -i /etc/network/interfaces.d/$str_nic_name + if [ $? -ne 0 ]; then + log_error "ifup -a -i /etc/network/interfaces.d/$str_nic_name failed." + error_code=1 + fi else echo "bring up ip" ifup $str_nic_name + if [ $? -ne 0 ]; then + log_error "ifup $str_nic_name failed." + error_code=1 + fi fi fi fi -exit 0 +exit $error_code diff --git a/xCAT/postscripts/confignetwork b/xCAT/postscripts/confignetwork index bb0a90cec..6fac25ac8 100755 --- a/xCAT/postscripts/confignetwork +++ b/xCAT/postscripts/confignetwork @@ -320,7 +320,7 @@ function sort_nics_device_order { echo $alonenic else errorcode=1 - echo "Error: nicips,nictype and nicnetwork should be configured in nics table for $alonenic." + echo "Error: nicips,nictypes and nicnetworks should be configured in nics table for $alonenic." ((num1+=1)) continue fi @@ -521,7 +521,7 @@ function configure_nicdevice { elif [ x"$nic_dev_type" = "xinfiniband" ]; then log_error "confignetwork does not support configure IB. " else - log_error "Error : please check nictypes for $nic_pair." + log_error "Error : please check nic data in nics table." errorcode=1 fi @@ -603,7 +603,7 @@ parser_nic_attribute "$NICCUSTOMSCRIPTS" "niccustomscripts" #bond0 eth2@eth3 new_nicdevice=`find_nic_and_device_list $str_all_nics|sort -g -k1 -g -k2|uniq` if [ -z "$new_nicdevice" ]; then - log_info "There is no nic device to configure." + log_info "There is no other nic device to configure." exit $errorcode fi diff --git a/xCAT/postscripts/confignics b/xCAT/postscripts/confignics index 41f15db31..96a452ab4 100755 --- a/xCAT/postscripts/confignics +++ b/xCAT/postscripts/confignics @@ -18,7 +18,7 @@ if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then str_dir_name=`dirname $0` . $str_dir_name/xcatlib.sh fi - +error_code=0 #the nics' information contain: #1. ip address #2. nic network @@ -102,6 +102,7 @@ function findnetwork(){ done echo "Error: Can not find the corresponding network defination for ip address: $str_ip ." + error_code=1 } function checknetwork(){ @@ -138,7 +139,7 @@ str_os_type=`uname | tr 'A-Z' 'a-z'` if [ "$str_os_type" = "aix" ];then logger -t xcat -p local4.err "confignics: aix does not support in this build" echo "confignics: aix does not support in this build" - exit 0 + exit 1 fi bool_remove=0 num_iba_ports= @@ -167,7 +168,7 @@ then then logger -t xcat -p local4.info "confignics --script could Not be used with other options" echo "confignics --script could Not be used with other options" - exit -1 + exit 1 fi boot_myscript=1 myscript=$2; @@ -215,7 +216,7 @@ if [ -z "$NICIPS" ];then else logger -t xcat -p local4.info "confignics: nicips attribute is not defined. " echo "confignics on $NODE: nicips attribute is not defined. " - exit 0 + exit 1 fi fi splitconfig "$NICIPS" @@ -226,7 +227,7 @@ splitconfig "$NICCUSTOMSCRIPTS" if [ $boot_myscript -eq 1 ];then . $str_dir_name/$myscript if [ $? -ne 0 ];then - exit -1 + exit 1 fi exit 0 fi @@ -277,6 +278,9 @@ if [ $bool_remove -eq 1 ];then logger -t xcat -p local4.info "confignics: remove nic $str_temp_nic" echo "confignics on $NODE: remove nic $str_temp_nic" configeth -r $str_temp_nic + if [ $? -ne 0 ]; then + error_code=1 + fi done fi old_ifs=$IFS @@ -310,6 +314,9 @@ do logger -t xcat -p local4.info "confignics: call 'configeth $str_inst_nic'" echo "confignics on $NODE: call 'configeth -s $str_inst_nic" configeth -s $str_inst_nic + if [ $? -ne 0 ]; then + error_code=1 + fi continue else continue @@ -322,6 +329,7 @@ do else logger -t xcat -p local4.info "confignics: unknown nic type for $key: $str_value ." echo "confignics on $NODE: unknown nic type for $key: $str_value ." + error_code=1 continue fi @@ -337,6 +345,9 @@ do 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 + if [ $? -ne 0 ]; then + error_code=1 + fi elif [ "$str_nic_type" = "infiniband" ];then if [ $str_ib_nics ];then str_ib_nics=$str_ib_nics","$key @@ -346,6 +357,7 @@ do else logger -t xcat -p local4.info "confignics: unknown type $str_nic_type for NIC: $key" echo "confignics on $NODE: unknown type $str_nic_type for NIC: $key" + error_code=1 fi fi done @@ -358,5 +370,9 @@ else logger -t xcat -p local4.info "confignics: executed script: 'configib -u' to remove all ib nics and configuration files" echo "confignics on $NODE: executed script: 'configib -r' to remove all ib nics and configuration files" configib + if [ $? -ne 0 ]; then + error_code=1 + fi fi fi +exit $error_code