Add additional flag: -t set trasnpot (default is tcp). -f force specific transport -disable the fallback to tcp (default is fallback enabled). force the transport specified by the argument of the -t flag. -m manual startup - will set manual startup (default is automatic startup). -l login - login to the new discovered nodes (defualt is false).
Signed-off-by: Doron Shoham <[EMAIL PROTECTED]> Signed-off-by: Erez Zilber <[EMAIL PROTECTED]> --- doc/iscsi_discovery.8 | 41 ++++++++++++++++-------- utils/iscsi_discovery | 84 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 92 insertions(+), 33 deletions(-) diff --git a/doc/iscsi_discovery.8 b/doc/iscsi_discovery.8 index e772130..f14c1c8 100644 --- a/doc/iscsi_discovery.8 +++ b/doc/iscsi_discovery.8 @@ -8,32 +8,45 @@ .SH NAME iscsi_discovery \- discover iscsi devices .SH SYNOPSIS -.B iscsi_discovery <IP> [port] +.B iscsi_discovery <IP> [-p <port>] [-d] [-t <tcp|iser|qla4xxx> [-f]] [-m] [-l] .SH DESCRIPTION Perform send-targets discovery to the specified IP. If a discovery record -is generated, try to login to the portal using iSER and TCP transports. +is generated, try to login to the portal using iSER and TCP transports +(-t flag specifies the requested transport type, TCP is the default). If login using a certain transport succeeds, mark the portal for automatic -login, and disconnect. +login (unless -m flag is used), and disconnect (unless -l flag is used). For iscsi discovery to work, open-iscsi services must be running. e.g. iscsid should be up, and the iscsi modules loaded. This is best accomplished by the init.d startup script. .\" .SH OPTIONS -.\" .TP -.\" .B \-<a command line switch> -.\" <description of what that switch does> -.\" .TP -.\" .B \-<a command line switch> -.\" <description of what that switch does> -.\" .TP -.\" .B <etc . . .> -.\" .SH "SEE ALSO" -.\" <a list of related man pages> +.TP +.BI [-p=]\fIport\-number\fP +set the port number (defualt is 3260). +.TP +.BI [-d] +print debugging information. +.TP +.BI [-t=]\fItransport\-type\fP +set transport (default is tcp). +.TP +.BI [-f] +force specific transport - +disable the fallback to tcp (default is fallback enabled). +force the transport specified by the argument of the -t flag. + +.TP +.BI [-m] +manual startup - will set manual startup (default is automatic startup). +.TP +.BI [-l] +login - login to the new discovered nodes (defualt is false). + .SH AUTHOR Written by Dan Bar Dov .SH "REPORTING BUGS" -Report bugs to <[EMAIL PROTECTED]>. +Report bugs to <[EMAIL PROTECTED]>. .SH COPYRIGHT Copyright \(co Voltaire Ltd. 2006. diff --git a/utils/iscsi_discovery b/utils/iscsi_discovery index 2de9f82..7c06b92 100755 --- a/utils/iscsi_discovery +++ b/utils/iscsi_discovery @@ -33,6 +33,19 @@ # + mark record automatic # +usage() +{ + echo "Usage: $0 <IP> [-p <port>] [-d] [-t <tcp|iser|qla4xxx> [-f]] [-m] [-l]" + echo "Options:" + echo "-p set the port number (defualt is 3260)." + echo "-d print debugging information" + echo "-t set trasnpot (default is tcp)." + echo "-f force specific transport -disable the fallback to tcp (default is fallback enabled)." + echo " force the transport specified by the argument of the -t flag." + echo "-m manual startup - will set manual startup (default is automatic startup)." + echo "-l login to the new discovered nodes (defualt is false)." +} + dbg() { $debug && echo $@ @@ -41,23 +54,44 @@ dbg() initialize() { trap "exit" 2 - usage="Usage: $0 [-d] <IP> [<port>]" debug=false + force="0" + log_out="1" + startup_manual="0" + #set defualt transport to tcp + transport=tcp + #set defualt port to 3260 + port=3260; } parse_cmdline() { - if [ "$1" = "-d" ]; then - debug=true - shift - fi if [ $# -lt 1 ]; then - echo ${usage} + usage exit 1 fi - ip=$1 - port=${2:-3260} + # check if the IP address is valid + ip=`echo $1 | awk -F'.' '$1 != "" && $1 <=255 && $2 != "" && $2 <= 255 && $3 != "" && $3 <= 255 && $4 != "" && $4 <= 255 {print $0}'` + if [ -z "$ip" ]; then + echo "$1 is not a vaild IP address!" + exit 1 + fi + shift + while getopts "dfmlt:p:" options; do + case $options in + d ) debug=true;; + f ) force="1";; + t ) transport=$OPTARG;; + p ) port=$OPTARG;; + m ) startup_manual="1";; + l ) log_out=0;; + \? ) usage + exit 1;; + * ) usage + exit 1;; + esac + done } @@ -91,15 +125,22 @@ discover() /bin/rm -f ${df} } -set_auto_if_login() +try_login() { + if [ "$startup_manual" != "1" ]; then + iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic + fi iscsiadm -m node --targetname ${target} --portal ${portal} --login >/dev/null 2>&1 ret=$? if [ ${ret} = 0 ]; then - iscsiadm -m node --targetname ${target} --portal ${portal} --logout - iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic echo "Set target ${target} to automatic login over ${transport} to portal ${portal}" ((connected++)) + if [ "$log_out" = "1" ]; then + iscsiadm -m node --targetname ${target} --portal ${portal} --logout + fi + else + echo "Cannot login over ${transport} to portal ${portal}" + iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v manual fi return ${ret} } @@ -107,21 +148,26 @@ set_auto_if_login() set_transport() { transport=$1 + if [ "$transport" == "iser" ];then + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n node.conn[0].iscsi.HeaderDigest -v None + iscsiadm -m node --targetname ${target} --portal ${portal} \ + --op update -n node.conn[0].iscsi.DataDigest -v None + fi + transport_name=`iscsiadm -m node -p ${portal} -T ${target} |awk '/transport_name/ {print $1}'` iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n node.conn[0].iscsi.HeaderDigest -v None - iscsiadm -m node --targetname ${target} --portal ${portal} \ - --op update -n node.transport_name -v ${transport} + --op update -n ${transport_name} -v ${transport} } select_transport() { - set_transport iser - dbg "Testing iser-login to target ${target} portal ${portal}" - set_auto_if_login - if [ $? != 0 ]; then + set_transport $transport + dbg "Testing $transport-login to target ${target} portal ${portal}" + try_login; + if [ $? != 0 -a "$force" = "0" ]; then set_transport tcp dbg "starting to test tcp-login to target ${target} portal ${portal}" - set_auto_if_login + try_login; fi } -- 1.5.3.6 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to open-iscsi@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/open-iscsi -~----------~----~----~----~------~----~------~--~---