1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24 # Use is subject to license terms.
  25 #
  26 
  27 #
  28 # NAME
  29 #       fc_target_online_offline_io
  30 # DESCRIPTION
  31 #       target cable pull tests with diskomizer I/O.
  32 #       utilized by fc target test suite
  33 #
  34 # ARGUMENT
  35 #       $1 - fc initiator host
  36 #       $2 - the seconds of target online/offline intervals
  37 #       $3 - test rounds for target online/offline 
  38 #
  39 # RETURN
  40 #       void
  41 #
  42 function fc_target_online_offline_io
  43 {       
  44         typeset hostname=$1
  45         typeset intervals=$2
  46         typeset max_iter=$3
  47         if [ $NO_IO = 0 ];then
  48                 return
  49         fi
  50         typeset cmd="$LUXADM probe | grep -c \"Logical Path\""
  51         run_rsh_cmd $hostname "$cmd"
  52         typeset LUN_NO_PRE=`get_cmd_stdout`
  53         if [ $LUN_NO_PRE -eq 0 ];then
  54                 cti_fail "FAIL - $hostname : fail to get LUN LIST"
  55                 report_err "$cmd"
  56         elif [ $VOL_MAX -ne $LUN_NO_PRE ]; then
  57                 cti_report "WARNING - There should be $VOL_MAX LUNs"\
  58                     "on initiator host $hostname setup,"\
  59                     "but $LUN_NO_PRE LUNs now"
  60                 report_err "$cmd"
  61         else
  62                 :
  63         fi
  64 
  65         typeset iter=1
  66         typeset t_portWWN
  67         while [ $iter -le $max_iter ]   
  68         do
  69                 cti_report "Executing: running target online - offline to"\
  70                     "verify failover with $iter round"\
  71                     "and $intervals intervals"
  72                 
  73                 for t_portWWN in $G_TARGET
  74                 do
  75                         typeset port=`format_shellvar $t_portWWN`
  76                         typeset cmd="$STMFADM offline-target $t_portWWN"
  77                         cti_report "$cmd"
  78                         run_ksh_cmd "$cmd"
  79                         if [ `get_cmd_retval` -ne 0 ];then
  80                                 report_err "$cmd"
  81                                 cti_fail "WARNING - Can not offline fc target port"
  82                         fi
  83                         cti_report "sleep $intervals intervals after offline target port"
  84                         sleep $intervals
  85                         
  86                         typeset cmd="$STMFADM online-target $t_portWWN"
  87                         cti_report "$cmd"
  88                         run_ksh_cmd "$cmd"
  89                         if [ `get_cmd_retval` -ne 0 ];then
  90                                 report_err "$cmd"
  91                                 cti_fail "WARNING - Can not online fc target port"
  92                         fi
  93                         cti_report "sleep $intervals intervals after online target port"
  94                         sleep $intervals
  95                 done
  96                 (( iter+=1 ))
  97         done
  98 }
  99 #
 100 # NAME
 101 #       fc_target_online_offline
 102 # DESCRIPTION
 103 #       target cable pull tests without diskomizer I/O.
 104 #       utilized by fc target test suite
 105 #
 106 # ARGUMENT
 107 #       $1 - fc initiator host
 108 #       $2 - the seconds of target online/offline intervals
 109 #       $3 - test rounds for target online/offline 
 110 #
 111 # RETURN
 112 #       void
 113 #
 114 function fc_target_online_offline
 115 {       
 116         typeset hostname=$1
 117         typeset intervals=$2
 118         typeset max_iter=$3
 119         leadville_bug_trigger $hostname
 120         typeset cmd="$LUXADM probe"
 121         run_rsh_cmd $hostname "$cmd"
 122         typeset LUN_NO_PRE=`get_cmd_stdout  | grep -c "Logical Path"`   
 123         if [ $LUN_NO_PRE -eq 0 ];then
 124                 cti_fail "FAIL - $hostname : fail to get LUN LIST"
 125                 report_err "$cmd"
 126         elif [ $VOL_MAX -ne $LUN_NO_PRE ]; then
 127                 cti_report "WARNING - There should be $VOL_MAX LUNs"\
 128                     "on initiator host $hostname setup,"\
 129                     "but $LUN_NO_PRE LUNs now"
 130                 report_err "$cmd"
 131         else
 132                 :
 133         fi
 134         
 135         typeset target_list="$G_TARGET"
 136         typeset t_portWWN
 137         for t_portWWN in $target_list
 138         do
 139                 typeset port=`format_shellvar $t_portWWN`
 140                 eval typeset online="\$TARGET_${port}_ONLINE"
 141                 if [ "$online" = "Y" ];then             
 142                         eval TARGET_${port}_ONLINE=N
 143                         typeset cmd="$STMFADM offline-target $t_portWWN"                
 144                         cti_report "$cmd"
 145                         run_ksh_cmd "$cmd"
 146                         if [ `get_cmd_retval` -ne 0 ];then
 147                                 report_err "$cmd"
 148                                 cti_fail "WARNING -"\
 149                                     "Can not offline fc target port"
 150                         fi
 151                 fi
 152         done
 153         cti_report "Executing: sleep $FT_SNOOZE intervals to verify"\
 154                 "all the LUNs are offline from initiator host"
 155         sleep $FT_SNOOZE
 156         leadville_bug_trigger $hostname
 157         typeset cmd="$LUXADM probe"
 158         run_rsh_cmd $hostname "$cmd"
 159         typeset LUN_NOW=`get_cmd_stdout  | grep -c "Logical Path"`
 160         if [ $LUN_NOW -ne 0 ];then
 161                 cti_fail "FAIL - There should be 0 LUNs on initiator host"\
 162                     "$hostname after offline-target, but $LUN_NOW LUNs now"
 163                 report_err "$cmd"
 164         fi
 165 
 166         for t_portWWN in $target_list
 167         do
 168                 typeset port=`format_shellvar $t_portWWN`
 169                 eval typeset online="\$TARGET_${port}_ONLINE"
 170                 if [ "$online" = "N" ];then             
 171                         eval TARGET_${port}_ONLINE=Y
 172                         typeset cmd="$STMFADM online-target $t_portWWN"
 173                         cti_report "$cmd"
 174                         run_ksh_cmd "$cmd"
 175                         if [ `get_cmd_retval` -ne 0 ];then
 176                                 report_err "$cmd"
 177                                 cti_fail "WARNING -"\
 178                                     "Can not online fc target port"
 179                         fi
 180                 fi
 181         done
 182         cti_report "Executing: sleep $FT_SNOOZE intervals to verify"\
 183             "all the LUNs are online from initiator host"
 184         sleep $FT_SNOOZE
 185         leadville_bug_trigger $hostname
 186         typeset cmd="$LUXADM probe"
 187         run_rsh_cmd $hostname "$cmd"
 188         typeset LUN_NOW=`get_cmd_stdout | grep -c "Logical Path"`
 189         if [ $LUN_NOW -lt $LUN_NO_PRE ];then
 190                 cti_fail "FAIL - There should be at least $LUN_NO_PRE LUNs"\
 191                     "on initiator host $hostname after online-target,"\
 192                     "but $LUN_NOW LUNs now"
 193                 report_err "$cmd"
 194         fi
 195 }
 196