Whamcloud - gitweb
LU-1049 script: lc_net doesn't parse output correctly
[fs/lustre-release.git] / lustre / scripts / lc_net.in
index fef2637..51f3c43 100644 (file)
@@ -20,9 +20,9 @@ Usage:        `basename $0` [options] <csv file>
        -x hostname,hostname,...
                        exclude the specified list of nodes (separated by commas)
        -v              verbose mode
-       csv file        a spreadsheet that contains configuration parameters 
+       csv file        a spreadsheet that contains configuration parameters
                        (separated by commas) for each target in a Lustre cl-
-                       uster, the first field of each line is the host name 
+                       uster, the first field of each line is the host name
                        of the cluster node
 
 EOF
@@ -48,11 +48,11 @@ while getopts "aw:x:v" OPTION; do
                USE_ALLNODES=false
                EXCLUDED_NODELIST=$OPTARG
                ;;
-       v) 
+       v)
                VERBOSE_OUTPUT=true
                ;;
-        ?) 
-               usage 
+        ?)
+               usage
        esac
 done
 
@@ -95,7 +95,7 @@ get_hostnames() {
 }
 
 # ping_host host_name
-# Check whether host $host_name is reachable. 
+# Check whether host $host_name is reachable.
 # If it is, then return the IP address of this host.
 ping_host() {
        local host_name=$1
@@ -169,9 +169,8 @@ remote_check() {
        fi
 
        # Get the IP address of ${HOST_NAMES[i]} from its own ping
-       ip_pattern="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
-       ip_addr=`echo "${ret_str}" | egrep -o "${ip_pattern}"`
-       ip_addr=`echo "${ip_addr}" | sed -e 's/^(//' -e 's/)$//'`
+       ip_pattern="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
+       ip_addr=`echo "${ret_str}" | egrep -m 1 -o "${ip_pattern}"`
 
        # Compare IP addresses
        # Check whether ${HOST_NAMES[i]} agrees with the local host
@@ -183,7 +182,7 @@ remote_check() {
                "\"${ip_addr}\". They are not the same!"
                return 1
        fi
-       
+
        return 0
 }
 
@@ -195,10 +194,10 @@ network_verify() {
        # Initialize the HOST_IPADDRS array
        unset HOST_IPADDRS
 
-       # Get all the host names to be operated on 
+       # Get all the host names to be operated on
        ! get_hostnames && return 1
 
-       # Check the network connectivity between local host 
+       # Check the network connectivity between local host
        # and other cluster nodes
        for ((i = 0; i < ${#HOST_NAMES[@]}; i++)); do
                [ "${HOST_NAMES[i]}" = "`hostname`" ] && continue
@@ -215,12 +214,12 @@ network_verify() {
 
 # Main flow
 if ! check_file ${CSV_FILE}; then
-       exit 1  
+       exit 1
 fi
 
 # Cluster network verification
 if ! network_verify; then
-       exit 1  
+       exit 1
 fi
 
 exit 0