1# vim: filetype=sh 2# 3# CDDL HEADER START 4# 5# The contents of this file are subject to the terms of the 6# Common Development and Distribution License (the "License"). 7# You may not use this file except in compliance with the License. 8# 9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10# or http://www.opensolaris.org/os/licensing. 11# See the License for the specific language governing permissions 12# and limitations under the License. 13# 14# When distributing Covered Code, include this CDDL HEADER in each 15# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16# If applicable, add the following below this CDDL HEADER, with the 17# fields enclosed by brackets "[]" replaced with your own identifying 18# information: Portions Copyright [yyyy] [name of copyright owner] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26 27. $STF_SUITE/include/libtest.kshlib 28 29# 30# Check if a volume is a valide iscsi target 31# $1 volume name 32# return 0 if suceeds, otherwise, return 1 33# 34function is_iscsi_target 35{ 36 typeset dataset=$1 37 typeset target targets 38 39 [[ -z $dataset ]] && return 1 40 41 targets=$($ISCSITADM list target | $GREP "Target:" | $AWK '{print $2}') 42 [[ -z $targets ]] && return 1 43 44 for target in $targets; do 45 [[ $dataset == $target ]] && return 0 46 done 47 48 return 1 49} 50 51# 52# Get the iSCSI name of a target 53# $1 target name 54# 55function iscsi_name 56{ 57 typeset target=$1 58 typeset name 59 60 [[ -z $target ]] && log_fail "No parameter." 61 62 if ! is_iscsi_target $target ; then 63 log_fail "Not a target." 64 fi 65 66 name=$($ISCSITADM list target $target | $GREP "iSCSI Name:" \ 67 | $AWK '{print $2}') 68 69 return $name 70} 71 72# 73# Check shareiscsi option is supported or not 74# return 0 if it is supported, otherwise return 1 75# 76function check_shareiscsi 77{ 78 $ZFS set 2>&1 | $GREP shareiscsi 79 [[ $? -ne 0 ]] && return 1 80 81 return 0 82} 83