proc default_zone_test { } { global cl_winhost_ip_list set wwn_list [get_device_wwns] set pid_list [get_all_device_pids] set number_remote_pid [expr [llength $pid_list] - [llength $wwn_list]]
foreach pid $pid_list { if {[convert_to_dec [get_pid_alpa $pid]] == 0} { set fport_wwn [get_pid_wwn $pid] } }
if {[cause "nszonemember $fport_wwn" "[llength $wwn_list] local zoned members"] == 0} { add_status "Proper local zoned members shown for nszonemember" 3 } else { add_status "Number of local zoned members shown is not correct" 1 }
if {[cause "nszonemember $fport_wwn" "$number_remote_pid remote zoned members:"] == 0} { add_status "Proper remote zoned members shown" 3 } else { add_status "Number of remote zoned members shown is not correct" 1 }
if {[cause "defzone --show" "committed - All Access"] != 0} { add_status "Default zone with no access allready enabled" 1 }
set cfgshow_config [get_after "cfgshow" "no configuration" 1] if {([trim_string [lindex $cfgshow_config 0]]=="defined") && ([trim_string [lindex $cfgshow_config 1]]=="in effect ")} { add_status "There is no effective or defined configuration" }
do_command "defzone --noaccess" set cfgshow_config [get_after "cfgshow" "no configuration" 1] if {([llength $cfgshow_config]==1) && ([trim_string [lindex $cfgshow_config 0]]=="in effect")} { add_status "Default zone is shown in defined configuration" } else { add_status "cfgshow doesn't display proper default zone after configuring noaccess" 1 }
if {[trim_string [get_after "defzone --show" "transaction - "]] == "No Access"} { add_status "proper transaction is shown with defzone --show option" 3 } else { add_status "proper transaction is not shown with defzone --show" 1 }
retry_command "cfgsave"
if {[get_after "defzone --show" "committed - "]!="No Access"} { add_status "Default zone show not displaying proper access" 3 }
if {[cause "cfgshow" "no configuration"] == 0} { add_status "Improper display of cfgshow" 1 } else { add_status "cfgshow on saving default zone is shown properly" 3 }
set nszone_mem [get_before "nszonemember $fport_wwn" "zoned members" 1] if {([trim_string [lindex $nszone_mem 0]]=="No local") && ([trim_string [lindex $nszone_mem 1]]=="No remote")} { add_status "Proper display of nszone membership after default no access" }
sleep 30
if {([info exists cl_winhost_ip_list])&&([lindex $cl_winhost_ip_list 0]!="")} { get_inq_device_count [lindex $cl_winhost_ip_list 0] 0 }
do_command "defzone --allaccess"
retry_command "cfgsave"
if {[cause "defzone --show" "committed - All Access"] != 0} { add_status "Default zone is not set to all access" 1 }
set cfgshow_config [get_after "cfgshow" "no configuration" 1] if {([trim_string [lindex $cfgshow_config 0]]=="defined") && ([trim_string [lindex $cfgshow_config 1]]=="in effect ")} { add_status "There is no effective or defined configuration" } }
########################################################################### ## NAME ##
transaction_test -tests zone transcation buffer property
## ## SYNOPSIS ##
transaction_test
## ## DESCRIPTION ##
Tests transcation buffer test property
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
transaction_test
################################################################### proc transaction_test { } { do_command "zonecreate \"zone_trans\",\"239,1\"" if {[count_number "cfgshow" "zone_trans"] == 1} { add_status "Created zone with zone_trans" 3 } else { add_status "zone creation failed" 1 }
if {[cause "cfgtransshow" "Current transaction token is"] == 0} { add_status "Zoning transaction is available" 3 } else { add_status "Zoning transaction failed" 1 } set trans_size [trim_string [get_after "cfgsize" "transaction -"]]
if {$trans_size >0} { add_status "Transaction size is greater than zero its $trans_size" 3 } else { add_status "Transaction size is wrong" 1 }
if {[cause "cfgtransabort" "Zoning transaction aborted"] == 0} { add_status "zoning transaction aborted successfully" 3 } else { add_status "zoning transaction abort failed" 1 }
if {[count_number "cfgshow" "zone_trans"] == 0} { add_status "zonecreation properly aborted" 3 } else { add_status "Zone creation didn't abort" 1 } } ########################################################################### ## NAME ##
verify_zones - verify that the zone is propogated properly in the fabric
## ## SYNOPSIS ## ##
verify_zones
## DESCRIPTION ##
This procedure verifies zone configuration propogation in the fabric
## also returns the members of this zone ## ## OPERANDS ##
zone_name: name of the zone whose members needs to be checked
##
status: Checks Effective/Defined configuration based on input
##
user_ad_list: username, password and admindomain
##
ip_list: ipaddress of the fabric that needs to be checked for zone propogation
##
If nothing is specified it takes ipaddress from cl_ip_address_list
## ## DEPENDENCIES ## ## RETURN ##
member list of the zone specified
## ## USAGE ##
verify_zone zone_first Effective
##
--> {10:00:00:00:c9:2b:9d:35 22:00:00:04:cf:03:4c:fa}
## ################################################################### proc verify_zones {zone_name status {user_ad_list "admin password"} {ip_list ""}} { # Store the original ip address for login back to same spawn global cl_ip_address_list global cl_ip_address
global spawn_id set username [lindex $user_ad_list 0] set pwd [lindex $user_ad_list 1] set ad [lindex $user_ad_list 2] set orig_spawn_id $spawn_id
set orig_ip_address $cl_ip_address set status [string toupper $status] if {$ip_list==""} { set ip_list $cl_ip_address_list } # set ip_list [get_fabric_ips] foreach ip $ip_list { if {$ip!=$orig_ip_address} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } } elseif {[set_spawn_id $ip] != 0} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } }
if {$ad !=""} {
ad_select $ad }
retry_command "cfgshow" # Checks the Effective configuration for zone's if {$status=="EFFECTIVE"} { set cfgshow_output [get_command "cfgshow"] set cfgshow_string1 [regexp {Effective configuration:(.*)} $cfgshow_output cfgshow_string] } # Checks the Defined configuration for zone's if {$status =="DEFINED"} { set cfgshow_string [get_between "cfgshow" "Defined configuration:" "Effective configuration:|Type <CR> to continue "] } # Spliting the cfgshow by new line character if {$status=="EFFECTIVE"} { set cfgshow_list [split $cfgshow_string "\r\n"] set lengt [expr [llength $cfgshow_list] - 2] set cfgshow_list [lrange $cfgshow_list 0 $lengt] } else { set cfgshow_list [split $cfgshow_string "\r\n"] } # Variable that needs to be passed set members_list ""
set first_line "" for {set i 0} {$i<[llength $cfgshow_list]} {incr i} { set cfgshow_line [lindex $cfgshow_list $i] #
Search for zone expression in each of cfgshow line if {[regexp {(.*)ne:(.*)} $cfgshow_line cfgshow_zone]} { if {[lsearch $cfgshow_zone $zone_name]!=-1} { for {set j 2} {$j<[llength $cfgshow_zone]} {incr j} { append first_line [lindex $cfgshow_zone $j] } if {$first_line!=""} { lappend members_list $first_line } while {$i< [expr [llength $cfgshow_list]-1]} { incr i set cfgshow_line [lindex $cfgshow_list $i] if {[llength $cfgshow_line]==0} { continue; } #Check if next zone, alias, config has started if so exit if {[regexp {(.*)ne:(.*)|(.*)as:(.*)|(.*)fg:(.*)} $cfgshow_line kk]} { break; } lappend members_list $cfgshow_line } }
} } set members_string [join $members_list ";"] set members_list [split $members_string ";"] set final_member_list "" foreach member $members_list { set final_member [string trim $member] if {[regexp {[a-zA-Z0-9:,-_]+} $final_member t]} { lappend final_member_list $final_member } } lappend zone_list $final_member_list if {$ip!=$orig_ip_address} { end_telnet "exit" } }
#
Check whether zone is propogated properly through out the fabric through compare list set zone_member1 [lindex $zone_list 0] foreach zone_member $zone_list { set compare_result [compare_lists [lsort $zone_member1] [lsort $zone_member]] if {$compare_result != ""} {
add_status "zone configuration is not propogated properly through out fabric $compare_result" 1 } }
if {[set_spawn_id $orig_spawn_id] != 0} { if {[telnet_switch $orig_ip_address $username $pwd] != 0} { add_status "Telnet to switch $orig_ip_address failed" 0 } } return $zone_member1 }
############################################################################## ## ## NAME ##
create_zone - create zone based on key and list provided
## ## SYNOPSIS ##
create_zone
## ## DESCRIPTION ##
This procedure will create zone based on the list provided
##
with zonename as zone_$key and configuration as cfg_$key if configuration
##
argument is set then only creation of zone happens.
##
If key is given as lsan_* then zone is not appended as this is requirement
##
for FCR testing which need zones to start with lsan_*
## ## OPERANDS ##
key: string used to create zone and configuration
##
zonelist: list of devices that needs to be part of zone
##
configuration: If any value is given to this argument,
##
only zone creation gets executed, creation of zone configuration
##
and enabling is ommitted.o
## DEPENDENCIES ## ## RETURN ##
NONE
## ## USAGE ##
create_zone first {4,5 6,7}
## ################################################################### proc create_zone {key zonelist {configuration ""} {enable ""}} {
if {[regexp -nocase {^qos|^lsan} $key]} { set zone_name $key } else { set zone_name zone_$key } set cfg_name cfg_$key set zonestring [join $zonelist ";"] set zonestring [trim_string $zonestring] do_command "zonecreate \"$zone_name\", \"$zonestring\"" do_command "zoneshow"
do_command "cfgshow" do_command "cfgsave" if {$configuration == ""} { retry_command "cfgcreate \"$cfg_name\",\"$zone_name\"" do_command "zoneshow" do_command "cfgshow" retry_command "cfgsave" sleep 20 if {$enable == ""} { retry_command "cfgenable $cfg_name" } } sleep 20 } ############################################################################## ## ## NAME ##
add_zone - add members to existing zone
## ## SYNOPSIS ##
add_zone
## ## DESCRIPTION ##
This procedure will add members to existing zone
## ## OPERANDS
##
key: string used to create zone and configuration
##
zonelist: list of devices that needs to be part of zone
## ## DEPENDENCIES ## ## RETURN ##
NONE
## ## USAGE ##
add_zone first {4,5 6,7}
## ################################################################### proc add_zone {key zonelist} { if {[regexp -nocase {^qos|^lsan} $key]} { set zone_name $key } else { set zone_name zone_$key } set cfg_name cfg_$key set zonestring [join $zonelist ";"] do_command "zoneadd \"$zone_name\",\"$zonestring\"" do_command "zoneshow" do_command "cfgshow" retry_command "cfgsave" sleep 20
}
############################################################################## ## ## NAME ##
remove_zone - remove members from existing zone
## ## SYNOPSIS ##
remove_zone
## ## DESCRIPTION ##
This procedure will remove zone members from existing zone
## ## OPERANDS ##
key: string used to create zone and configuration
##
zonelist: list of devices that needs to be part of zone
## ## DEPENDENCIES ## ## RETURN ##
NONE
## ## USAGE ##
remove_zone first {4,5 6,7}
## ###################################################################
proc remove_zone {key zonelist} { if {[regexp -nocase {^qos|^lsan} $key]} { set zone_name $key } else { set zone_name zone_$key } set cfg_name cfg_$key set zonestring [join $zonelist ";"] do_command "zoneremove \"$zone_name\",\"$zonestring\"" do_command "zoneshow" do_command "cfgshow" retry_command "cfgsave" sleep 20 }
########################################################################### ## NAME ##
failover_with_zonecfg - failover of coreswitch with zone cofiguration
## ## SYNOPSIS ##
failover_with_zonecfg
## ## DESCRIPTION ##
This procedure does hafailover if switch is bladed
## else it does hareboot
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ## ## RETURN ##
NONE
## ## USAGE ##
failover_with_zonecfg
###################################################################
proc failover_with_zonecfg { } { global cl_ip_address cl_zvm_build if {[info exists cl_zvm_build] && $cl_zvm_build == 1} { brcd_login $cl_ip_address do_command "hadisable" do_command "cd /fabos/bin" do_command "./zvmk-tgt -cov" 300 do_command "./zvmk-tgt -leak" 300 do_command "haenable" wait_for_ha_sync } if {[get_switch_platform] < 12000 } {
do_command "hareboot" sleep 120 close_spawn_list "exit" } else { if {[cause "hashow" "ync"] != 0} { add_status "HA State is NOT on Sync. Exiting.... " 0 } else { add_status " HA State is in Sync" } set chk1 [get_hastate] set firstroundCP [get_ActiveCP]
if {[get_ActiveCP] == 2} { do_command "hashow" add_status "HA is DISABLED on this system, exiting the script" 0 } do_command "hafailover" 180 set Timer 10 while {[cause "hashow" "ync" 30 1] != 0} { add_status "Not synchronized yet..." 3 set Timer [expr $Timer - 1] if {$Timer == 0} { add_status "CP failed to synchronize" 1 break }
sleep 30 }
if {[get_hastate] == 0} { do_command "hashow" add_status "After failover, system has only ONE cp or HA is disabled, exiting the script" 0 } } }
########################################################################### ## NAME ##
get_number_devices - get the number of devices based on zone string
## ## SYNOPSIS ##
get_number_devices
## ## DESCRIPTION ##
This procedure parses the zonestring and finds out number of
## devices(targets) participating in the zone ## ## OPERANDS ##
zone_string: zone member list that will be used to find the number of
## targets visiblie through host ##
## DEPENDENCIES ## COPA needs to be installed on the host ## ## RETURN ##
0: on success
##
-1: on failure
## ## USAGE ##
get_number_devices 1,3 3,4
##
--> 4 (4 target visible through host)
## ################################################################### proc get_number_devices {zone_string} { global array fportlist global array lportlist global cl_ip_address_list
set device_count 0 foreach dev $zone_string { foreach ip $cl_ip_address_list { if {$lportlist($ip)!=""} { if {[regexp {([0-9]+,[1-9]+)} $dev]} { set index [lsearch $lportlist($ip) $dev] if {$index!=-1} { incr device_count [llength [lindex $lportlist($ip) [expr $index +1]]]
} } else { for {set j 1} {$j<[llength $lportlist($ip)]} {incr j 2} { if {[lsearch [lindex $lportlist($ip) $j] $dev] != -1} { incr device_count } } } } } } # add_status "Device count $device_count" return $device_count }
########################################################################### ## NAME ##
get_all_remote_devices
## ## SYNOPSIS ##
get_number_devices
## # DESCRIPTION ## Get all the remote devices pids ##
## OPERANDS ## NONE ## ## DEPENDENCIES ## get_remote_devices ## ## RETURN ## Give the PID of remote devices ## ## USAGE ##
get_all_remote_devices
## ################################################################### proc get_all_remote_devices {{domain_ -1}} { set return_value "" set temp_list [get_remote_devices]
if {$domain_ < 0} { set return_value $temp_list } else { foreach item $temp_list { set item_domain [convert_to_dec [get_pid_domain [lindex $item 0]]] if {$domain_ == $item_domain} { set return_value [lappend return_value $item] }
} } return $return_value }
########################################################################### ## NAME ##
get_all_remote_device_wwns
## ## SYNOPSIS ##
get_all_remote_device_wwns
## ## DESCRIPTION ##
SDK Routine
## ## OPERANDS ## ## DEPENDENCIES ## ## RETURN ## ## USAGE ##
get_all_remote_device_wwns
## #############################################################
proc get_all_remote_device_wwns {{wwn_type_ "port"} {domain_ -1}} { set return_value ""
if {$wwn_type_ == "port"} { set wwn_type_ 1 } else { set wwn_type_ 2 }
set temp_list [get_all_remote_devices $domain_] if {$temp_list != ""} { foreach item $temp_list { set return_value [lappend return_value [lindex $item $wwn_type_]] } }
return $return_value } ########################################################################### ## NAME ##
check_device_presence - check device presence through nsshow, nscamshow
## and nsallshow ## ## SYNOPSIS ##
check_device_presence
## ## DESCRIPTION ##
This procedure does nsshow and check whether device is present
## then it telnet's to switches in the fabric, checks the devices presence ## through nscamshow ## ## OPERANDS ##
wwn_list: wwn_list that needs to be checked through nsshow and nscamshow
##
user_ad_list: username, password and admindomain
##
ip_list: List of ip address that needs to be traversed for checking nameserver
##
entries. If nothing is given it takes cl_ip_address_list as default
## ## DEPENDENCIES ## get_device_wwns # get_all_device_pids ## ## RETURN ## ## USAGE ##
check_device_presence {21:00:00:04:cf:03:10:10 21:00:00:04:cf:03:51:38}
## ################################################################### proc check_device_presence {wwn_list {user_ad_list "admin password"} {ip_list ""}} { global cl_ip_address_list cl_ip_address global spawn_id
set orig_ip_address $cl_ip_address set username [lindex $user_ad_list 0] set pwd [lindex $user_ad_list 1] set ad [lindex $user_ad_list 2] set orig_spawn_id $spawn_id
##
Checking the availability of device through nsshow
set ns_wwn_list [get_device_wwns] set pid_list [lsort [get_all_device_pids]] # add_status "PID's from nsallshow : $pid_list" 3
# add_status "wwn's got through nsshow $ns_wwn_list" 3 foreach wwn $wwn_list { if {[lsearch $ns_wwn_list $wwn]== -1} { add_status "Could not find WWN $wwn through nsshow on switch $orig_ip_address" 1 } }
# set ip_list [get_fabric_ips] if {$ip_list==""} { set ip_list $cl_ip_address_list }
## Checking the availability of device through nscamshow foreach ip $ip_list {
if {$ip!=$orig_ip_address} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } if {$ad !=""} { ad_select $ad } set ns_wwn_list [get_device_wwns] set ns_remote_wwn_list [get_all_remote_device_wwns] foreach wwn $wwn_list { if {[lsearch $ns_remote_wwn_list $wwn]== -1} { add_status "Could not find WWN $wwn through nscamshow on switch $ip" 1 } }
## Checking the nsallshow it should be same within the fabric set compare_result [compare_lists $pid_list [lsort [get_all_device_pids]]] if {$compare_result != ""} { add_status "nsallshow did not match: $compare_result" 1 } end_telnet "exit" } } if {[set_spawn_id $orig_spawn_id] != 0} { if {[telnet_switch $orig_ip_address $username $pwd] != 0} {
add_status "Telnet to switch $orig_ip_address failed" 0 } } }
########################################################################### ## NAME ##
check_device_absence - check for device absence in name server
## ## SYNOPSIS ##
check_device_absence
## ## DESCRIPTION ##
This procedure does nsshow and checks for device absence,
## then it telnet's to switches in the fabric, checks the devices ## is not shown remotly through nscamshow ## ## OPERANDS ## ## ## ##
wwn_list: wwn_list that needs to be checked through nsshow and nscamshow user_ad_list: username, password and admindomain ip_list: List of ip address that needs to be traversed for checking nameserver entries. If nothing is given it takes cl_ip_address_list as default
## ## DEPENDENCIES ## get_device_wwns
# get_all_device_pids ## ## RETURN ## ## USAGE ##
check_device_absence {21:00:00:04:cf:03:10:10 21:00:00:04:cf:03:51:38}
## ################################################################### proc check_device_absence {wwn_list {user_ad_list "admin password"} {ip_list ""}} { global cl_ip_address_list cl_ip_address global spawn_id set orig_ip_address $cl_ip_address set username [lindex $user_ad_list 0] set pwd [lindex $user_ad_list 1] set ad [lindex $user_ad_list 2] set orig_spawn_id $spawn_id
## Checking the availability of device through nsshow set ns_wwn_list [get_device_wwns] # add_status "Got wwn list is $wwn_list" 3 # add_status "wwn's got through nsshow $ns_wwn_list" 3 foreach wwn $wwn_list { if {[lsearch $ns_wwn_list $wwn]!= -1} { add_status "WWN $wwn found through nsshow on switch $orig_ip_address" 1 }
}
## Checking the availability of device through nscamshow #set ip_list [get_fabric_ips] if {$ip_list==""} { set ip_list $cl_ip_address_list }
foreach ip $ip_list { if {$ip!=$orig_ip_address} { #
if {[set_spawn_id $ip] != 0} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 }
#
} if {$ad !=""} { ad_select $ad } set ns_wwn_list [get_device_wwns]
#
add_status "wwn's got through nsshow on switch $ip is $ns_wwn_list" set ns_remote_wwn_list [get_all_remote_device_wwns]
#
add_status "NS WWN List in switch $ip is $ns_remote_wwn_list" 3 foreach wwn $wwn_list { if {[lsearch $ns_remote_wwn_list $wwn]!= -1} { add_status "WWN $wwn found through nscamshow on switch $ip" 1
} } end_telnet "exit" } } if {[set_spawn_id $orig_spawn_id] != 0} { if {[telnet_switch $orig_ip_address $username $pwd] != 0} { add_status "Telnet to switch $orig_ip_address failed" 0 } } } ########################################################################### ## NAME ##
clear_zonecfg - disables and clears the zone configuration
## ## SYNOPSIS ##
clear_zonecfg
## ## DESCRIPTION ##
This procedure disables and clears all the zone confiuration
## ## OPERANDS ## NONE ## ## DEPENDENCIES
## NONE ## ## RETURN ## NONE ## ## USAGE ##
clear_zonecfg
## ############################################################################# proc clear_zonecfg { } { retry_command "cfgdisable" sleep 30 retry_command "cfgclear" retry_command "cfgsave" sleep 30 retry_command "cfgshow" }
########################################################################### ## NAME ##
reinitialize_device_array - reinitializes the device array
## ## SYNOPSIS ## ##
reinitialize_device_array
## DESCRIPTION ##
This procedure reinitializes the device array by calling nsallshow
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ## get_devices -sdk routing ## ## RETURN # NONE ### ## USAGE ##
reinitialize_device_array
## ################################################################### proc reinitialize_device_array { } { global array fportlist global cl_ip_address global array lportlist set local_device_list [get_devices] set fportlist($cl_ip_address) "" set lportlist($cl_ip_address) "" for {set i 0} {$i<[llength $local_device_list]} {incr i} { set pid [lindex [lindex $local_device_list $i] 0]
set loop [string range [lindex [lindex $local_device_list $i] 0] 4 5] set domain [convert_to_dec [string range [lindex [lindex $local_device_list $i] 0] 0 1]] set dp "" if {$loop==00} { append dp $domain,[convert_to_dec [string range [lindex [lindex $local_device_list $i] 0] 2 3]] lappend fportlist($cl_ip_address) $dp lappend fportlist($cl_ip_address) [lindex [lindex $local_device_list $i] 1] } set dp "" if {$loop!=00} { set domain [convert_to_dec [string range [lindex [lindex $local_device_list $i] 0] 0 1]] append dp $domain,[convert_to_dec [string range [lindex [lindex $local_device_list $i] 0] 2 3]] lappend lportlist($cl_ip_address) [list $dp] set templist [list [lindex [lindex $local_device_list $i] 0]] set wwnlist [list [lindex [lindex $local_device_list $i] 1]] for {set j [expr $i+1]} {$j<=[llength $local_device_list]} {incr j; incr i} { set next_pid [lindex [lindex $local_device_list $j] 0] set first_domainarea [string range [lindex $templist 0] 0 3] set next_domainarea [string range $next_pid 0 3] if {$first_domainarea==$next_domainarea} { lappend templist [lindex [lindex $local_device_list $j] 0] lappend wwnlist [lindex [lindex $local_device_list $j] 1] } else { break;
} } lappend lportlist($cl_ip_address) $wwnlist } } }
########################################################################### ## NAME ##
initialize_device_array - Initialize the device array list
## ## SYNOPSIS ## initialize_device_array ## ## DESCRIPTION ## Initialize the device array using nsallshow, output is population ##
of global array fport and lport list with ipaddress as index
##
ip_list: IP's of switch whose device information needs to be gathered.
##
If not defined cl_ip_address_list is taken as default
## ## OPERANDS ## ip_list(optional) ## ## DEPENDENCIES ## get_all_devices
## get_fabricshow_info ## ## RETURN ## NONE ## ## USAGE ##
initialize_device_array
###############################################################
proc initialize_device_array {{ip_list ""} } { global array fportlist global array lportlist global cl_ip_address_list
if {$ip_list == ""} { set ip_list $cl_ip_address_list }
foreach ip $ip_list { set fportlist($ip) "" set lportlist($ip) "" }
set all_devices [get_all_devices] set fabric_info [get_fabricshow_info]
foreach switch_info $fabric_info { lappend domain_iplist [lindex $switch_info 0] lappend domain_iplist [lindex $switch_info 2] } add_status "IP Address list $domain_iplist" 3 for {set i 0} {$i<[llength $all_devices]} {incr i} { set pid [lindex [lindex $all_devices $i] 0] set loop [string range [lindex [lindex $all_devices $i] 0] 4 5] set domain [convert_to_dec [string range [lindex [lindex $all_devices $i] 0] 0 1]] set dp "" if {$loop=="00" || $loop=="c0" || $loop=="40" || $loop=="80"} { append dp $domain,[convert_to_dec [string range [lindex [lindex $all_devices $i] 0] 2 3]] set index [lsearch $domain_iplist $domain] set ip [lindex $domain_iplist [expr $index + 1]] lappend fportlist($ip) $dp lappend fportlist($ip) [lindex [lindex $all_devices $i] 1] } set dp "" if {$loop!=00} { append dp $domain,[convert_to_dec [string range [lindex [lindex $all_devices $i] 0] 2 3]] set index [lsearch $domain_iplist $domain] set ip [lindex $domain_iplist [expr $index + 1]] lappend lportlist($ip) [list $dp] set templist [list [lindex [lindex $all_devices $i] 0]] set wwnlist [list [lindex [lindex $all_devices $i] 1]]
for {set j [expr $i+1]} {$j<=[llength $all_devices]} {incr j; incr i} { set next_pid [lindex [lindex $all_devices $j] 0] set first_domainarea [string range [lindex $templist 0] 0 3] set next_domainarea [string range $next_pid 0 3] if {$first_domainarea==$next_domainarea} { lappend templist [lindex [lindex $all_devices $j] 0] lappend wwnlist [lindex [lindex $all_devices $j] 1] } else { break; } } lappend lportlist($ip) $wwnlist } } }
########################################################################### ## NAME ## initialize_pid_db ## ## SYNOPSIS ## initialize_pid_db ## ## DESCRIPTION ## initialize PID database using nsshow and nscamshow
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
SDK Routing get_all_devices
## ## RETURN ##
NONE
## ## USAGE ##
initialize_pid_db
## ################################################################### proc initialize_pid_db {} { global array wwn_pid_list set dev_data [get_all_devices] foreach device $dev_data { set wwn_pid_list([lindex $device 1]) [lindex $device 0] } }
########################################################################### ## NAME ## get_wwn_pid_db
## ## SYNOPSIS ## get_wwn_pid_db ## ## DESCRIPTION ## get PID for give wwn through database ## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
initialize_pid_db should have been called earlier
## ## RETURN ##
NONE
## ## USAGE ##
get_wwn_pid_db
## ###################################################################
proc get_wwn_pid_db {wwn} { global array wwn_pid_list return $wwn_pid_list($wwn) }
proc check_cfg {zone} { set boolean 0 foreach tmp_zone $zone { if {$boolean == 0} { do_command "cfgcreate \"tmp_config\", \"$tmp_zone\"" set boolean 1 } else { do_command "cfgadd \"tmp_config\", \"$tmp_zone\"" } } do_command "cfgenable \"tmp_config\""
set member_list [get_zone_object_members "cfg" "tmp_config"] foreach tmp $member_list { foreach tmp_zone $zone { if {$tmp == $tmp_zone} { add_status "tmp_config was created with zone $tmp_zone" 3 } } }
set check_tmp_cfg [trim_string [get_after "cfgshow" "Effective conf(.*)cfg:"]]
if {$check_tmp_cfg == "tmp_config"} {
add_status "tmp_config is effective" } else { add_status "tmp_config was not made effective" 1 } }
proc get_alias_wwnport {wwnport_list alias_list} { set ret_list "" for {set i 0} {$i < [llength $wwnport_list]} {incr i 1} { foreach element [lindex $wwnport_list $i] { foreach tmp $alias_list { if {[lindex $element 0] == $tmp} { lappend ret_list [lindex $element 1] } } } } return $ret_list } ############################################################################## ### ## NAME ##
create_dummy_zone
## ## SYNOPSIS ##
create_dummy_zone
## ## DESCRIPTION ##
Create dummy zone as part of defined zone configuration
## ## OPERANDS ##
None.
## ## DEPENDENCIES ##
None.
## ## RETURN ##
None.
## ## USAGE ## create_dummy_zone ############################################################################## ### proc create_dummy_zone {} { for {set i 25} {$i<35} {incr i} { for {set j 0} {$j<10} {incr j} { append zone_list "21:00:00:0$j:00:00:1c:$i" " " } } set zonestring [join $zone_list ";"]
for {set i 108} {$i<118} {incr i} {
for {set j 0} {$j<10} {incr j} { append zone_list1 "$i,$j" " " } } set zonestring1 [join $zone_list1 ";"]
for {set i 1} {$i<50} {incr i} { do_command "zonecreate \"dummyzone_$i\", \"$zonestring\"" } for {set i 51} {$i<100} {incr i} { do_command "zonecreate \"dummyzone_$i\", \"$zonestring1\"" } do_command "cfgshow" retry_command "cfgsave" sleep 30 }
########################################################################### ## NAME ##
verify_zones_vf - verify that the zone is propogated properly in the fabric in LS context
## ## SYNOPSIS ##
verify_zones_vf
## ## DESCRIPTION
##
This procedure verifies zone configuration propogation in the fabric
## also returns the members of this zone ## ## OPERANDS ##
zone_name: name of the zone whose members needs to be checked
##
status: Checks Effective/Defined configuration based on input
##
fid : LS fid
##
user_ad_list: username and password
##
ip_list: ipaddress of the fabric that needs to be checked for zone propogation
##
If nothing is specified it takes ipaddress from cl_ip_address_list
## ## DEPENDENCIES ## ## RETURN ##
member list of the zone specified
## ## USAGE ##
verify_zones_vf zone_first Effective
##
--> {10:00:00:00:c9:2b:9d:35 22:00:00:04:cf:03:4c:fa}
## ################################################################### proc verify_zones_vf {zone_name status {fid "128"} {user_ad_list "root fibranne"} {ip_list ""}} { # Store the original ip address for login back to same spawn global cl_ip_address_list global cl_ip_address
global spawn_id set username [lindex $user_ad_list 0] set pwd [lindex $user_ad_list 1] set orig_spawn_id $spawn_id
set orig_ip_address $cl_ip_address set status [string toupper $status] if {$ip_list==""} { set ip_list $cl_ip_address_list } foreach ip $ip_list { if {$ip!=$orig_ip_address} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } } elseif {[set_spawn_id $ip] != 0} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } }
if {($fid != 128) && ([is_vf_enabled] == 0)} { setcontext_fid $fid } retry_command "cfgshow"
# Checks the Effective configuration for zone's if {$status=="EFFECTIVE"} { set cfgshow_output [get_command "cfgshow"] set cfgshow_string1 [regexp {Effective configuration:(.*)} $cfgshow_output cfgshow_string] set cfgshow_list [lrange [compress_list [split $cfgshow_string "\r\n"] ] 0 end-1] } # Checks the Defined configuration for zone's if {$status =="DEFINED"} { set cfgshow_string [get_between "cfgshow" "Defined configuration:" "Effective configuration:|Type <CR> to continue"] set cfgshow_list [compress_list [split $cfgshow_string "\r\n"] ] } # Variable that needs to be passed set members_list "" set first_line "" for {set i 0} {$i<[llength $cfgshow_list]} {incr i} { set cfgshow_line [lindex $cfgshow_list $i] # Search for zone expression in each of cfgshow line if {[regexp {(.*)ne:(.*)} $cfgshow_line cfgshow_zone]} { if {[lsearch $cfgshow_zone $zone_name]!=-1} { for {set j 2} {$j<[llength $cfgshow_zone]} {incr j} { append first_line [lindex $cfgshow_zone $j] } if {$first_line!=""} { lappend members_list $first_line
} while {$i< [expr [llength $cfgshow_list]-1]} { incr i set cfgshow_line [lindex $cfgshow_list $i] if {[llength $cfgshow_line]==0} { continue; } #Check if next zone, alias, config has started if so exit if {[regexp {(.*)ne:(.*)|(.*)as:(.*)|(.*)fg:(.*)} $cfgshow_line kk]} { break; } lappend members_list $cfgshow_line } } } } set members_string [join $members_list ";"] set members_list [split $members_string ";"] set final_member_list "" foreach member $members_list { set final_member [string trim $member] if {[regexp {[a-zA-Z0-9:,-_]+} $final_member t]} { lappend final_member_list $final_member } }
lappend zone_list $final_member_list if {$ip!=$orig_ip_address} { end_telnet "exit" } }
# Check whether zone is propogated properly through out the fabric through compare list set zone_member1 [lindex $zone_list 0] foreach zone_member $zone_list { set compare_result [compare_lists [lsort $zone_member1] [lsort $zone_member]] if {$compare_result != ""} { add_status "$status zone configuration is not propogated properly through out fabric $compare_result" 1 } else { add_status "$status zone configuration is propogated properly through out the fabric === $compare_result" 3 } }
if {[set_spawn_id $orig_spawn_id] != 0} { if {[telnet_switch $orig_ip_address $username $pwd] != 0} { add_status "Telnet to switch $orig_ip_address failed" 0 } } return $zone_member1 }
########################################################################### ## NAME ## check_device_status - Verifies if the particular device wwn is connected in the given port number ## ## SYNOPSIS ##
check_device_status
## ## DESCRIPTION ##
This procedure verifies portshow portWWn's of device and checks if the
## given wwn is connected to that port. ## ## OPERANDS ##
device_info_list : passed as a list of lists. 1st member should be port number
## verified.
and next member is the wwn of device which needs to be
## Eg: set device_info_list [list "9 22:00:00:04:cf:03:4c:fa" "7 10:00:00:00:c9:2b:9d:35"] ## ## DEPENDENCIES ##
NONE
## RETURN ##
NONE
## ## USAGE ##
check_device_status $device_info_list
## ################################################################### proc check_device_status {device_info_list} { set flag 0 set len [llength $device_info_list] foreach line $device_info_list { set port [lindex $line 0] set wwn [lindex $line 1] set wwn_list [trim_list_elements [lrange [compress_list [split [get_between "portshow $port" "portWwn of device" "Distance"] "\r\n"]] 1 end] "\t"] if {[lsearch $wwn_list $wwn] == -1} { add_status "Error device wwn \"$wwn\" missing in switch in port $port. Update the device list in testbed file properly" 0 } else { incr flag } } if {$flag == $len} { add_status "All devices verified successfully" 3 } }
########################################################################### ## NAME ## get_wwn_pid_nsshow - Used to return pid and wwn from nsshow output in the form of a list. ##
## SYNOPSIS ##
get_wwn_pid_nsshow
## ## DESCRIPTION ##
This procedure returns a list of list with each element consisting of
## pid and wwn of each device obtained from nsshow output. Regexp in th api can be modified ##
according to future needs.
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
NONE
## RETURN ##
List of lists - containing pid and wwn of devices
## ## USAGE ##
get_wwn_pid_nsshow
## ################################################################### proc get_wwn_pid_nsshow {} { set return_list [list] set wwn_list [list] set pid_list [list] set output [lrange [compress_list [split [get_command "nsshow | grep '\[0-9a-fA-F\]\\{6\\}'"]
"\r\n"]] 1 end-1] add_status "$output==>" 3 foreach line $output { set temp [split $line ";"] if {[regexp {N\s+([0-9a-f]+)} [lindex $temp 0] match pid]==1} { lappend pid_list $pid if {[regexp {(([0-9a-fA-f]+:){7}[0-9a-fA-F]+)} [lindex $temp 2] match wwn ignore] ==1} { lappend wwn_list $wwn } } } lappend return_list $wwn_list $pid_list return $return_list }
proc zone_cfg_enable {cfg_name zone_name} { retry_command "cfgcreate \"$cfg_name\",\"$zone_name\"" do_command "zoneshow" do_command "cfgshow" retry_command "cfgsave" sleep 20 retry_command "cfgenable $cfg_name" sleep 20 }
###########################################################
proc get_index_given_port {port_no_list} { set index_list "" set port_list_output [get_switchport_details] foreach port_no $port_no_list { if {[regexp "/" $port_no]} { set port_temp [split $port_no "/"] set slot [lindex $port_temp 0] set port [lindex $port_temp 1] set flag 1 } else { set port $port_no set flag 0 } foreach list1 $port_list_output { set index "" if {$flag == 0} { if {[lindex $list1 1] == $port} { set index [lindex $list1 0] lappend index_list $index } } else { if {([lindex $list1 1] == $slot) && ([lindex $list1 2] == $port)} { set index [lindex $list1 0]
lappend index_list $index } } } } return $index_list }
proc get_pid {port_no} { set pid "" set port_list_output [get_switchport_details] if {[regexp "/" $port_no]} { set port_temp [split $port_no "/"] set slot [lindex $port_temp 0] set port [lindex $port_temp 1] set flag 1 } else { set port $port_no set flag 0 } foreach list1 $port_list_output { set list1 [compress_list $list1] if {$flag == 0} { if {[lindex $list1 1] == $port} { set pid [lindex $list1 2]
} } else { if {([lindex $list1 1] == $slot) && ([lindex $list1 2] == $port)} { set pid [lindex $list1 3] } } } return $pid }
proc get_slot_type { } { set slot_type "" set val [lrange [compress_list [split [get_command "slotshow -m"] "\r\n"]] 3 end] foreach line $val { set slot "" set type "" set status [regexp {([0-9]+)\s*[a-zA-Z\s]+([0-9]+)\s*[a-zA-Z0-9\-]+} $line ignore slot type] if {$status == 1} { lappend slot_type $slot $type } } return $slot_type }
proc get_slot_ports {slot} {
set port_list "" clear_buffer set val [make_matrix "switchshow" "============" ""] foreach line $val { set line [compress_list $line] set temp [lindex $line 0] if {[lindex $temp 1] == $slot} { lappend port_list [lindex $temp 2] } } return $port_list }
proc compare_switch_logs {id_1 id_2 show_command_list {file_dir ""}} { set return_value 0 if {[string length $file_dir] != 0} { set file_dir "$file_dir/" } foreach type $show_command_list { set return_list "" if {[string first "=" $type] >= 0} { if {[llength $type] >= 2} { set type [lindex $type 0] set type [string trimleft $type "="] }
}
set type [replace_string_all $type " " "_"] set type [replace_string_all $type "/" "_"] set diff_count [compare_files "$file_dir[set id_1]_$type.txt" "$file_dir[set id_2]_$type.txt"] add_status "diff_count : $diff_count" if {$diff_count != 0} { add_status "$type outputs do not match" 2 add_status "files are $file_dir[set id_1]_$type.txt and $file_dir[set id_2]_$type.txt" 3 set return_value [llength $diff_count] lappend return_list $return_value $file_dir[set id_1]_$type.txt $file_dir[set id_2]_$type.txt } else { add_status "PASSED: $type outputs match" lappend return_list $return_value } } add_status "return_list : $return_list" return $return_list }
proc get_showListcmd_output {ip_address show_list {fid 128}} { global cl_log_path cl_diff_file_dir if {[set_spawn_id $ip_address]!= 0} { if {[telnet_switch $ip_address]!= 0} { add_status "Switch: $ip_address not available" 1
} } if {$fid != "128"} { setcontext_fid $fid clear_buffer } set switch_info [log_switch_state $show_list [subst $cl_diff_file_dir]]
return $switch_info }
proc swap_ports {port1 port2} { do_command "portswapenable" do_command "portdisable $port1" do_command "portdisable $port2" set status [get_command "portswap $port1 $port2"] if {[regexp "portswap done" $status]} { add_status "Port swap done between $port1 and $port2 successfully" 3 } else { add_status "Error observed while doing port swap" 1 } do_command "portenable $port1" do_command "portenable $port2" sleep 60 }
proc check_test_mode_configuration {test_mode} { global cl_ag_ip_address_list cl_ip_address_list cl_fid_list set flag 0 foreach SUT $cl_ag_ip_address_list { if {[set_spawn_id $SUT] == 1} { if {[telnet_switch $SUT] != 0} { add_status "Switch $SUT not available" 0 } } set switch_mode [string trim [get_after "switchshow" "switchMode:"]] if {$switch_mode == "Access Gateway Mode"} { add_info "AG mode is already enabled in $SUT" add_status "Check for Disabled ports in the switch" set disabled_port_list [get_ports "Disabled"] if {$disabled_port_list != ""} { foreach port $disabled_port_list { do_command "portcfgpersistentenable $port" } sleep 50 } add_status "Required configuration exists in AG $SUT" } else { add_status "Required configuration not available" add_status "Making the necessary configurations for AG...."
incr flag } }
if {$flag != 0} { add_info "Enable AG mode in AG capable switch" source /vobs/multisite/intgtest/inc/configure_ag.inc }
set val "Scenario_$test_mode" switch $val { "Scenario_1" { set flag 0 foreach SUT $cl_ip_address_list { if {[set_spawn_id $SUT] == 1} { if {[telnet_switch $SUT] != 0} { add_status "Switch $SUT not available" 0 } } set vf_status [string trim [get_after "fosconfig --show" "Virtual Fabric:"]] if {[regexp {enabled} $vf_status] == 0} { add_info "VF is already disabled in $SUT" add_status "Check for Disabled ports in the switch" set disabled_port_list [get_ports "Disabled"] if {$disabled_port_list != ""} {
foreach port $disabled_port_list { do_command "portcfgpersistentenable $port" } sleep 50 } } else { incr flag } } if {$flag == 0} { add_status "All switches in the fabric are in Non-VF mode" #Verify whether the fabric has come up fine set SUT [lindex $cl_ip_address_list 0] if {[set_spawn_id $SUT]!= 0} { if {[telnet_switch $SUT]!= 0} { add_status "Switch: $SUT not available" 0 } } set total_no_of_switches [llength $cl_ip_address_list] set total_switches 0 set fabric_show [get_command "fabricshow"] regexp {The Fabric has ([0-9]+) switches} $fabric_show ignore total_switches if {$total_no_of_switches == $total_switches} { add_status "Fabric has come up fine" 3 add_status "configuration for Non-VF mode testing is available. Proceed with testing...." 3
} else { add_status "Fabric has not come up properly" add_info "Creating configuration for testing in Non-VF mode" source /vobs/multisite/intgtest/inc/create_nonvf_fabric.inc } close_spawn_list end_telnet "exit" } else { add_info "Creating configuration for testing in Non-VF mode" source /vobs/multisite/intgtest/inc/create_nonvf_fabric.inc } } "Scenario_2" { set flag 0 foreach SUT $cl_ip_address_list { if {[lsearch $cl_ag_ip_address_list $SUT] == -1} { if {[set_spawn_id $SUT] == 1} { if {[telnet_switch $SUT] != 0} { add_status "Switch $SUT not available" 0 } } set vf_status [string trim [get_after "fosconfig --show" "Virtual Fabric:"]] if {[regexp {enabled} $vf_status] == 1} { add_status "VF is already enabled in $SUT" set ls_list [get_logical_switch_fid]
set bs_fid [get_base_switch_fid] if {([llength $ls_list] == 2) && ($bs_fid == "")} { foreach ls $ls_list { if {[regexp "128" $ls]} { do_command "setcontext 128" set onlineport_list [get_ports "Port"] if {$onlineport_list == ""} { add_status "No online ports found in DS" } else { add_status "Online ports found in DS" incr flag } } else { setcontext_fid $ls clear_buffer set disabled_ports [get_ports "Disabled"] if {$disabled_ports != ""} { foreach port $disabled_ports { do_command "portcfgpersistentenable $port" } } sleep 50 } } } else {
incr flag } } else { incr flag } } } if {$flag == 0} { add_status "VF is enabled in all the switches in the fabric" set fabric_sw_list "" foreach switch $cl_ip_address_list { if {[lsearch $cl_ag_ip_address_list $switch] == -1} { lappend fabric_sw_list $switch } } if {[llength $fabric_sw_list] > 1} { set SUT [lindex $fabric_sw_list 0] if {[set_spawn_id $SUT]!= 0} { if {[telnet_switch $SUT]!= 0} { add_status "Switch: $SUT not available" 0 } } set lsfid [lindex $ls_list end] setcontext_fid $lsfid clear_buffer
set total_no_of_switches [llength $fabric_sw_list] set total_switches 0 set fabric_show [get_command "fabricshow"] regexp {The Fabric has ([0-9]+) switches} $fabric_show ignore total_switches if {$total_no_of_switches == $total_switches} { add_status "Fabric has come up fine" 3 add_status "configuration for VF LS mode testing is available. Proceed with testing...." 3 } else { add_status "Fabric has not come up properly" add_info "Creating configuration for testing in VF LS mode" source /vobs/multisite/intgtest/inc/create_ls_fabric.inc } close_spawn_list end_telnet "exit" } } else { add_info "Creating configuration for testing in VF LS mode" source /vobs/multisite/intgtest/inc/create_ls_fabric.inc } } "Scenario_3" { set flag 0 foreach SUT $cl_ip_address_list { if {[lsearch $cl_ag_ip_address_list $SUT] == -1} { if {[set_spawn_id $SUT] == 1} {
if {[telnet_switch $SUT] != 0} { add_status "Switch $SUT not available" 0 } } set vf_status [string trim [get_after "fosconfig --show" "Virtual Fabric:"]] if {[regexp {enabled} $vf_status] == 1} { add_status "VF is already enabled in $SUT" set ls_list [get_logical_switch_fid] set bs_fid [get_base_switch_fid] if {([llength $ls_list] == 2) && ($bs_fid != "")} { foreach ls $ls_list { if {[regexp "128" $ls]} { do_command "setcontext 128" set onlineport_list [get_ports "Port"] if {$onlineport_list == ""} { add_status "No online ports found in DS" } else { add_status "Online ports found in DS" incr flag } } else { setcontext_fid $ls clear_buffer set disabled_ports [get_ports "Disabled"] if {$disabled_ports != ""} {
foreach port $disabled_ports { do_command "portcfgpersistentenable $port" } } sleep 50 } } } else { incr flag } } else { incr flag } } } if {$flag == 0} { add_status "VF is enabled in all the switches in the fabric" set fabric_sw_list "" foreach switch $cl_ip_address_list { if {[lsearch $cl_ag_ip_address_list $switch] == -1} { lappend fabric_sw_list $switch } } if {[llength $fabric_sw_list] > 1} { set SUT [lindex $fabric_sw_list 0]
if {[set_spawn_id $SUT]!= 0} { if {[telnet_switch $SUT]!= 0} { add_status "Switch: $SUT not available" 0 } } set lsfid [lindex $ls_list end] set ls_list [list $lsfid $bs_fid] set flag1 0 foreach ls $ls_list { setcontext_fid $lsfid clear_buffer set total_no_of_switches [llength $fabric_sw_list] set total_switches 0 set fabric_show [get_command "fabricshow"] regexp {The Fabric has ([0-9]+) switches} $fabric_show ignore total_switches if {$total_no_of_switches == $total_switches} { add_status "Fabric has come up fine in $ls" 3 } else { add_status "Fabric has not come up properly" incr flag1 } } } if {$flag1 == 0} { add_status "configuration for VF LF mode testing is available. Proceed with testing...." 3
} else { add_status "Fabric has not come up properly" add_info "Creating configuration for testing in VF LF mode" source /vobs/multisite/intgtest/inc/create_lf_fabric.inc } close_spawn_list end_telnet "exit" } else { add_info "Creating configuration for testing in VF LF mode" source /vobs/multisite/intgtest/inc/create_lf_fabric.inc } } } }
proc get_WWNbasedPID_status { } { set status "" set val "" send_command "configure" expect { -re "Fabric parameters" { exp_send "y\r" exp_continue } -re {WWN Based persistent PID[^\n]+} {
exp_send "\r" set val $expect_out(0,string) exp_continue } -re ":" { exp_send "\r" exp_continue } -re ">" { } } set res [regexp {WWN Based persistent PID \(yes, y, no, n\): \[([a-zA-Z]+)\]} $val ignore status] return $status }
proc get_wwnaddress_show_output {{area ""}} { set wwn_show_output "" set wwn_show_list "" set wwn_list "" set wwn_area_list "" set wwn_show_output [split [get_command "wwnaddress --show"] "\r\n"] foreach element $wwn_show_output { if {$element != ""} { lappend wwn_show_list $element }
} set end_val [expr [llength $wwn_show_list] - 3] set wwn_show_list [lrange $wwn_show_list 3 $end_val] foreach line $wwn_show_list { set line [compress_list $line] lappend wwn_list [lindex $line 1] lappend wwn_area_list [lindex $line 1],[lindex $line 2] } if {$area == ""} { return $wwn_list } else { return $wwn_area_list } }
proc get_wwn2BoundAreaMap_file_output {ip_address {fid 128} {file ""}} { set return_list "" if {[set_spawn_id $ip_address]!= 0} { if {[telnet_switch $ip_address]!= 0} { add_status "Switch: $ip_address not available" 1 } } if {$fid != "128"} { setcontext_fid $fid
clear_buffer } if {$file == ""} { set cmd_val "" do_command "cd /etc/fabos" set cmd_val [split [get_command "ls wwn2BoundAreaMap*"] "\r\n"] set file_list "" foreach line $cmd_val { if {$line != ""} { lappend file_list $line } } set req_file [lindex $file_list end-1] } else { set req_file $file } set file_output [lrange [split [get_command "cat $req_file"] "\r\n"] 1 end-1] set file_content "" foreach line $file_output { if {$line != ""} { lappend file_content $line } } set wwn_list "" foreach line $file_content {
set line [split $line "-"] lappend wwn_list [lindex $line 0] } return $wwn_list }
proc clear_wwn2BoundAreaMap_files { } { do_command "cd /etc/fabos" do_command "rm wwn2BoundAreaMap*" set status [get_command "ls wwn2BoundAreaMap*"] if {[regexp "No such file or directory" $status]} { add_status "All existing wwn2BoundAreaMap.* files have been deleted" 3 } else { add_status "wwn2BoundAreaMap file couldn't be deleted" 1 } }
proc verify_wwnaddress_cli { } { set cmd_list [list "wwnaddress" "wwnaddress --help"] set search_pattern_list [list "wwnAddress --bind" "wwnAddress --unbind" "wwnAddress --show" "wwnAddress --findPID" "wwnAddress --help"] foreach cmd $cmd_list { set cmd_output [get_command $cmd] set count 0 foreach pattern $search_pattern_list {
if {[regexp $pattern $cmd_output]} { incr count } } if {$count == [llength $search_pattern_list]} { add_status "Usage is shown properly for $cmd" 3 } else { add_status "Usage is not shown for $cmd" 1 } } }
proc get_device_wwn_list_byPortType { {type "F-Port"}} { set port_list [get_ports $type] array set wwn "" foreach port $port_list { set wwn_list [lrange [split [get_between "portshow $port" "portWwn of device" "Distance"] "\r\n"] 1 end] set wwn_list [compress_list $wwn_list] set wwn_list [trim_list_elements $wwn_list "\t"] array set wwn [list $port $wwn_list] } return [array get wwn] }
proc enable_wwnbasedpid {ip_address {fid 128} {mapfile ""}} {
if {[set_spawn_id $ip_address]!= 0} { if {[telnet_switch $ip_address]!= 0} { add_status "Switch: $ip_address not available" 1 } } if {$fid != "128"} { setcontext_fid $fid clear_buffer } set sw_type [get_after "switchshow" "switchType:"] if {([regexp {62|77} $sw_type] == 0) || ($fid != "128")} { if {$mapfile == ""} { clear_wwn2BoundAreaMap_files } clear_buffer set status [configure_items "WWN Based persistent PID" "yes"] clear_buffer if {$status == 1} { add_status "WWN based PID assignment enabled successfully" 3 } else { add_status "Error observed while enabling WWN based PID assignment" 1 } do_command "switchdisable" sleep 20 do_command "switchenable"
sleep 50 } }
proc convert_portList_to_range {port_list} { set return_list "" set temp_list1 "" set temp [lindex $port_list 0] set count 1 foreach val1 $port_list { set val2 [lindex $port_list $count] if {[expr $val2 - $val1] == 1} { lappend temp $val2 set flag 1 } else { set temp_list2 $temp set temp $val2 set flag 0 }
if {$flag == 0} { lappend temp_list1 $temp_list2 } incr count }
foreach element $temp_list1 { if {[llength $element] > 1} { set init [lindex $element 0] set final [lindex $element end] lappend return_list $init-$final } else { lappend return_list $element } } return $return_list }
proc get_area_portAddress_show {{port_no ""}} { if {$port_no != ""} { set flag 1 if {[regexp "/" $port_no]} { set port_temp [split $port_no "/"] set slot [lindex $port_temp 0] set port [lindex $port_temp 1] set port_flag 1 } else { set port $port_no set port_flag 0 } } else {
set flag 0 set sw_type [get_after "switchshow" "switchType:"] if {[regexp {62|77} $sw_type]} { set sw_flag 1 } else { set sw_flag 0 } } set port_address_list [make_matrix "portaddress --show" "============" ""] foreach line $port_address_list { set line [compress_list $line] if {$flag == 1} { if {$port_flag == 0} { if {[lindex [lindex $line 0] 1] == $port} { set area [lindex [lindex $line 0] 2] } } else { if {([lindex [lindex $line 0] 1] == $slot) && ([lindex [lindex $line 0] 2] == $port)} { set area [lindex [lindex $line 0] 3] } } } else { if {$sw_flag == 0} { lappend area [lindex [lindex $line 0] 2] } else {
lappend area [lindex [lindex $line 0] 3] } } } return $area }
proc disable_wwnbasedpid { } { clear_buffer set status [configure_items "WWN Based persistent PID" "no"] if {$status == 1} { add_status "WWN based persistent PID disabled successfully" 3 } else { add_status "Error observed while disabling WWN based persistent PID" 1 } do_command "switchdisable" sleep 20 do_command "switchenable" sleep 50 }
proc get_random_area { } { set return_value "" set vf_status [get_after "fosconfig --show" "Virtual Fabric: "] set area_list ""
if {[regexp {enabled|Enabled} $vf_status]} { set ls_list [get_logical_switch_fid] foreach ls $ls_list { setcontext_fid $ls clear_buffer append area_list " " [get_area_portAddress_show] } } else { set area_list [get_area_portAddress_show] }
while {1} { set temp [convert_to_hex [get_random_integer 144 255]] set area "0x[append temp 00]" if {[lsearch $area_list $area] == -1} { return $area } } }
proc get_mapfile_list { } { set temp "" set temp [lrange [compress_list [split [get_command "ls /etc/fabos/wwn2BoundAreaMap.*"] "\r\n"]] 1 end] set temp [compress_list [split [lindex $temp 0] " "]] if {[regexp "No such file or directory" $temp]} {
add_status "No wwn2BoundAreaMap files are present" set temp "" } return $temp }
proc get_port_portAddress_show {area} { set port "" set ls_list "" set sw_type [get_after "switchshow" "switchType:"] if {[regexp {62|77} $sw_type]} { set flag 1 } else { set flag 0 } set vf_status [get_after "fosconfig --show" "Virtual Fabric:"] if {[regexp {enabled|Enabled} $vf_status]} { set ls_list [get_logical_switch_fid] set flag1 1 } else { set ls_list "128" set flag1 0 }
foreach ls $ls_list {
if {$flag1 == 1} { if {[regexp "128" $ls]} { set ls 128 } setcontext_fid $ls clear_buffer } set port_address_list [make_matrix "portaddress --show" "============" ""] foreach line $port_address_list { #set line [compress_list $line] if {$flag == 1} { if {[lindex [lindex $line 0] 3] == $area} { set port [lindex [lindex $line 0] 1]/[lindex [lindex $line 0] 2] return $port } } else { if {[lindex [lindex $line 0] 2] == $area} { set port [lindex [lindex $line 0] 1] return $port } } } } }
proc check_area_range { } { set sw_type [string range [trim_string [get_after "switchshow" "switchType:"]] 0 1] set switch_port_count [list 64 80 66 40 71 24] set sw_index [lsearch $switch_port_count $sw_type] set port_count [lindex $switch_port_count [expr $sw_index + 1]] set generated_area_list "" for {set i 0} {$i < $port_count} {incr i} { set temp "" set area "" set temp [convert_to_hex $i] if {[llength [split $temp ""]] == 1} { set temp 0$temp } set area "0x[append temp 00]" lappend generated_area_list $area } add_status "generated_area_list : $generated_area_list"
set actual_area_list "" set vf_status [get_after "fosconfig --show" "Virtual Fabric:"] add_status "vf_status : $vf_status" if {[regexp {enabled|Enabled} $vf_status]} { set ls_list [get_logical_switch_fid] foreach ls $ls_list {
if {[regexp 128 $ls]} { set ls 128 } setcontext_fid $ls clear_buffer set temp [get_area_portAddress_show] add_status "temp : $temp" append actual_area_list " " $temp } set ls_flag 1 } else { set ls_flag 0 set actual_area_list [get_area_portAddress_show] } add_status "actual_area_list : $actual_area_list" add_status "[get_list_disjoint $generated_area_list $actual_area_list]" if {[get_list_disjoint $generated_area_list $actual_area_list] != "" } { add_status "Some area in the switch is beyond MAX_PHY_PORTS" add_status "Unbind that area and bind a new area within the valid range" set diff_actual_list [get_list_opposite_of_intersection $generated_area_list $actual_area_list] set diff_generated_list [get_list_opposite_of_intersection $actual_area_list $generated_area_list] set port_list "" foreach val1 $diff_actual_list val2 $diff_generated_list { set port [get_port_portAddress_show $val1]
add_status "port : $port" if {$ls_flag != 0} { array set arr "" parse_lscfgshow arr set fid $arr($port) if {[regexp "128" $fid]} { set fid 128 } setcontext_fid $fid clear_buffer } do_command "portdisable $port" do_command "portaddress --unbind $port $val1" do_command "portaddress --bind $port $val2" } } else { add_status "All assigned areas are within the valid range (less than MAX_PHY_PORTS)" } } ########################################################### # windows settings #----------------------------------------------------------------# win_init - create a telnet session with Windows host # inputs:
windb - array where windows data will be stored
#
host - hostname or IP addr of Windows host
# outputs:
returns 0 if success
#
windb - loaded with windows data
#----------------------------------------------------------------proc win_init { windb index host } { global winuser global winpassword global winprompt global cl_host_user cl_host_password cl_win_prompt upvar $windb win
set win($index,host) $host if {[info exists winuser]} { set win($index,user) $winuser } else { set win($index,user) "$cl_host_user" } if {[info exists winpassword]} { set win($index,password) $winpassword } else { set win($index,password) "$cl_host_password" } if {[info exists winprompt]} { set win($index,prompt) $winprompt } else { set win($index,prompt) "$cl_win_prompt"
}
set win($index,retry) 3 set win($index,id) 0 set win($index,rc) 0 set win($index,cmd) "" set win($index,out) {} set win($index,targets) {} set win($index,targetportals) {}
win_goto_prompt win $index
return $win($index,rc) }
#----------------------------------------------------------------# win_close - close a telnet session with Windows host # inputs:
windb - win data created by win_init
# outputs:
returns nothing, telnet session is closed
#----------------------------------------------------------------proc win_close { windb index } { upvar $windb win
if {$win($index,id) != 0} { catch {
close -i $win($index,id) wait -i $win($index,id) } junk set win($index,id) 0 } set win($index,rc) 0 set win($index,out) {} }
#----------------------------------------------------------------# win_login - login to win host # inputs:
windb - win data created by win_init
# outputs:
returns 0 if success
#----------------------------------------------------------------proc win_login { windb index } { add_status "Entering login proc" global ctrl_c
upvar $windb win set rc -1 set retry $win($index,retry) set loginstate 0
if {$win($index,id) != 0} { win_close win $index
} set timeout 300 #
puts "login: telnet $linux(host)\n"
#spawn telnet $win($index,host) spawn sh -c "TERM=tty;export TERM;telnet $win($index,host)" set win($index,id) $spawn_id
while {$retry > 0} { expect { -re "\[^ \]login:" { catch {puts stderr "login: Got login prompt - send $win($index,user)\n"} send "$win($index,user)\r" exp_continue }
"password:" { if { $loginstate == 0 } { catch {puts stderr "login: Got password prompt $loginstate - send $win($index,password)\n"} send "$win($index,password)\r" incr loginstate } exp_continue }
-re "Connection closed" { catch {puts stderr "login: Connection closed by $win($index,host)\n"} set $win($index,id) 0 win_login win $index break }
-re "$win($index,prompt)" { catch {puts stderr "login: Got win prompt $loginstate done\n"} set rc 0 break exp_continue }
eof { catch {puts stderr "login: Got EOF - can't telnet to $win($index,host)\n"} win_close win $index set rc 1 break }
timeout { catch {puts stderr "login: Got timeout - failed to login\n"}
send "$ctrl_c\r" set rc 2 break } } incr retry -1 puts stderr "login: retry = $retry\n" } #
stty raw -echo
set win($index,rc) $rc return $rc }
#----------------------------------------------------------------# win_goto_prompt - make sure we are at win prompt, this func #
needs more work as required
# inputs:
windb - win data created by win_init
# outputs:
returns 0 if success
#----------------------------------------------------------------proc win_goto_prompt { windb index } { global ctrl_c
upvar $windb win set rc -1
set retry $win($index,retry)
#
puts stderr "goto: win = $win(host)\n" if { $win($index,id) == 0 } { win_login win $index } set spawn_id $win($index,id)
#
puts stderr "goto: checking $win(host)\n"
expect *
while {$retry > 0} { send "\r"
expect { -re "\[^ \]login:" { #
puts stderr "prompt: Got login prompt - need to login first\n" set rc [win_login win $index] break }
-re "$win($index,prompt)" { #
puts stderr "prompt: Got win prompt - done\n" set rc 0
break }
-re "Connection closed" { puts stderr "login: Connection closed by $win($index,host)\n" set $win($index,id) 0 win_login win $index exp_continue }
eof { #
puts stderr "prompt: Got EOF - disconnected\n" win_close win $index set rc [win_login win $index] break }
timeout { #
puts stderr "prompt: Got timeout - try again\n" send "$ctrl_c\r" } } incr retry -1 }
expect *
set win($index,rc) $rc return $rc }
#----------------------------------------------------------------# win_cmd - execute a command and return output # inputs:
windb - windows data created by win_init
#
cmd - command string
# outputs:
returns list containing output for command
#----------------------------------------------------------------proc win_cmd { windb index cmd {change_prompt 0} {prompt ""}} { upvar $windb win
global timeout
set rc -1 set buf "" set lines {} set done 0 set oldtimeout $timeout set timeout 30
set rc [win_goto_prompt win $index]
set spawn_id $win($index,id) set retry $win($index,retry) if {$change_prompt} { set win($index,prompt) "$prompt" add_status "Changed prompt as $prompt" }
if { $rc != 0 } { set timeout $oldtimeout return {} }
#
puts stderr "cmd: Sending command: $cmd\n" send "$cmd\r\n" while {$retry > 0} { expect {
#
-re "$win($index,prompt).*$cmd" {
#
puts stderr "cmd: Got cmd echo - continue\n"
#
exp_continue
#
}
-re "$win($index,prompt)" { #
puts stderr "cmd: Got win prompt - done\n" set rc 0
#
puts stderr "cmd: flushing"
set done 1 set timeout 3 append buf "$expect_out(buffer)" # break exp_continue }
-re "--More--" { #
puts stderr "cmd: Got more prompt - press enter\n" append buf "$expect_out(buffer)" send "\r\n" exp_continue } eof {
#
puts stderr "cmd: Got EOF - disconnected\n" win_close win $index set rc 1 break } full_buffer { append buf "$expect_out(buffer)" exp_continue } timeout { if {$done == 1} {
break } puts stderr "cmd: Exceeded timeout value. Exiting the procedure without receiving prompt" set rc 1 append buf "$expect_out(buffer)" }
-re ".+" { #
puts stderr "cmd: Got more lines - keep reading\n" append buf "$expect_out(buffer)" exp_continue } } incr retry -1
#
puts stderr "cmd: retry = $retry\n" }
#NM: Why appending twice?? #append buf "$expect_out(buffer)" regsub -all "\033\\\[\[0-9\]+;\[0-9\]+(\[A-Z\]|\[a-z\])" $buf "\n" tmp1 regsub -all "\015" $tmp1 "\n" tmp2 regsub -all "\010 \010" $tmp2 "\n" tmp1 regsub -all -- "--More--" $tmp1 "\n" tmp2 regsub -all ", next page: Space, next line: Return key, quit: Control-c" $tmp2 "\n" tmp1
set timeout $oldtimeout foreach line [split $tmp1 "\n"] { if { ![regexp "\^\[\t\\ \]*\$" $line junk]} { lappend lines [string trim $line] # TOM1: keep newline lappend lines [string trim $line "\t\ "] #
puts stderr "cmd: dbg: $line\n" } } set win($index,out) $lines return $lines
}
proc winhost_inquiry { winhost } {
set numdestdrives 0 set rc 0
add_status "Telnet to windows host $winhost" if {[win_init winpc 1 $winhost] != 0} { add_status "Telnet to windows host $winhost failed" 1 set rc -1 return $rc }
win_cmd winpc 1 "cd C:\\copa"
set winpc(1,out) {}
## List the drives win_cmd winpc 1 "inq.wnt"
add_status "Getting the number of drives on windows host" foreach line $winpc(1,out) { set line [string trim $line] if [regexp -nocase {^.*PHYSICALDRIVE(.*).*:SEAGATE.*} $line junk drivenum] { #Assumes **ONE** internal scsi drive. Ignore this drive. if { $drivenum == 0 } { continue } incr numdestdrives } }
add_status "Found $numdestdrives device on windows host" win_close winpc 1 return $numdestdrives }
#----------------------------------------------------------------# enable_bcu_port - To enable a given bcu port # inputs: port - Port number to be enabled in host
# outputs: 1 : Success #
-1 : Failure
#----------------------------------------------------------------proc enable_bcu_port {port} { global winuser winpassword winprompt winip set index 1 win_init win1 $index $winip set spawn_id $win1($index,id) set output [win_cmd win1 $index "bcu port --enable $port"] if {[regexp {port enabled} $output] ==1} { return 1 } else { return -1 } win_close win1 $index }
#----------------------------------------------------------------# disable_bcu_port - To disable a given bcu port # inputs: port - Port number to be disabled in host # outputs: 1 : Success #
-1 : Failure
#----------------------------------------------------------------proc disable_bcu_port {port} { global winuser winpassword winprompt winip
set index 1 win_init win1 $index $winip set spawn_id $win1($index,id) set output [win_cmd win1 $index "bcu port --disable $port"] if {[regexp {port disabled} $output] ==1} { return 1 } else { return -1 } win_close win1 $index }
#----------------------------------------------------------------# get_bcu_port - To get the bcu port number of a given wwn # inputs: wwn - wwn of the device connected # outputs: port : Port number of the given wwn #
-1 : WWN not found in bcu port list
#----------------------------------------------------------------proc get_bcu_port {wwn} { global winuser winpassword winprompt winip set index 1 win_init win1 $index $winip set spawn_id $win1($index,id) set output [win_cmd win1 $index "bcu port --list"] set port ""
foreach line $output { if {[regexp "(.*?)\[ \t]+(.*)\[ \t]+(.*)\[ \t]+$wwn.*Linkup" $line match port ig ig1 ig2] ==1 && $port!= ""} { break } } win_close win1 $index if {$port == ""} { return -1 } else { return $port } }
proc online_disk {host_ip} { global winuser global winpc_user global cl_ip_address_list win_init win1 1 $host_ip win_cmd win1 1 "diskpart" win_cmd win1 1 "rescan" set oput [win_cmd win1 1 "list disk"] #set oput [split [win_cmd win1 1 "list disk"] "\r\n"] foreach line $oput { set num "" regexp -nocase {(Disk\s+\d+).*offline} $line ig num
add_status "Line: $line Disk: $num" if { $num != "" } { win_cmd win1 1 "select $num" win_cmd win1 1 "online disk" } } sleep 20 win_cmd win1 1 "list disk" win_close win1 1 } ############################################## #! /bin/sh
proc enable_vf_no_check {} {
if {[is_vf_enabled] != 0} { exp_send "fosconfig --enable vf\r" log_test_command_ "fosconfig --enable vf" expect { "]:" { exp_send "y\r" } timeout { add_status "timed out $timeout seconds waiting for affirmation of enabling vf" 0 } }
sleep 15 end_telnet "exit" return 0 } else { return 1 }
}
############################################################################## ###### ## NAME ##
return_current_ls
## ## SYNOPSIS ##
returns the current LS you are in
## ## ## DESCRIPTION ##
returns the current LS you are in
## ## OPERANDS ##
none
## ## DEPENDENCIES
## ## ## RETURN ##
-1 no current LS found after parsing switchshow
##
ls_num the number of the logical switch
## ## USAGE ## return_current_ls ## ############################################################################## ##### proc return_current_ls {} { set stuff [get_command "switchshow"] set lines [split $stuff "\n"] set lsnum -1 foreach line $lines { if {[string first "LS Attributes" $line] >= 0} { regexp "FID:\[ \t]*(\[0-9]+)," $line ignore lsnum
} } return $lsnum }
############################################################################## ###### ## NAME ##
verify_vf_enabled
## ## SYNOPSIS ##
verifies if VF is enabled
## ## ## DESCRIPTION ##
verifies if VF is enabled
## ## OPERANDS ##
none
## ## DEPENDENCIES ## ## ## RETURN ##
0 not enabled
##
1 enabled
## ## USAGE ## verify_vf_enabled ## ##############################################################################
##### proc verify_vf_enabled {} { if {[trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] == "enabled"} { add_status "vf is enabled" 3 return 1 } else { add_status "vf is not enabled" 3 return 0 } }
############################################################################## ###### ## NAME ##
create_logical_switch
## ## SYNOPSIS ## creates logical switch at $fid, will retry command until it successfully completes unless it times out in 200 seconds ## this is because creation of logical switch can commonly be stalled due to FOS with the "system is not ready" response ## ## ## DESCRIPTION ##
creates logical switch without having to worry about command being accepted
## ## OPERANDS
##
the fid number
## ## DEPENDENCIES ## ## ## RETURN ##
0 failed because maximum number of switches created
##
1 passed, logical switch at $fid created
##
-1 failed, timed out, 10 tries with 20 seconds wait each
## USAGE ## create_logical_switch 29 ## ############################################################################## ##### proc create_logical_switch {fid {wait_time "180"}} { set times 0 #v7.3.0v7.3.0_pit_a_131121_1700 set version [join [lrange [regexp -inline {([0-9])\.([0-9])\.*} [get_version]] 1 end] "" ] add_status "$version : [get_version]" if { $version < "72" } { set cmd [get_command_no_wait "lscfg --create $fid" $wait_time] } else { set cmd [get_command_no_wait "lscfg --create $fid -force" $wait_time] }
while {[string first "system is not ready" $cmd] >= 0} {
sleep 20 if { $version < "72" } { set cmd [get_command_no_wait "lscfg --create $fid" $wait_time] } else { set cmd [get_command_no_wait "lscfg --create $fid -force " $wait_time] } incr times if {$times >= 10} { add_status "tried 10 times to create logical switch at $fid, but system is not ready, quitting" 1 return -1 } } if {[string first "maximum number of switches" $cmd] >= 0} { return 0 } else { return 1 } }
############################################################################## ###### ## NAME ## delete_logical_switch ## ## SYNOPSIS
## deletes logical switch at $fid, will retry command until it successfully completes unless it times out in 200 seconds ## this is because creation of logical switch can commonly be stalled due to FOS with the "system is not ready" response ## ## ## DESCRIPTION ##
deletes logical switch without having to worry about command being accepted
## ## OPERANDS ##
the fid number
## ## DEPENDENCIES ## ## ## RETURN ## ##
1 passed, logical switch at $fid created
##
-1 failed, timed out, 10 tries with 20 seconds wait each
## ## USAGE ## delete_logical_switch 29 ## ############################################################################## ##### proc delete_logical_switch {fid} { set times 0
set wait_time 120 set version [join [lrange [regexp -inline {([0-9])\.([0-9])\.*} [get_version]] 1 end] "" ] if { $version < "72" } { set cmd [get_command_no_wait "lscfg --delete $fid" $wait_time] } else { set cmd [get_command_no_wait "lscfg --delete $fid -force" $wait_time] } while {[string first "system is not ready" $cmd] >= 0} { sleep 20 if { $version < "72" } { set cmd [get_command_no_wait "lscfg --delete $fid" $wait_time] } else { set cmd [get_command_no_wait "lscfg --delete $fid -force" $wait_time] } incr times if {$times >= 10} { add_status "tried 10 times to delete logical switch at $fid, but system is not ready, quitting" 1 return -1 } } if {[string first "Unable to delete" $cmd] >=0 } { add_status "switch complaining about logical switch $fid having ports even though it does not. unable to delete, quitting" 1 return -1 }
return 1 }
############################################################################## ###### ## NAME ##
create_base_switch
## ## SYNOPSIS ## creates base switch at $fid, will retry command until it successfully completes unless it times out in 200 seconds ## this is because creation of logical switch can commonly be stalled due to FOS with the "system is not ready" response ## ## ## DESCRIPTION ##
creates base switch without having to worry about command being accepted
## ## OPERANDS ##
the fid number
## ## DEPENDENCIES ##
## ## RETURN ##
0 failed because maximum number of switches created
##
1 passed, base switch at $fid created
##
-1 timed out, 10 tries at 20 seconds wait each
## ## USAGE ## create_base_switch 29 ## ############################################################################## ##### proc create_base_switch {fid} { set wait_time 240 set times 0 set cmd [get_command_no_wait "lscfg --create $fid -b -f" $wait_time] while {[string first "system is not ready" $cmd] >= 0} { sleep 20 set cmd [get_command_no_wait "lscfg --create $fid -b -f" $wait_time] incr times if {$times >= 10} { add_status "tried 10 times to create base switch at $fid, but system is not ready, quitting" 1 return -1 } } if {[string first "maximum number of switches" $cmd] >= 0} {
return 0 } else { return 1 }
}
############################################################################## ###### ## NAME ##
enable_virtual_fabric
## ## SYNOPSIS ##
enables virtual fabric feature on the switch, requires a complete reboot
## ## ## DESCRIPTION ## enables virtual fabric feature on the switch and after a complete reboot will log back into the original spawns that existed when this routine was called ## ## OPERANDS ##
optional wait time for reboot to finish, recommended default is 250 seconds
## ## DEPENDENCIES ##
get_switch_platform
## ## RETURN ##
1: succeeded in enabling virtual fabric
##
0: no need to enable
##
-1: failed
## ## USAGE ## enable_virtual_fabric ## ############################################################################## ##### proc enable_virtual_fabric { {wait_time 250} } { set SUT [trim_string [get_after "ipaddrshow" "Ethernet IP Address:"]] add_status "The IP of the SUT is: $SUT" 3 set platform [get_switch_platform] if {[check_firmware_version] >= 62} { add_status "Virtual Fabric is supported in this Loaded FOS" 3 #set switchType [parse_real [get_after "switchShow" "switchType:"]] #set switchType [parse_integer $switchType strict] if {[check_vf_capable_platform] == 1} { add_status "Verifying VF is enabled/disabled" 3 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]]
if {$vf_status == "enabled"} { add_status "VF is already enabled" 3 return 0 } else { slot_switch_validation add_status "Enabling the VF mode" 3 send_command "fosconfig --enable vf" expect { "\\\[Y/N]:" { exp_send "y\r" } timeout { add_status "timed out waiting for Y/N prompt after fosconfig enable vf" 2 return -1 } } sleep 60 end_telnet sleep 360 end_telnet if {[telnet_switch $SUT] != 0} { add_status "Switch not available" 0 return -1 } else { if {($platform >= 12000)} {
set xyzabc 0 while {[cause "hashow" "HA State not in sync" 5 wait] == 0} { incr xyzabc sleep 30 add_status "HA State still not in sync after Enabling VF, retrying" 3 if {$xyzabc == 10} { add_status "HA State not in sync after waiting for 5 minutes" 1 break } } } slot_switch_validation add_status "Checking VF is enabled properly" 3 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] add_status "value of vf is $vf_status" 3 if {$vf_status == "enabled"} { add_status "VF enabled successfully" 3 return 1 } else { add_status "Issues Observed while enabling VF" 1 return -1 }
} } } else { add_status "Platform doesn't support VF" 3 return 0 } } else { add_status "Virtual Fabric is not supported in this loaded FOS" 3 return 0 } }
#Bob:root> lscfg --show #Created switches: 128 2 #Slot
1
2
3
4
5
6
7
8
9 10 11 12
#------------------------------------------------------------------------------#Port # 0 | 128 |
|
| 128 | 128 |
|
| 128 |
| 128 |
| 128 |
# 1 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 2 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 3 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 4 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 5 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 6 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 7 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 8 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
# 9 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#10 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#11 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#12 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#13 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#14 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#15 | 128 |
|
| 128 | 128 |
|
| 2|
| 128 |
| 128 |
#16 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#17 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#18 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#19 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#20 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#21 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#22 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#23 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#24 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#25 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#26 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#27 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#28 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#29 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#30 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#31 | 2 |
|
|
| 128 |
|
| 2|
| 2|
| 2|
#32 |
|
|
|
|
|
|
|
|
|
|
| 2|
#33 |
|
|
|
|
|
|
|
|
|
|
| 2|
#34 |
|
|
|
|
|
|
|
|
|
|
| 2|
#35 |
|
|
|
|
|
|
|
|
|
|
| 2|
#36 |
|
|
|
|
|
|
|
|
|
|
| 2|
#37 |
|
|
|
|
|
|
|
|
|
|
| 2|
#38 |
|
|
|
|
|
|
|
|
|
|
| 2|
#39 |
|
|
|
|
|
|
|
|
|
|
| 2|
#40 |
|
|
|
|
|
|
|
|
|
|
| 2|
#41 |
|
|
|
|
|
|
|
|
|
|
| 2|
#42 |
|
|
|
|
|
|
|
|
|
|
| 2|
#43 |
|
|
|
|
|
|
|
|
|
|
| 2|
#44 |
|
|
|
|
|
|
|
|
|
|
| 2|
#45 |
|
|
|
|
|
|
|
|
|
|
| 2|
#46 |
|
|
|
|
|
|
|
|
|
|
| 2|
#47 |
|
|
|
|
|
|
|
|
|
|
| 2|
############################################################################## ###### ## NAME ## parse_lscfgshow ## ## SYNOPSIS ## parse_lscfgshow ##
## DESCRIPTION ##
Routine will parse lscfg --show, which assosciates every port on the switch
##
to a logical switch FID (fabric ID). The default logical switch FID is 128.
## ## OPERANDS ##
none
## ## DEPENDENCIES ##
none
## ## RETURN ##
-1 if error occurred
## ##
mtx(x/y) assosciative array is returned, visually
##
represented below
## ##
1 2 3 4 5 6 7 8 9 10 11 12
##
15 128 0 0 128 128 0 0 2 0 128 0 128
##
16 2 0 0 0 128 0 0 2 0 2 0 2
##
17 2 0 0 0 128 0 0 2 0 2 0 2
## ##
the X axis corresponds to the slot number
##
the Y axis corresponds to the port number
##
the value is the FID the port X/Y belongs to.
##
##
For example, if you want port 1/5 (slot 1, port 5) simply use
##
==> $mtx(1/5)
## ##
Make sure that the string between the ()'s contains no spaces
##
as this is a simiulated matrix using assosciative arrays.
## ##
For example
##
==> $mtx(1/5) NOT EQUAL TO $mtx (1 /5)
## ## ## USAGE ##
parse_lscfgshow
## ############################################################################## ##### proc parse_lscfgshow {array} { upvar $array mtx #make sure VF is enabled set output [split [get_command "lscfg --show"] "\r\n"] if {[string first "requires VF to be enabled" $output] >= 0} { add_status "Virtual Fabric is not enabled and therefore there are no partitions from lscfg --show" 1 return 0 } elseif {[string first "command not found" $output] >= 0} { add_status "Command not found, probably not an Orion or later build" 1 return 0
} set ten 0
set col 0 set row 0
set chassis "no" foreach line $output { if {[string first "Slot" $line] >= 0} { set num_slots [expr [llength $line] -1] set chassis "yes" } if {$chassis == "yes"} { if {$num_slots == 8} { set found [regexp "^ *\[0-9 ]+\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ] +)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+).*$" $line ignore clm1 clm2 clm3 clm4 clm5 clm6 clm7 clm8] } else { set found [regexp "^ *\[0-9 ]+\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ] +)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+)\\|(\[0-9 ]+).*$" $line ignore clm1 clm2 clm3 clm4 clm5 clm6 clm7 clm8 clm9 clm10 clm11 clm12] } if {$found == 1} { set col 1 for {set i 1} {$i <= $num_slots} {incr i} { set var clm$i if {[parse_integer [set $var]] == 0} {
set mtx($col/$row) -1 } else { set mtx($col/$row) [parse_integer [set $var]] }
incr col } incr row }
} else {
#Created switches: 128(ds) 10 20(bs) 30
#Port
0
1
2
3
4
5
6
7
8
9
#------------------------------------------------------------------#FID
10 | 128 | 128 | 128 | 128 | 128 | 128 | 128 | 128 | 128 |
#Port
10 11 12 13 14 15 16 17 18 19
#------------------------------------------------------------------#FID
128 | 128 | 128 | 128 | 128 | 128 | 128 | 128 | 128 | 128 |
if {[regexp "^FID\[ \t]+(\[0-9 ]+)\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ] +)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?\\|?(\[0-9 ]+)?.*$" $line ignore x0
x1 x2 x3 x4 x5 x6 x7 x8 x9] == 1} { for {set i 0} {$i < 10} {incr i} { set var x$i set index [expr $i + $ten] if {[parse_integer [set $var]] == 0} { set mtx($index) -1 } else { set mtx($index) [parse_integer [set $var]] } if {$i == 9} { set ten [expr $ten + 10] } }
}
}
}
} ########################################################################### ## NAME ## ##
clear_zonecfg - disables and clears the zone configuration
## SYNOPSIS ##
clear_zonecfg
## ## DESCRIPTION ##
This procedure disables and clears all the zone confiuration
## ## OPERANDS ## NONE ## ## DEPENDENCIES ## NONE ## ## RETURN ## NONE ## ## USAGE ##
clear_zonecfg
## ############################################################################# proc clear_zonecfg {} { while {1} { set zone_cfg [get_command "cfgshow"] set result [regexp -nocase {(.*)busy(.*)} $zone_cfg -] if {$result} { sleep 20
} else { break } } set result [regexp {([a-z0-9][a-z0-9]:)+([a-z0-9][a-z0-9])} $zone_cfg -] if {$result} { do_command "cfgshow" retry_command "cfgdisable" retry_command "cfgclear" sleep 10 retry_command "cfgsave" do_command "cfgshow" add_status "Wait for switch to stabilize" 3 sleep 30 } }
proc setcontext_mercury {ls_fid} { global cl_ip_address_list set sut [lindex $cl_ip_address_list 0] global cl_PROMPT if {$ls_fid == 128} { set cmd "setcontext chassis" send_command "setcontext fcsw 128"
} else { set cmd "setcontext fcsw $ls_fid" send_command "setcontext fcsw $ls_fid" } expect { "Use Control-C to exit" { sleep 3 exp_send "\003" expect { -re ".*>.*" { if {[string first "Please logout" $expect_out(buffer)] >= 0} { add_status "$cmd command failed, working around by using logout and re-telnet" 1 end_telnet "logout" telnet_switch $sut } else { add_status "setcontext command succeeded, no need to use logout" 3 } } } } }
clear_buffer }
########################################################################### ## NAME ## ## setcontext_fid :will set the context of a particular ls ## ## SYNOPSIS ## setcontext_fid $ls_fid ## ## DESCRIPTION ## This procudure will set the context of the fid which you will pass it as argument ## ## OPERANDS ## Fabric id of the ls of which you want to set the context ## ## DEPENDENCIES ## NONE ## ## RETURN ## NONE ## ## USAGE ##
setcontext_fid $ls_fid
## ############################################################################# proc setcontext_fid {ls_fid} {
add_status "inside setcontext in virtual_switch_fabric.lib" 3 set timeout 60 global cl_PROMPT send_command "setcontext $ls_fid" expect { "Use Control-C to exit" { sleep 3 exp_send "\003" wait_for "until password is changed." } "ethsw" { setcontext_mercury $ls_fid } -re "$cl_PROMPT" { add_status "prompt received, no password change required" 3 } "requires VF to be enabled" { add_status "FOS responded that it \"requires VF to be enabled\" while issuing setcontext $ls_fid" 2 } timeout { add_status "setcontext $ls_fid command timed out, aborting" 2 } } clear_buffer }
############################################################################## ###### ## NAME
##
delete_all_ls
## ## SYNOPSIS ##
Deletes all the LS's in the SUT
## ## ## DESCRIPTION ##
a)Moves all the ports in all the LS's including BS(Base switch) to DS(Default switch)
##
b)Deletes all the LS's and BS if all the ports are successfully moved to DS from
##
that LS instance
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
NONE
## ## RETURN ## 0: Failed to delete all LS's ## 1: Successful deletion of all the LS's ## ## ## USAGE ## delete_all_ls ##
############################################################################## ##### proc delete_all_ls {} { add_status "You are in delete all ls procedure" 3 global timeout set f_port_trunking_status 0 set return_type 1 set ls_fids "" set ds_fid "" set other_ls_fids "" global cl_PROMPT if {[check_firmware_version] >= 62} { add_status "Virtual Fabric is supported in this Loaded FOS" 3 #set switchType [parse_real [get_after "switchShow" "switchType:"]] #set switchType [parse_integer $switchType strict] if {[check_vf_capable_platform] == 1} { add_status "Verifying VF is enabled/disabled" 3 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] if {$vf_status == "disabled"} { add_status "VF is already disabled" 3 } else { set ls_fids [trim_string [get_after "lscfg --show" "Created switches.*:"]] foreach fids $ls_fids { set str [regexp {\(.+?\)} $fids match] if {$str == 1 && $match == "(ds)"} { regexp {\d+} $fids ds_fid
#set ds_fid [string trimright $fids $match] } elseif {$str == 1 && $match == "(bs)"} { regexp {\d+} $fids match set other_ls_fids [linsert $other_ls_fids 0 $match] #set other_ls_fids [linsert $other_ls_fids 0 [string trimright $fids $match]] } elseif {$str == 1} { regexp {\d+} $fids match lappend other_ls_fids $match #lappend other_ls_fids [string trimright $fids $match] } else { lappend other_ls_fids $fids } } set ls_fids_len [llength $ls_fids] add_status "The total LS's are:$ls_fids; Of which DS is:$ds_fid and LS's are: $other_ls_fids" 3 if {$ls_fids_len > 1} { foreach fid $other_ls_fids { add_status "Switching to LS $fid" 3 setcontext_fid $fid sleep 10 set switchshow_output [get_command "switchshow"] set switchshow_info [split $switchshow_output "\n"] foreach line $switchshow_info { set ge_port ""
if {[regexp "\[x\]*ge\[0-9\]" $line ge_port] == 1} { set slot_num [string trim [lindex $line 0]] do_command "lscfg --config $ds_fid -slot $slot_num -port $ge_port -f" } } if {[cause "porttrunkarea --show enabled" "No ports have Trunk Area enabled"] != 0} { set f_port_trunking_status 1 do_command "switchshow" add_status "Disabling f-port trunking before moving the ports; ($f_port_trunking_status)" 3 set slot_port "" #set switchType [parse_integer [parse_real [get_after "switchShow" "switchType:"]] strict] set fport_trunk_list [split [get_command "porttrunkarea --show enabled"] "\n"] if {[get_switch_platform] > 12000} { foreach fport_list $fport_trunk_list { set port_type [trim_string [lindex $fport_list 2]] if {$port_type == "F-port" || $port_type == "--"} { set slot [lindex $fport_list 0] set port [lindex $fport_list 1] lappend slot_port "$slot/$port" set area [lindex $fport_list 5] } } } else { foreach fport_list $fport_trunk_list {
set port_type [trim_string [lindex $fport_list 1]] if {$port_type == "F-port" || $port_type == "--"} { lappend slot_port [lindex $fport_list 0] set area [lindex $fport_list 4] } } } add_status "the trunking info is:- area= $area; Port list is= $slot_port" 3 do_command "switchdisable" sleep 10 do_command "porttrunkarea --disable all" sleep 10 do_command "switchenable" sleep 30 } else { add_status "No trunking links were found hence continuing" 3 } set ports_info_before "" set ports_info_before [get_ports_info] add_status "The ports information is:\n $ports_info_before" 3 set ports_info_before_len [llength $ports_info_before] set list_of_ports "" set port1 "" set port "" if {$ports_info_before_len!= 0 && [regexp "No ports found in the system!!!" $ports_info_before] != 1} {
if {[check_ha_capable_platform] == 0} { foreach port1 $ports_info_before { lappend list_of_ports [lindex $port1 1] } add_status "The list of ports in LS($fid) are:$list_of_ports" 3 set list_of_ports [convert_portList_to_range [lsort -integer $list_of_ports]] foreach port $list_of_ports { send_command "lscfg --config $ds_fid -port $port" expect { "\\\[y/n]?:" { exp_send "y\r" wait_for "Please enable your ports/switch when you are ready to continue." #
exp_continue }
#
-re "$cl_PROMPT" {
#
} timeout { add_status "Command Timed out($timeout)" 2 } } } } elseif {[get_switch_platform] > 12000} { set slots [list] foreach port1 $ports_info_before { set slot [lindex $port1 1]
set port [lindex $port1 2] if {[regexp {^[0-9]+$} $port]} { lappend slots slot_$slot lappend slot_$slot $port } }
set slots [lsort -unique $slots] foreach sl $slots { set portrange [convert_portList_to_range [lsort -integer [set $sl]]] set slot [lindex [split $sl "_"] 1] add_status "Port range - $portrange for slot $slot" foreach port $portrange { send_command "lscfg --config $ds_fid -slot $slot -port $port" expect { "\\\[y/n]?:" { exp_send "y\r" wait_for "Please enable your ports/switch when you are ready to continue." #
exp_continue }
#
-re "$cl_PROMPT" {
#
} timeout { add_status "Command Timed out($timeout)" 2 }
} } unset $sl } } } setcontext_fid $ds_fid setcontext_fid $ds_fid add_status "Deleting LS with fid $fid" 3 set version [join [lrange [regexp -inline {([0-9])\.([0-9])\.*} [get_version]] 1 end] "" ] if { $version < "72" } { send_command "lscfg --delete $fid" } else { send_command "lscfg --delete $fid -force" } if {[wait_for "Switch successfully deleted." 200] == 0} { add_status "Successfully deleted LS($fid)" 3 } else { add_status "Failed to delete LS($fid) in given time" 1 } } add_status "checking for the successful deletion of LSwitches" 3 sleep 20 set ls_fids_after [trim_string [get_after "lscfg --show" "Created switches.*:"]] set ls_fids_after_len [llength $ls_fids_after]
add_status "The LS after deletion are: $ls_fids_after; length: $ls_fids_after_len" 3 if {$ls_fids_after_len == 1} { add_status "All the LS's are successfully deleted" 3 set return_type 1 } else { add_status "The LS's [lrange $ls_fids_after 1 end] failed to be deleted" 1 set return_type 0 } ################################### # Reconfiguring the f-port truking ################################### if {$f_port_trunking_status == 1} { add_status "Reconfiguring the f-port trunking after deleting all the LS" 3 do_command "switchcfgtrunk 1" do_command "switchdisable" sleep 10 if {[check_ha_capable_platform] == 0} { foreach fport $slot_port { do_command "porttrunkarea --enable $fport -area $area" } } else { foreach fport $slot_port { do_command "porttrunkarea --enable $fport -index $area" } }
} else { add_status "No f-port trunking was enabled hence did not reconfigure" 3 do_command "switchdisable" sleep 10 } do_command "switchenable" sleep 30 if {[verify_command "switchShow" "(unconfirmed)" 20] == 0} { add_status "Switch still coming up" 3 } if {[cause "porttrunkarea --show enabled" "No ports have Trunk Area enabled"] == 0 && $f_port_trunking_status == 1} { add_status "Failed to reconfigure F-port trunking" 1 } elseif {$f_port_trunking_status == 0} { add_status "F-port trunking was not enabled initially itself" 3 } else { add_status "F-port trunking is reconfigured successfully" 3 } } else { add_status "There are no LS's created; could find only $ls_fids" 3 } } } else { add_status "Platform doesn't support VF###" 3 } } else {
add_status "Virtual Fabric is not supported in this loaded FOS" 3 } return $return_type } ############################################################################## ###### ## NAME ##
disable_virtual_fabric
## ## SYNOPSIS ##
Disables virtual fabric feature on the switch, requires a complete reboot
## ## ## DESCRIPTION ##
a)Checks if all the LS's are deleted and
##
b)Then disables VF if all the switch instances are deleted succeessfully.
## ## ## OPERANDS ##
None
## ## DEPENDENCIES ##
None
## ## RETURN ##
## ## ## USAGE ## disable_virtual_fabric ## ############################################################################## ###### proc disable_virtual_fabric {} { add_status "You are in disable virtual fabric procedure" 3 set SUT [trim_string [get_after "ipaddrshow" "Ethernet IP Address:"]] add_status "The IP of the SUT is: $SUT" 3 if {[check_firmware_version] >= 62} { add_status "Virtual Fabric is supported in this Loaded FOS" 3 add_status "Verifying VF is enabled/disabled" 3 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] if {$vf_status == "enabled"} { set ls_fids [trim_string [get_after "lscfg --show" "Created switches.*:"]] set ls_fids_len [llength $ls_fids] if {$ls_fids_len == 1} { add_status "No LS's detected; continuing with disabling of VF" 3 send_command "fosconfig --disable vf" puts "==>sending y" expect { "Would you like to continue" { exp_send "y\r" add_status "==>sending y"
} } sleep 60 end_telnet sleep 360 end_telnet if {[telnet_switch $SUT root fibranne] != 0} { add_status "Telnet to switch $SUT failed" 0 } add_status "Verifying for successful disabling of VF" 3 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] if {$vf_status == "enabled"} { add_status "Failed to disable VF" 1 return -1 } else { add_status "VF is Successfully disabled" 3 } } else { add_status "The LS's $ls_fids failed to be deleted hence failed to disable VF" 1 return -1 } } else { add_status "VF is already disabled" 3 } } else {
add_status "Virtual Fabric is not supported in this loaded FOS" 3 } return 1 } ############################################################################## ###### ## NAME ## verify_ls_presence ## ## SYNOPSIS ## verify_ls_presence ## ## DESCRIPTION ##
This procedure verifies for the presence of given LS FID by getting the list
##
of LS's created in SUT by executing lscfg --show
## ## OPERANDS ##
fid of the switch to be tested
## ## ## DEPENDENCIES ##
verify_ls_presence
## ## RETURN ##
0: if it finds the fid among the LS's present on the switch
##
1: if it fails to locate the same
## ## USAGE ##
verify_ls_presence $ls_fid
##
verify_ls_presence 12
## ############################################################################## ###### proc verify_ls_presence {fid} { set ret "" set total_ls "" set ls_fid $fid set ls_fids [trim_string [get_after "lscfg --show" "Created switches.*:"]] if {[llength $ls_fids] < 1} { sleep 10 set ls_fids [trim_string [get_after "lscfg --show" "Created switches.*:"]] } foreach fids $ls_fids { set str [regexp {\(.+\)} $fids match] if {$str == 1} { lappend total_ls [string trimright $fids $match] } else { lappend total_ls $fids } } add_status "the total ls are:$total_ls;ls_fids=$ls_fids" 3 if {[lsearch $total_ls $ls_fid] != -1} {
add_status "Successfully created LS($ls_fid)" 3 set ret 0 } else { add_status "Failed to create LS($ls_fid),Please check" 1 set ret 1 } return $ret } ############################################################################## ###### ## NAME ## move_online_port ## ## SYNOPSIS ## move_online_port ## ## DESCRIPTION ##
Moving the F-Port,L-Ports from DS to LS and E-ports from DS to BS.It takes
##
care of those f-ports with trunking (f-port trunking) enabled
## ## OPERANDS ##
The following operands had to be passed in the sequence
##
BS FID,LS FID,E-port list,F-port list,L-port list
## ## DEPENDENCIES ##
verify_ls_presence
## ## RETURN ##
0
## ## USAGE ##
move_online_port $bs_fid $ls_fid $switch_eport $switch_fport $switch_lport
## ############################################################################## ###### proc move_online_port {bs_fid1 ls_fid1 switch_eport1 switch_fport1 switch_lport1} { add_status "you are in move online port procedure" 3 proc port_movement {port_list lsfid} { add_status "you are about to move the ports" 3 set switch_port $port_list set ls_fid $lsfid set version [join [lrange [regexp -inline {([0-9])\.([0-9])\.*} [get_version]] 1 end] "" ] #set switchType [parse_integer [parse_real [get_after "switchShow" "switchType:"]] strict] set platform [get_switch_platform] foreach line $switch_port { if {$platform >= 12000} { if {[regexp "switchshow" $line] != 1} { #set status [lindex $line 6] if {[regexp "Online" $line]} { set slot [lindex $line 1] set port [lindex $line 2]
send_command "lscfg --config $ls_fid -slot $slot -port $port" expect { "\\\[y/n]?:" { exp_send "y\r" if {[wait_for "Logical Switch management operations. Please try again shortly."] == 0} { send_command "lscfg --config $ls_fid -slot $slot -port $port" exp_continue } elseif {[wait_for "Please enable your ports/switch when you are ready to continue."] == 0} { exp_continue } } } } elseif {$line == ""} { #add_status "ignore" 3 } else { add_status "Port $line is not online, Please check" 1 } } } else { if {[regexp "switchshow" $line] != 1} { #set status [lindex $line 4] if {[regexp "Online" $line]} { set port [lindex $line 1] send_command "lscfg --config $ls_fid -port $port"
expect { "\\\[y/n]?:" { exp_send "y\r" wait_for "Please enable your ports/switch when you are ready to continue." #
exp_continue } } } elseif {$line == ""} { #add_status "ignore" 3 } else { add_status "Port $line is not online, Please check" 1 } } } } } #set switchType [parse_real [get_after "switchShow" "switchType:"]] #set switchType [parse_integer $switchType strict] #add_status "switch_type is $switchType" 3 if {[check_vf_capable_platform] == 1} { add_status "It's a VF capable switch" 3 set platform [get_switch_platform] add_status "Platform is $platform" 3 set f_port_trunking_status 0 set switch_eport $switch_eport1
set switch_fport $switch_fport1 set switch_lport $switch_lport1 set ls_fids [trim_string [get_after "lscfg --show" "Created switches.*:"]] foreach fids $ls_fids { set str [regexp {\(.+?\)} $fids match] if {$str == 1 && $match == "(ds)"} { regexp {\d+} $fids ds_fid #set ds_fid [string trimright $fids $match] add_status "The DS is: $ds_fid" 3 } } set ls_fid [lindex $ls_fid1 0] if { $version < "72" } { send_command "lscfg --create $ls_fid" } else { send_command "lscfg --create $ls_fid -force" } wait_for "Switch successfully created." add_status "Checking for successful creation of the ls($ls_fid)" 3 if {[verify_ls_presence $ls_fid] != 0} { add_status "Failed to create LS($ls_fid), do consider to check" 1 } else { add_status "Successfully created LS($ls_fid)" 3 } set bs_fid [lindex $bs_fid1 0]
if { $version < "72" } { send_command "lscfg --create $bs_fid -b" } else { send_command "lscfg --create $bs_fid -b -force" } expect { "\\\[y/n]?:" { exp_send "y\r" wait_for "Switch successfully created." #
exp_continue } } do_command "switchenable" sleep 30 if {[verify_ls_presence $bs_fid] != 0} { add_status "Failed to create Base Switch($bs_fid), do consider to check" 1 } else { add_status "Successfully created Base switch($bs_fid)" 3 } ################################### # Moving E-ports ################################### set switch_eport [split $switch_eport "\n"] port_movement $switch_eport $bs_fid ###################################
# Moving F-ports ################################### if {$switch_fport != ""} { set switch_fport [split $switch_fport "\n"] #Checking for the presence of f-port trunking# add_status "checking for the presence of f-port trunking" 3 set fport_output "" set fport_output [get_command "porttrunkarea --show enabled"] if {[regexp "No ports have Trunk Area enabled" $fport_output] != 1} { set f_port_trunking_status 1 set area "" set slot_port "" do_command "switchshow" add_status "Disabling f-port trunking before moving the ports; ($f_port_trunking_status)" 3 #set switchType [parse_integer [parse_real [get_after "switchShow" "switchType:"]] strict] set fport_trunk_list [split [get_command "porttrunkarea --show enabled"] "\n"] if {[get_switch_platform] > 12000} { foreach fport_list $fport_trunk_list { set port_type [trim_string [lindex $fport_list 2]] if {$port_type == "F-port" || $port_type == "--"} { set slot [lindex $fport_list 0] set port [lindex $fport_list 1] lappend slot_port "$slot/$port" set area [lindex $fport_list 5]
} } } else { foreach fport_list $fport_trunk_list { set port_type [trim_string [lindex $fport_list 1]] if {$port_type == "F-port" || $port_type == "--"} { lappend slot_port [lindex $fport_list 0] set area [lindex $fport_list 4] } } } add_status "the trunking info is:- area= $area; Port list is= $slot_port" 3 do_command "switchdisable" sleep 10 do_command "porttrunkarea --disable all" sleep 10 do_command "switchenable" sleep 30 } else { add_status "No trunking links were found hence continuing" 3 } port_movement $switch_fport $ls_fid ################################### # Reconfiguring the f-port trunking ###################################
if {$f_port_trunking_status == 1} { add_status "Reconfiguring the f-port trunking after deleting all the LS" 3 setcontext_fid $ls_fid do_command "switchcfgtrunk 1" do_command "switchdisable" sleep 10 if {[check_ha_capable_platform] == 0} {
foreach fport $slot_port { do_command "porttrunkarea --enable $fport -area $area" } } else { foreach fport $slot_port { do_command "porttrunkarea --enable $fport -index $area" } } } else { add_status "No f-port trunking was enabled hence did not reconfigure" 3 do_command "switchdisable" sleep 5 } do_command "switchenable" sleep 30 if {[verify_command "switchShow" "(unconfirmed)" 20] == 0} { add_status "Switch still coming up" 3
} set fport_output [get_command "porttrunkarea --show enabled"] if {[regexp "No ports have Trunk Area enabled" $fport_output] == 1 && $f_port_trunking_status == 1} { add_status "Failed to reconfigure F-port trunking" 1 } elseif {$f_port_trunking_status == 0} { add_status "F-port trunking was not enabled initially itself" 3 } else { add_status "F-port trunking is reconfigured successfully" 3 } setcontext_fid $ds_fid } else { add_status "No F-port in the switch to move" 3 } ################################## # Moving L-ports ################################## if {$switch_lport != ""} { set switch_lport [split $switch_lport "\n"] port_movement $switch_lport $ls_fid } else { add_status "There are no L-port in the switch" 3 } sleep 30 } else { add_status "It's not a VF capable switch" 3
} }
############################################################################## # NAME #
delete_ls
# # SYNOPSIS #
delete_ls
# # DESCRIPTION #
Delete LS with specified FID.
# # OPERANDS #
FID: LS FID
# # DEPENDENCIES #
None
# # RETURN #
0: On successful deletion of LS
#
1: On failure to delete LS
# # USAGE
#
delete_ls 10
############################################################################## proc delete_ls {fid} { set return_value 0 set version [join [lrange [regexp -inline {([0-9])\.([0-9])\.*} [get_version]] 1 end] "" ] if { $version < "72" } { set command "lscfg --delete" } else { set command "lscfg --delete $fid -force" } if {[cause "$command" "Switch successfully deleted"] != 0} { set return_value 1 } return $return_value }
############################################################################## # NAME #
configure_lf
# # SYNOPSIS #
configure_lf
# # DESCRIPTION #
Disables or enables VF
# # OPERANDS #
lf_flag: 1 to enabled LF and 0 to disable LF.
# # DEPENDENCIES #
None
# # RETURN #
None
# # USAGE #
configure_lf 0
############################################################################## proc configure_lf {{lf_flag 1}} { global cl_PROMPT do_command "switchdisable" set timeout 1 if {$lf_flag == 0} { set str_to_send "n" } else { set str_to_send "y" } send_command "configure" expect { "Fabric parameters" {
exp_send "y\r" exp_continue } "Allow XISL Use" { exp_send "$str_to_send\r" exp_continue } "WARNING!! Disabling this parameter" { exp_send "y\r" exp_continue } -re "$cl_PROMPT" {
} default { exp_send "\r" exp_continue } } do_command "switchenable" }
############################################################################## # NAME #
get_base_switch_fid
# # SYNOPSIS #
get_base_switch_fid
# # DESCRIPTION #
Returns the FID of base switch.
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
bs_fid: FID of base switch.
# # USAGE #
get_base_switch_fid
############################################################################## proc get_base_switch_fid {} { set bs_fid "" set created_ls [get_after "lscfg --show" "Created switches.*: "] set ls_list [split $created_ls " "] set refined_ls_list "" foreach element $ls_list {
if {$element != ""} { lappend refined_ls_list $element } } foreach ls $refined_ls_list { if {[regexp {[0-9]+\(bs\)} $ls]} { regexp {[0-9]+\(bs\)} $ls bsid set bs_fid [parse_integer $bsid] } } return $bs_fid }
############################################################################## # NAME #
get_logical_switch_fid
# # SYNOPSIS #
get_logical_switch_fid
# # DESCRIPTION #
Returns list of LS FIDs
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
ls_fid: List of LS FIDs
# # USAGE #
get_logical_switch_fid
############################################################################## proc get_logical_switch_fid {} { set ls_fid "" set created_ls [get_after "lscfg --show" "Created switches.*: "] set ls_list [split $created_ls " "] set refined_ls_list "" foreach element $ls_list { if {$element != ""} { lappend refined_ls_list $element } } foreach ls $refined_ls_list { if {![regexp {128\(ds\)} $ls] && ([regexp {[0-9]+\(bs\)} $ls] != 1)} { if {[regexp {\d+} $ls match]} { lappend ls_fid $match }
} } return $ls_fid }
############################################################################## # NAME #
create_ls
# # SYNOPSIS #
create_ls
# # DESCRIPTION #
Created LS with specified FID.
# # OPERANDS #
fid: LS FID
#
base_attribute: Indicates whether the LS is BS
# # DEPENDENCIES #
None
# # RETURN #
0: On successful creation of LS
#
1: On failure to create LS
# # USAGE #
create_ls 10
############################################################################## proc create_ls {fid {base_attribute 0}} { set return_value 0 if {$base_attribute == 0} { if {[cause "lscfg --create $fid" "The system is not ready" 60] == 0} { set return_value 1 } } else { if {[cause "lscfg --create $fid -b -f" "The system is not ready" 60] == 0} { set return_value 1 } else { do_command "chassisenable" sleep 60 } } return $return_value }
############################################################################## # NAME # #
is_vf_enabled
# SYNOPSIS #
is_vf_enabled
# # DESCRIPTION #
Indicates whether VF is enabled or not.
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
0: If VF is enabled
#
1: If VF is disabled
# # USAGE #
is_vf_enabled
############################################################################## proc is_vf_enabled {} { set return_value 0 set vf_status [trim_string [get_after "fosconfig --show" "Virtual Fabric:"]] if {[string first "enabled" $vf_status] == -1 } { set return_value 1 }
return $return_value }
############################################################################## # NAME #
move_port_to_ls
# # SYNOPSIS #
move_port_to_ls
# # DESCRIPTION #
Move specified ports to specified FID
# # OPERANDS #
fid: LS FID
#
port_range: Ports to be moved
#
slot_num: Slot on which ports are to be moved
# # DEPENDENCIES #
None
# # RETURN #
0: On successful port movement
#
1: On failure to move ports
#
# USAGE #
move_port_to_ls 10 0-5 3
############################################################################## proc move_port_to_ls {fid port_range {slot_num ""}} { global cl_ip_address set return_value 0 if {$slot_num == ""} { set port_move_string "-port $port_range" } else { set port_move_string "-slot $slot_num -port $port_range" } # if {[cause "lscfg --config $fid $port_move_string -f" "Configuration change successful" 300] != 0} { # #
set return_value 1 } set status [get_command "lscfg --config $fid $port_move_string -f" 100]
if {[regexp {Configuration change successful} $status] || [regexp {port is already in the current switch} $status]} { set return_value 1 } return $return_value }
############################################################################## # NAME #
verify_ge_port_movement
# # SYNOPSIS #
verify_ge_port_movement
# # DESCRIPTION #
Verified whether GE ports are successfully moved to LS
# # OPERANDS #
num_ge_ports: Number of GE ports moved
# # DEPENDENCIES #
None
# # RETURN #
0: On successful GE-Port movement
#
1: On failure to move GE-Ports
# # USAGE #
verify_ge_port_movement 1
############################################################################## proc verify_ge_port_movement {num_ge_ports} { set return_value 0 set offline_count 0 set disabled_count 0 set ge_port_count 0
if {$num_ge_ports == 1} { set expected_offline_count 8 } elseif {$num_ge_ports == 2} { set expected_offline_count 16 } set switchshow_info [get_command "switchshow"] set switchshow_info [split $switchshow_info "\n"] foreach line $switchshow_info { if {[regexp "Disabled" $line] == 1} { incr disabled_count } elseif {[regexp "Offline" $line] == 1} { incr offline_count } elseif {[regexp "FCIP" $line] == 1} { incr ge_port_count } } if {$disabled_count > 0} { set return_value 1 add_status "There are disabled GE/VE ports in in the logical switch" 3 } if {$ge_port_count != $num_ge_ports} { set return_value 1 add_status "Expected number of GE-Ports not present in the logical switch" 3 } if {$offline_count != $expected_offline_count} {
set return_value 1 add_status "Expected number of VE-channels not present in the logical switch" 3 } return $return_value }
############################################################################## # NAME #
verify_lscfg_output
# # SYNOPSIS #
verify_lscfg_output
# # DESCRIPTION #
Verified lscfg --show for proper port assignment to LS
# # OPERANDS #
slot: Slot number
#
port: Port number
#
fid: LS FID
# # DEPENDENCIES #
None
# # RETURN
#
0: On successful port assignment to LS
#
1: On failed port assignment
# # USAGE #
verify_lscfg_output 10 5 10
############################################################################## proc verify_lscfg_output {slot port fid} { set return_value 0 parse_lscfgshow array if {$slot != "NONE"} { if {$array($slot/$port) != $fid} { set return_value 1 } } else { if {$array($port) != $fid} { set return_value 1 } } return $return_value }
############################################################################## # NAME # #
chassis_disable_enable
# SYNOPSIS #
chassis_disable_enable
# # DESCRIPTION #
Disables/enables chassis for removing segmentation
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
None
# # USAGE #
chassis_disable_enable
############################################################################## proc chassis_disable_enable {} { do_command "chassisdisable" sleep 3 do_command "chassisenable" sleep 60 }
############################################################################## # NAME #
clear_defzone_cfg
# # SYNOPSIS #
clear_defzone_cfg
# # DESCRIPTION #
Clears def zone configuration
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
None
# # USAGE #
clear_defzone_cfg
############################################################################## proc clear_defzone_cfg {} { global cl_ip_address_list foreach ip $cl_ip_address_list {
if {[set_spawn_id $ip] != 0} { if {[telnet_switch $ip] != 0} { add_status "Telnet to $ip failed" 0 } } do_command "switchdisable" default_zone "allaccess" clear_zonecfg do_command "switchenable" } sleep 60 }
############################################################################## # NAME #
get_zone_list_fid
# # SYNOPSIS #
get_zone_list_fid
# # DESCRIPTION #
Returns the zone list for specified FID from testbed file
# # OPERANDS #
fid: LS FID
# # DEPENDENCIES #
None
# # RETURN #
zone_list: Zone list for specified FID taken from testbed file
# # USAGE #
get_zone_list_fid 10
############################################################################## proc get_zone_list_fid {fid} { global cl_zone_set_$fid set zone_list "" eval set zone_list_temp $\{cl_zone_set_$fid\} set zones [split $zone_list_temp ","] set num_zones [llength $zones] for {set zone_index 0} {$zone_index < $num_zones} {incr zone_index} { if {[regexp {[0-9]*-[0-9]*} [lindex $zones $zone_index]]} { set zone [split [lindex $zones $zone_index] "-"] for {set z_index [lindex $zone 0]} {$z_index <= [lindex $zone 1]} {incr z_index} { lappend zone_list $z_index } } else { lappend zone_list [lindex $zones $zone_index] }
} return $zone_list }
############################################################################## # NAME #
get_zone_mem_info
# # SYNOPSIS #
get_zone_mem_info
# # DESCRIPTION #
Returns the zone members for specified FID from testbed file
# # OPERANDS #
fid: LS FID
# # DEPENDENCIES #
None
# # RETURN #
all_zone_list: Zone members for specified FID taken from testbed file
# # USAGE #
get_zone_mem_info 10
############################################################################## proc get_zone_mem_info {fid} { set zone_list [get_zone_list_fid $fid] foreach mem $zone_list { global cl_zone_$mem\_list } set all_zone_list "" set zone_name_mem_list "" foreach mem $zone_list { eval set zone_mem_list_temp $\{cl_zone_$mem\_list\} set zone_name [lindex $zone_mem_list_temp 0] set zone_mem "" for {set index 1} {$index < [llength $zone_mem_list_temp]} {incr index} { lappend zone_mem [lindex $zone_mem_list_temp $index] } lappend zone_name_mem_list $zone_name lappend zone_name_mem_list $zone_mem lappend all_zone_list $zone_name_mem_list set zone_name_mem_list "" } return $all_zone_list }
############################################################################## # NAME
#
config_upload_vf
# # SYNOPSIS #
config_upload_vf
# # DESCRIPTION #
Uploads configuration for specified FID
# # OPERANDS #
fid: LS FID
# # DEPENDENCIES #
upload_config
# # RETURN #
None
# # USAGE #
config_upload_vf 10
############################################################################## proc config_upload_vf {{fid "all"}} { global cl_network_path global cl_upload_file global cl_upload_passwd global cl_upload_host
global cl_upload_user
######################################################################### # Execute the configupload command. ######################################################################### add_status "Executing configupload command" 3
if {[upload_config $cl_upload_host $cl_upload_host $cl_upload_user $cl_upload_file "scp" $cl_upload_passwd $fid] == 0} { add_status "Configupload executed successfully" 3 } else { add_status "Configupload failed" 1 }
######################################################################### # Confirm configuration file is uploaded. #########################################################################
add_status "Verifying the uploaded configuration file" 3 if {[read_file $cl_network_path$cl_upload_file 1] > 0} { add_status "The Config Upload file could not be accessed using read_file" 1 } else { add_status "The configuration file uploaded was accessed successfully using
read_file" 3 } }
############################################################################## # NAME #
config_default_vf
# # SYNOPSIS #
config_default_vf
# # DESCRIPTION #
Executes configdefault -all to set configuration on all LS to factory
#
default
# # OPERANDS #
None
# # DEPENDENCIES #
None
# # RETURN #
None
# # USAGE
#
config_default_vf
############################################################################## proc config_default_vf {} { do_command "chassisdisable" do_command "configdefault -all" sleep 10 do_command "diagdisablepost" sleep 5 complete_reboot "fastboot" "480" }
############################################################################## # NAME #
config_download_vf
# # SYNOPSIS #
config_download_vf
# # DESCRIPTION #
Downloads configuration for specified FID
# # OPERANDS #
fid: LS FID
# # DEPENDENCIES
#
download_config
# # RETURN #
None
# # USAGE #
config_download_vf 10
############################################################################## proc config_download_vf {{fid "all"}} { global cl_network_path global cl_upload_file global cl_upload_passwd global cl_upload_host global cl_upload_user
do_command "chassisdisable" sleep 5 if {[download_config $cl_upload_host $cl_upload_host $cl_upload_user $cl_upload_file "scp" $cl_upload_passwd $fid] == 0} { add_status "Configdownload executed successfully" 3 } else { add_status "ConfigDownload failed" 1 } do_command "chassisenable" sleep 60 }
############################################################################## # NAME #
change_dom_id
# # SYNOPSIS #
change_dom_id
# # DESCRIPTION #
Changes domain ID on switch to specified domain ID
# # OPERANDS #
domain_id: Domain ID of switch
# # DEPENDENCIES #
None
# # RETURN #
None
# # USAGE #
change_dom_id 10
############################################################################## proc change_dom_id {domain_id} { global cl_PROMPT
do_command "switchdisable" set timeout 1 send_command "configure" expect { "Fabric parameters" { exp_send "y\r" exp_continue } "Domain:" { exp_send "$domain_id\r" exp_continue } -re "$cl_PROMPT" {
} default { exp_send "\r" exp_continue } } do_command "switchenable" sleep 20 }
########################################################################### ## NAME ##
verify_zones - verify that the zone is propogated properly in the fabric
## ## SYNOPSIS ##
verify_zones
## ## DESCRIPTION ##
This procedure verifies zone configuration propogation in the fabric
## also returns the members of this zone ## ## OPERANDS ##
zone_name: name of the zone whose members needs to be checked
##
status: Checks Effective/Defined configuration based on input
##
user_ad_list: username, password and admindomain
##
ip_list: ipaddress of the fabric that needs to be checked for zone propogation
##
If nothing is specified it takes ipaddress from cl_ip_address_list
## ## DEPENDENCIES ## ## RETURN ##
member list of the zone specified
## ## USAGE ##
verify_zone zone_first Effective
##
--> {10:00:00:00:c9:2b:9d:35 22:00:00:04:cf:03:4c:fa}
## ################################################################### proc verify_zones {zone_name status {fid "128"} {user_ad_list "root fibranne"} {ip_list ""}} { # Store the original ip address for login back to same spawn global cl_ip_address_list global cl_ip_address global spawn_id set username [lindex $user_ad_list 0] set pwd [lindex $user_ad_list 1] set ad [lindex $user_ad_list 2] set orig_spawn_id $spawn_id
set orig_ip_address $cl_ip_address set status [string toupper $status] if {$ip_list==""} { set ip_list $cl_ip_address_list } # set ip_list [get_fabric_ips] foreach ip $ip_list { if {$ip!=$orig_ip_address} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 }
} elseif {[set_spawn_id $ip] != 0} { if {[telnet_switch $ip $username $pwd] != 0} { add_status "Telnet to switch $ip failed" 0 } }
if {$ad !=""} { ad_select $ad } if {($fid != 128) && ([is_vf_enabled] == 0)} { setcontext_fid $fid } retry_command "cfgshow" # Checks the Effective configuration for zone's if {$status=="EFFECTIVE"} { set cfgshow_output [get_command "cfgshow"] set cfgshow_string1 [regexp {Effective configuration:(.*)} $cfgshow_output cfgshow_string] } # Checks the Defined configuration for zone's if {$status =="DEFINED"} { set cfgshow_string [get_between "cfgshow" "Defined configuration:" "Effective configuration:|Type <CR> to continue "] } # Spliting the cfgshow by new line character
set cfgshow_list [split $cfgshow_string "\r\n"] # Variable that needs to be passed set members_list "" set first_line "" for {set i 0} {$i<[llength $cfgshow_list]} {incr i} { set cfgshow_line [lindex $cfgshow_list $i] # Search for zone expression in each of cfgshow line if {[regexp {(.*)ne:(.*)} $cfgshow_line cfgshow_zone]} { if {[lsearch $cfgshow_zone $zone_name]!=-1} { for {set j 2} {$j<[llength $cfgshow_zone]} {incr j} { append first_line [lindex $cfgshow_zone $j] } if {$first_line!=""} { lappend members_list $first_line } while {$i< [expr [llength $cfgshow_list]-1]} { incr i set cfgshow_line [lindex $cfgshow_list $i] if {[llength $cfgshow_line]==0} { continue; } #Check if next zone, alias, config has started if so exit if {[regexp {(.*)ne:(.*)|(.*)as:(.*)|(.*)fg:(.*)} $cfgshow_line kk]} { break; }
lappend members_list $cfgshow_line } } } } set members_string [join $members_list ";"] set members_list [split $members_string ";"] set final_member_list "" foreach member $members_list { set final_member [string trim $member] if {[regexp {[a-zA-Z0-9:,-_]+} $final_member t]} { lappend final_member_list $final_member } } lappend zone_list $final_member_list if {$ip!=$orig_ip_address} { end_telnet "exit" } }
# Check whether zone is propogated properly through out the fabric through compare list set zone_member1 [lindex $zone_list 0] foreach zone_member $zone_list { set compare_result [compare_lists [lsort $zone_member1] [lsort $zone_member]] if {$compare_result != ""} {
add_status "$status zone configuration is not propogated properly through out fabric $compare_result" 1 } else { add_status "$status zone configuration is propogated properly through out the fabric === $compare_result" 3 } }
if {[set_spawn_id $orig_spawn_id] != 0} { if {[telnet_switch $orig_ip_address $username $pwd] != 0} { add_status "Telnet to switch $orig_ip_address failed" 0 } } return $zone_member1 }
proc enable_disable_switch {sw_mode {ls_fid "128"} {sw_ip ""}} { global cl_ip_address_list cl_ls_fid if {$sw_mode == "switchenable"} { set sw_state "Online" set sw_status "Enabled" } else { set sw_state "Offline" set sw_status "Disabled" } if {$sw_ip == ""} {
set sw_ip $cl_ip_address_list } foreach ip $sw_ip { if {[set_spawn_id $ip]!= 0} { if {[telnet_switch $ip]!= 0} { add_status "Switch: $ip not available" 0 } } if {[is_vf_enabled] == 0} { setcontext_fid $ls_fid do_command $sw_mode sleep 20 } else { do_command $sw_mode sleep 20 } if {[string trim [get_after "switchshow" "switchState:"]] == $sw_state} { add_status "switch $ip $sw_status successfully" 3 } else { add_status "switch $ip not $sw_status successfully after $sw_mode" 1 } } }
proc get_switch_platform_type_old {} {
do_command "switchshow" set type [string trimleft [get_after "switchshow" "switchType:"] ] if {[regexp {(10|21|42|62|77)} $type]} { set sw_type 1 } else { set sw_type 0 } return $sw_type } ############################################### ############################################################################## # NAME #
validate_viking_switch
# # SYNOPSIS #
validate_viking_switch
# # DESCRIPTION #
This routine find the first valid Viking switch from the list of ip_addresses
# # OPERANDS #
ip_list : list containing IP address
# # DEPENDENCIES #
None
# RETURN #
ip_address : This is the first valid viking ip_address from the list
# # USAGE #
validate_viking_switch $cl_viking_ip_address_list
# ############################################################################## proc validate_viking_switch {viking_ip_list} { set viking_switchtype "44.0" set success_ip 0 ########################################################################## # Telnet to the viking switches specified in viking_ip_list" ########################################################################## add_status "Get the first viking switch from ip list" 3 set num_viking_switches [llength $viking_ip_list] if {[llength $viking_ip_list] == 0 } { add_status " There are no Viking switches in the list" 0 } else { foreach ip $viking_ip_list { if {[telnet_switch $ip] != 0 } { add_status "Unable to telnet to switch $ip " 0 } else { set switch_num [get_after "switchshow" "switchType:"] set switch_num [expr {floor($switch_num)}] if { [trim_string $switch_num] == $viking_switchtype } {
set success_ip 1 return $ip } end_telnet "exit"
} } if { $success_ip == 0 } { add_status " Couldn't get valid viking ip address " 0 } } } ############################################################################## # NAME #
enable_ports
# # SYNOPSIS #
enable_ports
# # DESCRIPTION #
This routine enables the range of ports on a given switch
# # OPERANDS # #
ipaddress start_port end_port
# DEPENDENCIES #
None
# RETURN #
None
# # USAGE #
enable_ports [ip_address start_port end_port]
# ##############################################################################
proc enable_ports {ip start_port end_port} {
if { [set_spawn_id $ip] != 0 } { if { [telnet_switch $ip ] != 0 } { add_status " Unable to telnet to switch $ip" 0 } } for {set index $start_port} {$index < $end_port} {incr index } { do_command "portenable $index" } } ############################################################################## # NAME # #
disable_ports
# SYNOPSIS #
disable_ports
# # DESCRIPTION #
This routine disable the range of ports on a switch and check whether
#
ports are in disabled state
# # OPERANDS #
ip_address start_port end_port
# # DEPENDENCIES #
None
# RETURN #
None
# # USAGE #
disable_ports [ip_address start_port end_port]
# ##############################################################################
proc disable_ports {ip start_port end_port} { if { [set_spawn_id $ip] != 0 } { if { [telnet_switch $ip ] != 0 } { add_status " Unable to telnet to switch $ip" 0 }
} for {set index $start_port} {$index < $end_port} {incr index } { do_command "portdisable $index" } sleep 5 set switchshowList [get_switchshow_info] set portDescriptorList [lindex $switchshowList 1] for {set index $start_port} {$index < $end_port } {incr index} { set value_to_be_compared [lindex [lindex [lindex $portDescriptorList $index] 6] 1] if {[string compare $value_to_be_compared "Disabled"] != 0 } { add_status " port $index is not Disabled " 1 } else { add_status "Port $index is disabled" } } } ############################################################################# # NAME #
convert_viking_slottoport
# # SYNOPSIS #
convert_viking_slottoport
# # DESCRIPTION #
This routine first check if the switch is viking switch then return the area
#
number directly. Otherwise convert the area number into slot/port format
# # OPERANDS #
area_number
# # DEPENDENCIES #
None
# RETURN #
return area_number if the switch is viking otherwise
#
return port_number (port is converted in slot/port format)
# USAGE #
convert_viking_slottoport area_number
# ##############################################################################
proc convert_viking_slottoport {area_number} { set viking_switchtype "44.0" set switch_num [get_after "switchshow" "switchType:"] if { [trim_string $switch_num] == $viking_switchtype } { return $area_number } else { set port [convert_to_slotport area_number] return $port } }
##################################################################
############################################################################## ###### ## NAME ## cleanup_user ## ## SYNOPSIS ##
cleanup_user [ip_list]
## ## DESCRIPTION ##
This procedure will cleanup the users within the fabric
## ## OPERANDS ##
ip_list: Description for user profile
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful creation of user
##
1 : User account already exists
##
2 : Failed to create new user due to failure
## ## USAGE
##
create_user "USER1" "user" "passwd" - Creating a user without assigning any AD
############################################################################## ###### proc cleanup_user {{ip_list ""}} { global cl_ip_address_list if {$ip_list ==""} { set ip_list $cl_ip_address_list } do_command "passwddefault" set fabric_info [get_fabric_info] foreach switch_info $fabric_info { if {[lsearch $ip_list [lindex $switch_info 2]]!=-1} { append sw_domain_list [lindex $switch_info 0] ";" } }
do_command "distribute -p pwd -d \"$sw_domain_list\"" sleep 30 } ############################################################################## ###### ## NAME ##
create_user
## ## SYNOPSIS ##
create_user user [role] [password] [AD list] [home AD] [CurrentVF] [VF List] [Description]
## ## DESCRIPTION ##
This procedure will create user with given role, password, AD members and home AD
## ## OPERANDS ##
user : name of the account
##
role : role of the account
##
admem_list: AD member list
##
adhome: Home AD
##
description: Description for user profile
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful creation of user
##
1 : User account already exists
##
2 : Failed to create new user due to failure
## ## USAGE ##
create_user "USER1" "user" "passwd" - Creating a user without assigning any AD
## create_user "USER1" "user" "passwd" "AD1 AD2 AD3" - Creatinga user with AD list "AD1 AD2 AD3" ## create_user "USER1" "user" "passwd" "AD1 AD2 AD3" "AD2" - Creating user with AD list and home AD AD2 ## create_user "USER1" "user" "passwd" "" "" "User with role user" - Creating user without AD but it has description
## create_user "USER1" "user" "passwd" "AD1 AD2 AD3" "AD2" "test" -Creating user with AD list, home and description ## ############################################################################## ##### proc create_user {user {role ""} {password ""} {admem_list ""} {adhome ""} {description ""}} { global cl_PROMPT global cl_user_password if {$role == ""} { set role admin } if {$password == ""} { set password $cl_user_password } if {$description == ""} { set description "$user creation" }
if {$admem_list!=""} { set admem_string [join $admem_list ,] }
add_status "Creating the user $user with role $role and password $password" 3 set result 0 set command_to_send ""
if {($admem_list=="")&&($adhome=="")} { set command_to_send "userConfig --add $user -r $role -l 128 -d \"$description\"" }
if {($adhome=="")&&($admem_list!="")} { set command_to_send "userConfig --add $user -r $role -a $admem_string -d \"$description\"" }
if {($adhome!="")&&($admem_list!="")} { set command_to_send "userConfig --add $user -r $role -h $adhome -a $admem_string -d \"$description\"" } send_command $command_to_send expect { "Named account already exists" { set result 1 add_status "$user account already exists" 3 exp_continue } "assword:" { sleep 1 exp_send "$password\r" exp_continue } "command not found" {
set result 2 add_status "Current user cannot create a user account" 3 exp_continue } "Maximum number of allowed accounts reached" { set result 2 add_status "Unable to create new user as maximun no. of allowed accounts reached" 1 exp_continue } "Invalid user account name" { set result 2 add_status "Invalid user account name $user" 1 exp_continue } "Invalid user account role" { set result 2 add_status "Invalid user account role $role" 1 exp_continue } "Invalid AD-ID" { # Message TBD set result 2 add_status "Invalid Admin Domain" 1 exp_continue } "Maximum AD_ID list size exceeded" { # Message TBD
set result 2 add_status "Maximum AD_ID list size exceeded" 1 exp_continue } "Home AD not present in user's AD permissions" { # Message TBD set result 2 add_status "Home AD not present in user's AD permission list" 1 exp_continue } "Invalid user account description" { set result 2 add_status "User account description exceeds maximum allowed length" 1 exp_continue } "has been successfully added" { set result 0 add_status "User account created successfully" 3 exp_continue } -re "$cl_PROMPT" { exp_continue } }
#
set show_res [verify_user_profile $user $role $admem_list $adhome $description]
set result 0 #
Need to handle AD Name now I am overlooking foreach ad $admem_list { if {($ad>=0)&&($ad<=255)} { set id 1 } else { set id 0 return 0 } } if {$admem_list==""} { set id 1 } if {$id==1} { set show_res [verify_user_profile $user $role $admem_list $adhome $description] if {($show_res!=0)} { add_status "Userconfig show doesn't show correct profile" 1 set result 2 } } return $result
} ############################################################################## ###### ############################################################################## ######
## NAME ##
create_uservf
## ## SYNOPSIS ##
create_user user [role] [password] [VF_ID list] [home VF] [Chassis Role] [Description]
## ## DESCRIPTION ##
This procedure will create user with given role, password, VF members and home VF
## ## OPERANDS ##
user
: name of the account
##
role
: role of the account
##
vflist
: VF list
##
vfhome
: Home VF
##
vfchassis : Permission for chassis cli's
##
description
: Description for user profile
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful creation of user
##
1 : User account already exists
##
2 : Failed to create new user due to failure
##
## USAGE ##
create_user "USER1" "user" "passwd" - Creating a user without assigning any FID
## create_user "USER1" "user" "passwd" "FID1 FID2 FID3" - Creatinga user with VF FID list "FID1 FID2 FID3" ## create_user "USER1" "user" "passwd" "FID1 FID2 FID3" "FID3" - Creating user with VF FID list and home FID3 ## create_user "USER1" "user" "passwd" "" "" "User with role user" - Creating user without VF List but it has description ## create_user "USER1" "user" "passwd" "FID1 FID2 FID3" "FID2" "Creating User" -Creating user with VF list,home & descri ############################################################################## ##### proc create_uservf {user {role ""} {password ""} {vflist ""} {vfhome ""} {vfchassis ""} {description ""} {passexpire ""}} { global cl_PROMPT global cl_user_password global cl_tmp_logical_switch_fid_list
if {$role == ""} { set role admin } if {$password == ""} { set password $cl_user_password } if {$description == ""} { set description "$user creation" } if {$vflist!=""} {
set vf_string [join $vflist ,] } if {$vfchassis == ""} { set vfchassis admin }
add_status "Creating the user $user with role $role and password $password and chassis role $vfchassis" 3 set result 0 set command_to_send "" if {($vflist=="")&&($vfhome=="")} { set command_to_send "userConfig --add $user -r $role -l [lindex $cl_tmp_logical_switch_fid_list 0] -h [lindex $cl_tmp_logical_switch_fid_list 0] -d \"$description\" -c $vfchassis" } if {($vflist!="")&&($vfhome!="")} { set command_to_send "userConfig --add $user -r $role -l $vf_string -h $vfhome -d \"$description\" -c $vfchassis" } if {$passexpire!=""} { append command_to_send " -x" }
send_command $command_to_send expect { "Named account already exists" { set result 1
add_status "$user account already exists" 3 exp_continue } "assword:" { sleep 1 exp_send "$password\r" exp_continue } "command not found" { set result 2 add_status "Current user cannot create a user account" 3 exp_continue } "Maximum number of allowed accounts reached" { set result 2 add_status "Unable to create new user as maximun no. of allowed accounts reached" 1 exp_continue } "Invalid user account name" { set result 2 add_status "Invalid user account name $user" 1 exp_continue } "Invalid role" { set result 2
add_status "Invalid user account role $role" 1 exp_continue } "An invalid VF_ID was specified" { set result 2 add_status "Invalid VF_ID" 1 exp_continue } "Maximum VF_ID list size exceeded" { set result 2 add_status "Maximum VF_ID list size exceeded" 1 exp_continue } "The Home VF specified is not present in the users VF permissions" { set result 2 add_status "Home AD not present in user's AD permission list" 1 exp_continue } "Invalid user account description" { set result 2 add_status "User account description exceeds maximum allowed length" 1 exp_continue } "has been successfully added" { set result 0
add_status "User account created successfully" 3 exp_continue } #
-re "$cl_PROMPT" {
#
exp_continue
#
} -re "$cl_PROMPT" { } timeout { add_status "Command Timed out($timeout)" 2 } } set result 0 return $result
} ############################################################################## ########################## ## NAME ##
user_passwd_failure
## ## SYNOPSIS ## user_passwd_failure param user [role] [password] [AD list] [home AD] [Description] ## ## DESCRIPTION ## ##
This procedure will handle invalid passwords passed for creating a user
## OPERANDS ##
param : password feature for which invalid scenarios have to be taken care
##
user : name of the account
##
role : role of the account
##
admem_list: AD member list
##
adhome: Home AD
##
description: Description for user profile
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful creation of user
##
1 : User account already exists
##
2 : Failed to create new user due to failure
## ## USAGE ## user_passwd_failure "repeat" "USER1" "user" "passwd" ## ############################################################################## ##### proc user_passwd_failure { param user {role ""} {password ""} {admem_list ""} {adhome ""} {description ""} } { global cl_PROMPT global cl_user_password set count 0
if {$role == ""} { set role admin } if {$password == ""} { set password $cl_user_password } if {$description == ""} { set description "$user creation" } if {$admem_list!=""} { set admem_string [join $admem_list ,] } add_status "Creating the user $user with role $role and password $password" 3 set result 0 set command_to_send ""
if {($admem_list=="")&&($adhome=="")} { set command_to_send "userConfig --add $user -r $role -d \"$description\"" } if {($adhome=="")&&($admem_list!="")} { set command_to_send "userConfig --add $user -r $role -a $admem_string -d \"$description\"" }
if {($adhome!="")&&($admem_list!="")} {
set command_to_send "userConfig --add $user -r $role -h $adhome -a $admem_string -d \"$description\"" } send_command $command_to_send switch $param { "repeat" { expect { "Enter new password:" { exp_send "$password\r" incr count exp_continue
} "Password contains more repeated characters than allowed" { add_status "Password contains more repeated characters than allowed string " 3 exp_continue } "Password must be between 8 and 40 characters long." { add_status " Password supplied must be satisfying the basic conditions " 1 } "Failed to get user account password" { if {$count != 3 } { add_status "Account creation successful eventhough it violates passwd policy" 1 } else { add_status "Account creation Unsuccessful " 3 }
} } } "sequence" { expect { "Enter new password:" { exp_send "$password\r" incr count exp_continue
} "Password contains more character sequences than allowed" { add_status "Password contains more characters in sequence than allowed " 3 exp_continue } "Password must be between 8 and 40 characters long." { add_status " Password supplied must be satisfying the basic conditions " 1 } "Failed to get user account password" { if {$count != 3 } { add_status "Account creation successful eventhough it violates passwd policy" 1 } else { add_status "Account creation Unsuccessful " 3 } }
} } } } ############################################################################## ###### ## NAME ##
remove_user
## ## SYNOPSIS ##
remove_user user
## ## DESCRIPTION ##
This procedure will remove user $user account from the switch
## ## OPERANDS ##
user
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : success
##
1 : failed to remove the user from the switch
## ## USAGE
##
remove_user "USER1"
## ############################################################################## ##### proc remove_user {user} { add_status "Removing user account $user from the switch" 3 if {[do_command "userconfig --delete $user"] != 0} { add_status "Unable to delete the account $user form the switch" 1 return 1 } return 0 }
############################################################################## ###### ## NAME ##
verify_user_profile
## ## SYNOPSIS ##
verify_user_profile user [role] [ad_list] [home_ad] [description]
## ## DESCRIPTION ##
This procedure will check whether user was created successfully with
##
role, home AD, AD list. These are passed as argument
## ## OPERANDS
##
user : name of the account
##
role : role of the account
##
ad_list: AD member list
##
home_ad: Home AD
##
description: Description for user profile
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : User profile verification passed
##
1 : User profile verification failed
## ## USAGE ##
verify_user_profile "USER1" "admin" "1 3" 1 "User Check"
## ############################################################################## ##### proc verify_user_profile {user {role ""} {ad_list ""} {home_ad ""} {description ""}} { # Verifying whether the user is created successfully add_status "Verifying profile of user $user" 3 set userconf_list [get_command "userconfig --show $user" 10] set ad_list [lsort -integer $ad_list] if {[regexp "Account name: $user" $userconf_list] != 1} { add_status "User $user profile doesnot exists" 1 return 1
} if {$role !=""} { if {[regexp "Role: $role" $userconf_list] != 1} { add_status "User not created with role $role " 1 return 1 } } if {$ad_list!=""} { set parameter "AD membership: " set parameter1 "Home AD" if {[regexp ($parameter)(.*)($parameter1) $userconf_list expression expression1 user_ad]} { foreach ad $user_ad { if {[regexp {([0-9]+)-([0-9]+)} $ad]} { set ad_range [split $ad -] for {set i [lindex $ad_range 0]} {$i<=[lindex $ad_range 1]} {incr i} { append user_ad_list $i " " } } else { append user_ad_list $ad " " } } } set compare_result [compare_lists [lsort $user_ad_list] [lsort $ad_list]] if {$compare_result != ""} {
add_status "There is variation in AD list configured $ad_list and shown $user_ad_list" 1 } }
if {$home_ad!=""} { if {[regexp "Home AD: $home_ad" $userconf_list] != 1} { add_status "Home AD is wrong" 1 return 1 } } if {$description!=""} { if {[regexp "Description: $description" $userconf_list] != 1} { add_status "Description for user is wrong" 1 return 1 } } return 0 }
############################################################################## ###### ## NAME ##
verify_user_admember
## ## SYNOPSIS
##
verify_user_admember user AD_list
## ## DESCRIPTION ##
This procedure will check whether the user has the ad members specified.
## ## OPERANDS ##
user : name of the account
##
ad_list : AD member list
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : AD member present for this particular user
##
1 : AD memeber is not part of this particular user
## ## USAGE ##
verify_user_admember "USER1" "1 3 4"
## ############################################################################## ##### proc verify_user_admember {user ad_list} { # Verifying whether ad_memeber is present set return_value 0 set userconf_list [get_command "userconfig --show $user"] set ad_list [lsort -integer $ad_list]
set parameter "AD membership: " set parameter1 "Home AD"
if {[regexp ($parameter)(.*)($parameter1) $userconf_list expression expression1 user_ad]} { foreach ad $user_ad { if {[regexp {([0-9]+)-([0-9]+)} $ad]} { set ad_range [split $ad -] for {set i [lindex $ad_range 0]} {$i<=[lindex $ad_range 1]} {incr i} { append user_ad_list $i " " } } else { append user_ad_list $ad " " } } }
foreach ad $ad_list { if {[lsearch $user_ad_list $ad] == -1} { set return_value 1 } } return $return_value }
##############################################################################
###### ## NAME ##
verify_user_adhome
## ## SYNOPSIS ##
verify_user_adhome user ad
## ## DESCRIPTION ##
This procedure will check whether the user has specified AD as its home AD.
## ## OPERANDS ##
user : name of the account
##
ad : AD
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : AD is home AD for this particular user
##
1 : AD is not home AD for this particular user
## ## USAGE ##
verify_user_adhome "USER1" "3"
## ############################################################################## #####
proc verify_user_adhome {user ad} { # Verifying whether Home AD is the given AD set return_value 0 set userconf_list [get_command "userconfig --show $user"] if {[regexp {(Home AD: )(.*)} $userconf_list i j ad_home] == 1} { if {$ad_home!=$ad} { set return_value 1 } } return $return_value } ############################################################################## ###### ## NAME ##
verify_passwd_configuration
## ## SYNOPSIS ##
verify_passwd_configuration parameter value
## ## DESCRIPTION ##
This routine will try to verify if the correct password attribute is set
## ## OPERANDS ## parameter: password configuration parameter (example: repeat,sequence etc) ## ##
value: value that needs to verified for that particular password parameter
## DEPENDENCIES ##
NONE
## ## RETURN ## 0 - Success ##
1 - Failure
## ## USAGE ##
verify_passwd_configuration "repeat" "3"
## ############################################################################## ##### proc verify_passwd_configuration {parameter value} { set parameter [string tolower $parameter] set passwd_configuration passwdcfg.$parameter: set parameter_value [trim_string [get_after "passwdcfg --show" $passwd_configuration]] if {$value==$parameter_value} { return 0 } else { return 1 } }
############################################################################## ###### ## NAME
##
add_ad_to_user
## ## SYNOPSIS ##
add_ad_to_user user ad_list [ad_home]
## ## DESCRIPTION ##
This routine is used to add AD/homeAD to the user
## ## OPERANDS ## ## ##
user : name of the account ad_list : List of AD's that needs to be added ad_home: Home AD that will be modified
## ## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful additon of AD to user
##
1 : failed to add AD to the user
## ## USAGE ##
add_ad_to_user "USER1" "AD1 AD2 AD3" "AD2" - Adding AD and Home AD
## add_ad_to_user "USER1" "AD1 AD2 AD3" modifying the Home AD ##
- Adding only the AD memebers not
############################################################################## ##### proc add_ad_to_user {user admem_list {adhome ""}} { global cl_PROMPT
set admem_string [join $admem_list ,] add_status "Adding ad $admem_list to user $user" 3 set result 0 set command_to_send ""
if {($adhome=="")} { set command_to_send "userConfig --addad $user -a $admem_string" }
if {($adhome!="")} { set command_to_send "userConfig --addad $user -h $adhome -a $admem_string" }
send_command $command_to_send expect { "command not found" { set result 1 add_status "Current user cannot create a user account" 3 exp_continue } "Maximum number of allowed accounts reached" {
set result 1 add_status "Unable to create new user as maximun no. of allowed accounts reached" 1 exp_continue } "Invalid user account name" { set result 1 add_status "Invalid user account name $user" 1 exp_continue } "Invalid AD-ID" { # Message TBD set result 1 add_status "Invalid Admin Domain" 1 exp_continue } "Maximum AD_ID list size exceeded" { # Message TBD set result 1 add_status "Maximum AD_ID list size exceeded" 1 exp_continue } "Home AD not present in user's AD permissions" { # Message TBD set result 1 add_status "Home AD not present in user's AD permission list" 1 exp_continue } "New Ads for account $user has been successfully added" {
set result 0 add_status "AD added successfully" 3 exp_continue } -re "$cl_PROMPT" { exp_continue } } set show_res [verify_user_admember $user $admem_list] if {$show_res != 0} { add_status "userconfig show doesn't show the added AD memeber $admem_list" 1 set result 2 } if {$adhome!=""} { set show_res [verify_user_adhome $user $adhome] if {$show_res != 0} { add_status "userconfig show doesn't show the added home AD memeber" 1 set result 2 } } return $result }
############################################################################## ######
## NAME ##
delete_ad_from_user
## ## SYNOPSIS ##
delete_ad_from_user user ad_list [ad_home]
## ## DESCRIPTION ##
This routine is used to delete AD/home AD from the user
## ## OPERANDS ## ## ##
user : name of the account ad_list : List of AD's that needs to be added ad_home: Home AD that will be modified
## ## ## DEPENDENCIES ##
NONE
## ## RETURN ##
0 : successful deletion of AD to user
##
1 : failed to delete AD from the user
## ## USAGE ##
delete_ad_from_user "USER1" "AD1 AD2 AD3" "AD2" - deleting AD and Home AD
##
delete_ad_from_user "USER1" "AD1 AD2 AD3"
- deleting only the AD memebers
## ############################################################################## ##### proc delete_ad_from_user {user admem_list {adhome ""}} { global cl_PROMPT
set admem_string [join $admem_list ,] add_status "Deleting ad $admem_list from user $user" 3 set result 0 set command_to_send ""
if {($adhome=="")} { set command_to_send "userConfig --deletead $user -a $admem_string" }
if {($adhome!="")} { set command_to_send "userConfig --deletead $user -h $adhome -a $admem_string" }
send_command $command_to_send expect { "command not found" { set result 1 add_status "Current user cannot create a user account" 3 exp_continue }
"Maximum number of allowed accounts reached" { set result 1 add_status "Unable to create new user as maximun no. of allowed accounts reached" 1 exp_continue } "Invalid user account name" { set result 1 add_status "Invalid user account name $user" 1 exp_continue } "Invalid AD-ID" { # Message TBD set result 1 add_status "Invalid Admin Domain" 1 exp_continue } "Maximum AD_ID list size exceeded" { # Message TBD set result 1 add_status "Maximum AD_ID list size exceeded" 1 exp_continue } "Home AD not present in user's AD permissions" { # Message TBD set result 1 add_status "Home AD not present in user's AD permission list" 1 exp_continue }
"New Ads for account $user has been successfully deleted" { set result 0 add_status "AD added successfully" 3 exp_continue } -re "$cl_PROMPT" { exp_continue } } set show_res [verify_user_admember $user $admem_list] if {$show_res != 1} { add_status "userconfig show displays the deleted AD memeber" 1 set result 2 } if {$adhome!=""} { set show_res [verify_user_adhome $user $adhome] if {$show_res != 1} { add_status "userconfig show displays the deleted home AD memeber" 1 set result 2 } } return $result }
############################################################################## ######
## NAME ##
login_user
## ## SYNOPSIS ##
login_user ip_address user passwd
## ## DESCRIPTION ##
This procedure will login as user, and stores the spawn_id as
##
two dimension spawn_user_id array
##
Example: spawn_user_id(10.32.247.51,user1)
## ## OPERANDS ## ## ##
ip_address : IP address of the switch user : User name to login the switch passwd : Password of the user
## ## DEPENDENCIES ##
global two dimenstional array should be present in the main program
## Example: set spawn_user_id(10.32.247.51,user1) "" ## ## ## RETURN ##
None
## ## USAGE
##
login_user 10.32.247.41 user1 password
## ############################################################################## ##### proc login_user {ip_address user passwd} { global array spawn_user_id global spawn_id if {[set_spawn_id $spawn_user_id($ip_address,$user)] != 0} { if {[telnet_switch $ip_address $user $passwd] != 0} { add_status "Telnet to switch $ip_address failed" 0 } } set spawn_user_id($ip_address,$user) $spawn_id }
############################################################################## ###### ## NAME ## verify_failure_nondist_cfgdownload ## ## SYNOPSIS ## verify_failure_nondist_cfgdownload ## ## DESCRIPTION ## This routine will try to download the configuration filter parameter to the switch and verify that configuration \ ##
parameters cannot be downloaded when switch is enabled
## ## OPERANDS ## NONE ## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ## verify_failure_nondist_cfgdownload param "value" ## ############################################################################## #####
proc verify_failure_nondist_cfgdownload { } {
global cl_upload_host global cl_upload_user global cl_upload_file global cl_upload_passwd set protocol ftp set return_value 0 set timeout 300 exp_send "configDownload\r"
expect { "may not be executed" { add_status "Switch must be disabled first." 1 } "erver Name " { exp_send "$cl_upload_host\n" exp_continue } "ser Name " {
exp_send "$cl_upload_user\n" exp_continue } "ile Name " { exp_send "$cl_upload_file\n" exp_continue } "rotocol (" { exp_send "\n" exp_continue } "assword:" { exp_send "$cl_upload_passwd\n" exp_continue }
"Do you want to continue" { exp_send "y\n" exp_continue } "ogin incorrect." { add_status "config_download failed. Login incorrect." 1 } "ermission denied." { add_status "config_download failed. Permission denied." 1 } "load failed" { add_status "config_download failed. (Incorrect host / user / password ?)" 1 } "load complete" { add_status "Config download performed even when switch was not disabled " 1 set return_value 1 } "configDownload not permitted" { add_status " Verified that Configuration file cannot be downloaded to the switch without disabling it" 3 set return_value 0 } "Can only execute this command on the Primary FCS switch" { add_status " Verified that Configuration file cannot be downloaded to the backup FCS switch without disabling it" 3 set return_value 0
}
timeout { add_status "configDownload timed out." 1 } } clear_buffer return $return_value }
proc verify_success_nondist_cfgdownload { } {
global cl_upload_host global cl_upload_user global cl_upload_file global cl_upload_passwd set protocol ftp set return_value 0 set timeout 300 exp_send "configDownload\r" expect { "may not be executed" { add_status "Switch must be disabled first." 1 } "erver Name " {
exp_send "$cl_upload_host\n" exp_continue } "ser Name " {
exp_send "$cl_upload_user\n" exp_continue } "ile Name " { exp_send "$cl_upload_file\n" exp_continue } "rotocol (" { exp_send "\n" exp_continue } "assword:" { exp_send "$cl_upload_passwd\n" exp_continue } "Do you want to continue" { exp_send "y\n" exp_continue } "ogin incorrect." {
add_status "config_download failed. Login incorrect." 1 } "ermission denied." { add_status "config_download failed. Permission denied." 1 } "load failed" { add_status "config_download failed. (Incorrect host / user / password ?)" 1 } "load complete" { add_status "Config download performed even when Primary FCS switch was not disabled "3 set return_value 1 } "configDownload not permitted" { add_status " Configuration file cannot be downloaded to the switch without disabling it" 1 set return_value 0 } "Can only execute this command on the Primary FCS switch" { add_status "Current Switch is a Primary FCS Switch" 1 set return_value 0 }
timeout { add_status "configDownload timed out." 1 }
} clear_buffer return $return_value }
##################################################### ################### ## NAME ##
verify_required_index - verifies if the minimum required
##
index is in a list
## ## SYNOPSIS ##
verify_required_index list min_index [error_level]
## ## DESCRIPTION ##
Verifies if the minimum required index is in a list
## ## OPERANDS ##
list:
##
min_index: The minimum required index. The default
## ## ## ##
A list for verifying required index.
ist set to 1 if not specified. error_level: Error level for add_status. The default is set to 0 if not specified.
## DEPENDENCIES ##
none
## ## RETURN ##
<index>: returns 0 if required number of index is in the list,
##
else will return the number of indexes needed to reach the
##
required number.
## ## USAGE ##
set index [verify_required_index $ip_list $min_ip $error_level]
##
if {$index != 0} {
##
add_status "this list needs $index more indexes to reach its
## ##
required index." }
##
proc verify_required_index {list_ {min_index_ 1} {error_level_ 0}} { set return_value 0 if {[llength $list_] < $min_index_} { add_status "Missing index(es), need at least $min_index_ in this list" $error_level_ set return_value [expr $min_index_ - [llength $list_]] } return $return_value }
################### ## NAME ##
login_all_ips - login to all ip addresses
## ## SYNOPSIS ##
login_all_ips ip_list min_ip [error_level]
## ## DESCRIPTION ##
Verifies if the minimum required ip addresses is in
##
the ip list and login to all ip addresses.
## ## OPERANDS ##
ip_list:
##
min_ip:
## ##
A list of ip addresses to login. The minimum required ip addresses. The Default
is set to 1 if nothing is specified. error_level: Error level for add_status. The default is set
##
to 0 if nothing is specified.
## ## DEPENDENCIES ##
verify_required_index
## ## RETURN ##
<index>: If verification succeeds, returns 0 if all ip address
##
logins are successful, else will return the number of
##
logins that weren't successful.
##
If verification fails, returns the number of ip's
##
needed to reach the required number.
## ## USAGE ##
if {[login_all_ips $ip_list] == 0} {
## ##
add_status "All ip logins are successful" } else {
## ##
add_status "not all ip logins are successful" }
##
proc login_all_ips {ip_list_ {min_ip_ 1} {error_level_ 0}} { set return_value 0
set index [verify_required_index $ip_list_ $min_ip_ $error_level_] if {$index != 0} { set return_value $index } else { for {set count 0} {$count < [llength $ip_list_]} {incr count 1} { if {[telnet_switch [lindex $ip_list_ $count]] == 1} { add_status "Switch [lindex $ip_list_ $count] not available" $error_level_ incr return_value 1 } } }
return $return_value }
################### ## NAME ##
get_list_intersection - gets the intersection of two lists
## ## SYNOPSIS ##
get_list_intersection element list
## ## DESCRIPTION ##
Gets the intersection of two lists.
## ## OPERANDS ##
list1
##
list2
## ## DEPENDENCIES ##
none
## ## RETURN ##
<list_intersection>: returns the intersection of two lists, else
## ## ## USAGE
will return "" if nothing is found.
##
set intersection [get_list_intersection $list1 $list2]
##
proc get_list_intersection {list1_ list2_} { set return_list "" foreach tmp1 $list2_ { foreach tmp2 $list1_ { if {$tmp1 == $tmp2} { lappend return_list $tmp1 } } } return $return_list }
################### ## NAME ##
get_list_opposite_of_intersection - gets the opposite of
##
intersection of two lists
## ## SYNOPSIS ##
get_list_opposite_of_intersection element list
## ## DESCRIPTION ##
Gets the opposite of intersection of two lists.
## ## OPERANDS ##
list1
##
list2
## ## DEPENDENCIES ##
none
## ## RETURN ##
<list_intersection>: returns the opposite of intersection of
##
two lists, else will return "" if
##
nothing is found.
## ## USAGE ##
set var [get_list_opposite_of_intersection $list1 $list2]
##
proc get_list_opposite_of_intersection {list1_ list2_} { set return_list "" foreach tmp1 $list2_ { set boolean 0 foreach tmp2 $list1_ { if {$tmp1 == $tmp2} { set boolean 1 break
} } if {$boolean == 0} { lappend return_list $tmp1 } } return $return_list }
################### ## NAME ##
reboot_host - reboots a sun host
## ## SYNOPSIS ##
get_list_opposite_of_intersection element list
## ## DESCRIPTION ##
Reboots a sun hust with the "reboot -- -r" command
## ## OPERANDS ##
host_ip: host ip address
##
host_user: host username
##
host_pass: host password
##
wait_for: For logging back into the host to ensure it is back
##
up from a reboot. Will sleep for specified seconds
##
and then ensure host is back up. If value given
##
is 0, it will skip the verification completely.
##
Will default to 60 if nothing is specified.
## ## DEPENDENCIES ##
none
## ## RETURN ##
<return>: returns 0 if host successfully rebooted, or a value
##
greater than 0 if not.
## ## USAGE ##
if {[reboot_host $host_ip] == 0} {
## ##
add_status "host has been successfully rebooted" }
##
#proc reboot_host {host_ip_ {host_user_ ""} {host_pass_ ""} {wait_for_ 60}} { #
global cl_PROMPT
#
global cl_HOST_PROMPT
#
global cl_is_last_command
#
global spawn_id
# # #
if {$host_user_ == ""} { global cl_host_name
#
set host_user_ $cl_host_name
#
}
#
if {$host_pass_ == ""} {
#
global cl_host_pass
#
set host_pass_ $cl_host_pass
#
}
#
if {($host_user_ == "") || ($host_pass_ == "")} {
# #
return 1 }
# #
set orig_prompt $cl_PROMPT
#
set orig_spawn_id $spawn_id
#
set orig_ilc $cl_is_last_command
# #
set cl_PROMPT $cl_HOST_PROMPT
#
telnet_switch $host_ip_ $host_user_ $host_pass_
#
set cl_is_last_command 1
#
set return_value [do_command "reboot -- -r"]
# #
if {$wait_for_ > 0} {
#
sleep $wait_for_
#
set cl_PROMPT $cl_HOST_PROMPT
#
set return_value [telnet_switch $host_ip_ $host_user_ $host_pass_]
#
if {$return_value == 0} {
#
end_telnet "exit"
# #
} }
# #
set cl_PROMPT $orig_prompt
#
set spawn_id $orig_spawn_id
#
set cl_is_last_command $orig_ilc
#
return $return_value
#}
proc reboot_host { args } { global cl_ERROR
set argc [llength $args]
if {$argc == 1} { set spawn_id [lindex $args 0] } elseif {$argc == 3} { set system_name [lindex $args 0] set user [lindex $args 1] set password [lindex $args 2] if {[telnet_host $system_name $user $password] != -1} { add_status "$system_name is up successfully; reboot it!" } else { add_status "$system_name is not up successfully, cannot reboot it." 1 return $cl_ERROR
} }
set system [get_uname]
if {$system == "HP-UX"} { send -- "shutdown -r now\r" sleep 300 puts "system rebooted!" return 0 } else { send -- "reboot -- -r\r" expect -exact "Connection closed by foreign host." { sleep 120 } puts "system rebooted!" return 0 }
} #############################################
################### ## NAME ##
verify_fabric_io - Verifies traffic throughout a fabric.
## ## SYNOPSIS
##
verify_fabric_io ip_list [target_list] [performance]
## ## DESCRIPTION ##
Verifies traffic on each device port in a fabric.
##
Note, traffic is verified by comparing the average
##
portperfshow to a performance limit (in bytes).
## ## OPERANDS ##
ip_list:
List of IP addresses of the switches that traffic is
##
desired to be verified. There must be connections
##
already open to the switches and available by spawn_id.
##
target_list: List of targets by WWN or Domain/Port format that
##
specifies which targets are desired for traffic
##
verification. The default is all targets if no list
##
is specified.
##
performance: An integer that represents the least amount of
##
performance (in bytes) that is acceptable for traffic
##
to be verified on a port. The default is 150000 bytes
##
if nothing is specified.
## ## DEPENDENCIES ##
verify_switch_io: verifies traffic for each switch
## ## RETURN ##
<failure_number>: returns 0 if traffic on all switches in the fabric
##
was successfully verified, else will return the
##
number of switches that failed verification.
## ## USAGE ##
if {[verify_fabric_io $cl_ip_address_list $target_list] > 0} {
## ##
add_status "traffic was not verified" 1 } else {
## ##
add_status "traffic was successfully verified" 3 }
##
proc verify_fabric_io {ip_list_ {target_list_ ""} {performance_ 150000}} { global spawn_id
set return_value 0 set original_spawn_id $spawn_id foreach ip $ip_list_ { if {[set_spawn_id $ip] == 0} { if {[verify_switch_io $target_list_ $performance_] > 0} { incr return_value 1 } } } set spawn_id $original_spawn_id return $return_value
}
################### ## NAME ##
verify_switch_io - Verifies traffic on a switch.
## ## SYNOPSIS ##
verify_switch_io [target_list] [performance]
## ## DESCRIPTION ##
Verifies traffic on each device port in a switch.
##
Note, traffic is verified by comparing the average
##
portperfshow to a performance limit (in bytes).
## ## OPERANDS ##
target_list: List of targets by WWN or Domain/Port format that
##
specifies which targets are desired for traffic
##
verification. The default is all targets if no list
##
is specified.
##
performance: An integer that represents the least amount of
##
performance (in bytes) that is acceptable for traffic
##
to be verified on a port. The default is 150000 bytes
##
if nothing is specified.
## ## DEPENDENCIES
##
get_switch_platform
##
get_device_areas
##
convert_to_slotport
##
get_avg_switch_perf
##
get_avg_port_perf
##
extract_port_perf
## ## RETURN ##
<failure_number>: returns 0 if traffic on all ports in the switch
##
was successfully verified, else will return the
##
number of ports that failed verification.
## ## USAGE ##
if {[verify_switch_io $target_list_ $performance_] > 0} {
## ##
add_status "traffic was not verified" 1 } else {
## ##
add_status "traffic was successfully verified" 3 }
##
proc verify_switch_io {{target_list_ ""} {performance_ 150000}} { set switch_type [get_switch_platform] set target_list_ [get_device_areas $target_list_] set return_value 0
foreach target $target_list_ { if {$switch_type > 4100} { set target [convert_to_slotport $target] } if {$switch_type == 3900} { set tmp_matrix [get_avg_switch_perf 50] set tmp_perf [extract_port_perf $tmp_matrix $target] } else { set tmp_perf [get_avg_port_perf $target 50] } if {$tmp_perf < 0} { set tmp_perf [expr $tmp_perf * -1] } if {$tmp_perf < $performance_} { add_status "The throughput on port $target is less than $performance_!!" 1 add_status "The throughput was $tmp_perf" incr return_value 1 } else { add_status "Traffic on port $target is confirmed!!" 3 add_status "The throughput was $tmp_perf" } clear_buffer } return $return_value }
###################
## NAME ##
get_device_areas - Gets the Pid areas all devices
## ## SYNOPSIS ##
get_device_areas [device_list]
## ## DESCRIPTION ##
Converts local devices into Pid area format.
##
Note, there is still an outstanding issue with legacy and core
##
Pid differentiation. This function assumes all Pids are in
##
core Pid format.
## ## OPERANDS ##
device_list: List of devices by WWN or Domain/Port format that
##
specifies which devices are desired to be converted
##
into Pid area format. The default is all devices
##
if no list is specified.
## ## DEPENDENCIES ##
get_device_pids
##
get_pid_port
##
get_devices
##
convert_to_dec
##
convert_to_domain_port
##
lappend_unique
##
replace_string
## ## RETURN ##
<area_list>: returns a list of all Pid areas found. Will return
##
"" if nothing was found.
## ## USAGE ##
set target_list [get_device_areas $target_list_]
##
proc get_device_areas {{device_list_ ""}} { set return_value "" set temp_list [get_device_pids]
if {$device_list_ == ""} { if {$temp_list != ""} { foreach single_pid $temp_list { set pid_area [convert_to_dec [get_pid_port $single_pid]] set return_value [lappend_unique $return_value $pid_area] } } } else { set local_devices [get_devices] foreach member $device_list_ { # if it is in "domain,port" format, change to "domain port"
set member [replace_string $member "," " "] set member [string tolower $member] foreach local_device $local_devices { set new_member "" if {([string first $member $local_device] >= 0) || ([convert_to_domain_port [lindex $local_device 0]] == $member)} { set new_member [convert_to_dec [get_pid_port [lindex $local_device 0]]] set return_value [lappend_unique $return_value $new_member] } } } }
return $return_value } ################################################### ############################################################################## ###### ## NAME ##
get_ti_zone_show
## ## SYNOPSIS ##
get_ti_zone_show
## ## DESCRIPTION
##
This routine will give the list of port members, status and failover from TI zone
## ## OPERANDS ## Name - Name of the zone ## ## ## DEPENDENCIES ##
NONE
## ## RETURN: ## List containing: ## port_list ## status ## failover ## ## USAGE ##
get_ti_zone_show zone1
## ############################################################################## #####
proc get_ti_zone_show {name} { set firmware_version [get_version] regexp {v[0-9]+.[0-9]+} $firmware_version version_string set zone_show_output [get_command "zone --show $name"] set zone_show_list [lrange [split $zone_show_output "\n"] 0 end-1]
if {[string compare $version_string "v6.1"] == 0} { foreach elem $zone_show_list { set elem [trim_string $elem] if {[regexp {(Port List:)(.*)} $elem i j k] == 1} { set port_list "" set port_list [trim_string $k] } if {[regexp {(Status:)(.*)(Failover:)} $elem i j k] == 1} { set status [trim_string $k] } if {[regexp {(Failover:)(.*)} $elem i j k] == 1} { set failover [trim_string $k] } } set port_list [split $port_list ";"] foreach port $port_list { set port [trim_string $port] if {$port!=""} { append port_list1 $port " " } } set zone_show_list "{$port_list1} $status $failover" return $zone_show_list } else { foreach elem $zone_show_list {
set elem [trim_string $elem] if {[regexp {(Port List:)(.*)} $elem i j k] == 1} { set port_list "" set port_list [trim_string $k] } elseif {![regexp {Configured|Enabled} $elem]} { append port_list $elem add_status "Ari:port list is $port_list" } if {[regexp {(Configured Status:)(.*)(/ Failover-)} $elem i j k] == 1} { add_status "Stats is $i, $j, $k" set status [trim_string $k] } if {[regexp {(Failover-)(.*)} $elem i j k] == 1} { add_status "failover is $i, $j, $k" set failover [trim_string $k] } } set port_list [split $port_list ";"] foreach port $port_list { set port [trim_string $port] if {$port!=""} { append port_list1 $port " " } } add_status "list1 $port_list1"
set zone_show_list "{$port_list1} $status $failover" return $zone_show_list } } ############################################################################## ###### ## NAME ##
ti_zone_create
## ## SYNOPSIS ##
ti_zone_create
## ## DESCRIPTION ##
This routine will create ti zone with port members
## ## OPERANDS ## Name - Name of the zone ## port_list - List of ports(D,P) ## ## DEPENDENCIES ##
NONE
## ## RETURN ## ## USAGE ##
To create TI zone with list of parameters
##
ti_zone_create zone1 {1,1 1,3}
## ############################################################################## #####
proc ti_zone_create {name member_list {failover ""} {activate ""}} {
set i 0 foreach member $member_list { if {$i!=0} { append member_string ";" } incr i append member_string [join $member ";"] } set member_string \"$member_string\" if {($failover=="")&&($activate=="")} { do_command "zone --create -t ti $name -p $member_string" } if {($failover=="")&&($activate!="")} { do_command "zone --create -t ti -o d $name -p $member_string" } if {($failover!="")&&($activate=="")} { do_command "zone --create -t ti -o n $name -p $member_string" } if {($failover!="")&&($activate!="")} {
do_command "zone --create -t ti -o dn $name -p $member_string" } }
############################################################################## ###### ## NAME ##
ti_zone_add
## ## SYNOPSIS ##
ti_zone_add
## ## DESCRIPTION ##
This routine will add port members to ti zone
## ## OPERANDS ## Name - Name of the zone ## port_list - List of ports(D,P) ## failover- f(failover enable) ##
n(failover disable)
## activate- a(activate) ##
d(deactivate)
## ## DEPENDENCIES ## ##
NONE
## RETURN ## ## USAGE ##
To add TI zone with list of parameters
##
ti_zone_add zone1 {1,1 1,3}
## ############################################################################## #####
proc ti_zone_add {name member_list {failover ""} {activate ""}} { set member_string "" set i 0 foreach member $member_list { if {$i!=0} { append member_string ";" } incr i append member_string [join $member ";"] } set member_string \"$member_string\" if {($failover=="")&&($activate=="")} { do_command "zone --add $name -p $member_string" } if {($failover=="")&&($activate!="")} { do_command "zone --add -o d $name -p $member_string" }
if {($failover!="")&&($activate=="")} { do_command "zone --add -o an $name -p $member_string" } if {($failover!="")&&($activate!="")} { do_command "zone --add -o dn $name -p $member_string" } }
############################################################################## ###### ## NAME ##
ti_zone_remove
## ## SYNOPSIS ##
ti_zone_remove
## ## DESCRIPTION ##
This routine will remove port members from TI zone
## ## OPERANDS ## Name - Name of the zone ## port_list - List of ports(D,P) ## ## DEPENDENCIES ##
NONE
## ## RETURN ## ## USAGE ##
To remove the port members from TI zone
##
ti_zone_add zone1 {1,1 1,3}
## ############################################################################## #####
proc ti_zone_remove {name member_list} {
set i 0 foreach member $member_list { if {$i!=0} { append member_string ";" } incr i append member_string [join $member ";"] } set member_string \"$member_string\" do_command "zone --remove $name -p $member_string" }
############################################################################## ######
## NAME ##
verify_ti_zone_show
## ## SYNOPSIS ##
verify_ti_zone_show
## ## DESCRIPTION ##
This routine will verify the ti zone show with portlist, status and failover
## ## OPERANDS ## Name - Name of the zone ## port_list - list of ports participating in the zone ## state - State of TI zone activated or non activated state ## failover - status whether failover is enabled or disabled ## ## DEPENDENCIES ##
get_ti_zone_show
## ## RETURN: ## NONE ## ## ## USAGE ## ##
verify_ti_zone_show zone1 {1,1 1,2 1,3} Activated Enabled
############################################################################## #####
proc verify_ti_zone_show {name port_list {state ""} {failover ""}} { set ti_zone_show [get_ti_zone_show $name] set got_port_list [lindex $ti_zone_show 0] add_status "got_port is $got_port_list and $port_list" foreach port $port_list { if {[lsearch $got_port_list $port] == -1} { add_status "port $port is not in the zone show list" 1 } } if {$state!=""} { if {$state !=[lindex $ti_zone_show 1]} { add_status "State of TI zone $name doesn't match: expected $state, found [lindex $ti_zone_show 1]" 1 } } if {$failover!=""} { if {$failover !=[lindex $ti_zone_show 2]} { add_status "Failover status of TI zone $name doesn't match: expected $failover, found [lindex $ti_zone_show 2]" 1 } } }
############################################################################## ###### ## NAME ##
get_ti_zone_state
## ## SYNOPSIS ##
get_ti_zone_state
## ## DESCRIPTION ##
This routine will return the state of specified TI zone
## ## OPERANDS ## Name - Name of the zone ## ## ## DEPENDENCIES ##
get_ti_zone_show
## ## RETURN: ## status ## ## ## USAGE ##
get_ti_zone_state zone1
## ##############################################################################
#####
proc get_ti_zone_state {name} { set ti_zone_show_list [get_ti_zone_show $name] return [lindex $ti_zone_show_list 1] }
############################################################################## ###### ## NAME ##
get_ti_zone_failover
## ## SYNOPSIS ##
get_ti_zone_failover
## ## DESCRIPTION ##
This routine will return the failover status of specified TI zone
## ## OPERANDS ## Name - Name of the zone ## ## DEPENDENCIES ##
get_ti_zone_state
## ## RETURN: ## failover state(Enabled or Disabled)
## ## ## USAGE ##
get_ti_zone_failover zone1
## ############################################################################## #####
proc get_ti_zone_failover {name} { set ti_zone_show [get_ti_zone_show $name] return [lindex $ti_zone_show 2] }
proc get_route_domain {in_port domain} { set return_value ""
set raw_data [make_matrix "urouteshow [convert_area_slotport $in_port] $domain" "----------" "" 6] set in_port_blob "" set in_port_current "" foreach line $raw_data { set in_port [lindex $line 0] scan [lindex $line 1] "%d %d %d %d %s %d,%d" domain_ out_port_ metric_ hops_ flags_ remote_domain_ remote_port_ if {$in_port != ""} { if {$in_port_blob != ""} {
lappend return_value [list $in_port_current $in_port_blob] set in_port_current $in_port set in_port_blob [list "$domain_ $out_port_ $metric_ $hops_ $flags_ $remote_domain_ $remote_port_"] } else { set in_port_current $in_port lappend in_port_blob [list $domain_ $out_port_ $metric_ $hops_ $flags_ $remote_domain_ $remote_port_] } } else { lappend in_port_blob [list $domain_ $out_port_ $metric_ $hops_ $flags_ $remote_domain_ $remote_port_] } } lappend return_value [list $in_port_current $in_port_blob] return $return_value } proc get_out_next_dp {in_port domain} {
set route_list [get_route_domain $in_port $domain] set local_domain [trim_string [parse_integer [get_after "switchshow" "switchDomain:"]]] set out_route_list [lindex [lindex $route_list 0] 1] foreach route $out_route_list { set dom [lindex $route 5] set out_port [lindex $route 1] set next_port [lindex $route 6] set ndp "$dom,$next_port"
set odp "$local_domain,$out_port" append dp_list $odp " " $ndp " " } return $dp_list }
proc verify_no_route {in_port domain} { set route_list [get_route_domain $in_port $domain] set routes [lindex $route_list 0] foreach route $routes { if {$route!=""} { add_status "Routes are not empty" 1 } } } ########################################### proc telnet_SW {} { global cl_SWITCH global cl_EXPECTED_VERSION
release_term_console
if {[telnet_switch $cl_SWITCH] != 0} { add_status "Unable to connect to $cl_SWITCH" 0; }
send_command "auto" expect { "Booting" { add_status "waiting.." 1 sleep 60 end_telnet "exit" if {[telnet_switch $cl_SWITCH] != 0} { add_status "Unable to connect to $cl_SWITCH" 0; } } } set_spawn_id $cl_SWITCH do_command "version" if {[verify_version $cl_EXPECTED_VERSION] == 1} { add_status "Incorrect version. Firmwaredownload failed" 0 } }
proc reboot_SW {} {
global cl_SWITCH
# Reboot switch
set_spawn_id $cl_SWITCH puts "SWITCH GOING FOR FASTBOOT.." set cl_login_pause 200 do_command "fastboot" wait_for "Enabling switch..." 120:w }
proc release_term_console {} { global cl_SWITCH global cl_PROMPT
# find console ip ports set loc [string first " " $cl_SWITCH] set console [string range $cl_SWITCH 0 $loc]
set loc [expr $loc + 3] set port1 [string range $cl_SWITCH $loc end] if {[string index $port1 0] == 0} { set port1 [string index $port1 1] }
set old_PROMPT $cl_PROMPT set cl_PROMPT "> "
if {[telnet_switch $console "root" "pass"] != 0} { add_status "Unable to connect to $console" 0; }
add_status "sending command" do_command "user logout port$port1" end_telnet "quit"
sleep 5
set $cl_PROMPT $old_PROMPT } ####################################################### puts "
########################## temp library ##########################"
# type 26 should be 3850 # type 22 should be 3016 # type 21 should be 24000 # type 23 should be production model number for Pulsar-24 # type 32 should be production model number for Pulsar-32 proc get_switch_platform {} { set switch_version 0
set switch_type [parse_real [get_after "switchShow" "switchType:"]] set switch_type [parse_integer $switch_type strict]
# set chassis_config [parse_real [get_after "chassisconfig" "Current Option:"]] # set chassis_config [parse_integer $chassis_config strict] if {$switch_type < "1"} { set switch_type [parse_real [get_after "agswitchshow" "switchType:"]] set switch_type [parse_integer $switch_type strict] if {$switch_type < "1"} { # The line below is needed to handle the case of a standby switch # which does not support the switchShow command to return a switchType set switch_version 12000 } else { set switch_version 3900 } } elseif {$switch_type == "32"} { set switch_version 3900 } elseif {$switch_type == "26"} { set switch_version 3900 } elseif {$switch_type == "27"} { set switch_version 3900 } elseif {$switch_type == "23"} { set switch_version 3900 } elseif {$switch_type == "22"} { set switch_version 3900 } elseif {$switch_type == "29"} { set switch_version 3900 } elseif {$switch_type == "21"} {
set chassis_config [parse_real [get_after "chassisconfig" "Current Option:"]] set chassis_config [parse_integer $chassis_config strict] if {$chassis_config == "2"} { set switch_version 12000 } else { set switch_version 12128 } } elseif {$switch_type == "17"} { set switch_version 3600 } elseif {$switch_type == "16"} { set switch_version 3200 } elseif {$switch_type == "12"} { set switch_version 3900 } elseif {$switch_type == "10"} { set switch_version 12000 } elseif {$switch_type == "9"} { set switch_version 3800 } elseif {$switch_type <= "8"} { set switch_version 2000 } elseif {$switch_type == "42"} { set switch_version 12128 } elseif {$switch_type == "33"} { set switch_version 3900 } elseif {$switch_type == "34"} { set switch_version 3900
} elseif {$switch_type == "44"} { set switch_version 3900 } elseif {$switch_type == "46"} { set switch_version 3900 } elseif {$switch_type == "37"} { set switch_version 3900 } elseif {$switch_type == "58"} { set switch_version 3900 } elseif {$switch_type == "55"} { set switch_version 3900 } elseif {$switch_type == "62"} { set switch_version 96000 } elseif {$switch_type == "120"} { set switch_version 96000 } elseif {$switch_type == "64"} { set switch_version 3900 } elseif {$switch_type == "66"} { set switch_version 3900 } elseif {$switch_type == "71"} { set switch_version 3900 } elseif {$switch_type == "67"} { set switch_version 3900 } elseif {$switch_type == "76"} { set switch_version 3900 } elseif {$switch_type == "77"} {
set switch_version 68000 } elseif {$switch_type == "121"} { set switch_version 68000 } elseif {$switch_type == "83"} { set switch_version 5000 } elseif {$switch_type == "109"} { set switch_version 6510 }
return $switch_version }