#########zone_pit############################################################ proc verify_zoning_across_failover {} {
global cl_HOST1_PORT global cl_HOST1_SLOT
add_status "PITSTEP: Switch Disable and Failover" 3 do_command "switchDisable"
perform_hafailover
add_status "PITSTEP: Switch enable after Failover" 3 do_command "=sleep 20" do_command "switchenable" do_command "=sleep 30"
add_status "PITSTEP: verify zoning" 3 do_command "cfgShow"
add_status "PITSTEP: Port Disable/Enable" 3 do_command "portDisable $cl_HOST1_SLOT/$cl_HOST1_PORT" do_command "portEnable $cl_HOST1_SLOT/$cl_HOST1_PORT"
add_status "PITSTEP: verify zoning" 3 do_command "cfgShow"
}
proc perform_ISL_bringup {} {
add_status "PITSTEP: Enable switch 1 to bringup ISL" 3" do_command "switchenable" do_command "=sleep 20"
add_status "PITSTEP: Verify the zones on switch 1" 3 do_command "cfgShow"
add_status "PITSTEP: Verify the zones on switch 0" 3 do_command "setswitch 0" } proc clear_cfg {{fid ""}} { if { $fid == 0 } { do_command "setswitch $fid" } do_command "cfgDisable" do_command "cfgClear" # Delay to allow other switches in fabric to process # a previous change, if done. do_command "=sleep 30" do_command "cfgSave" }
#########################################################
proc enable_disable_switch {sw_mode {ls_fid "128"} {sw_ip ""}} {
if {[regexp "^\[0-9]+\\.\[0-9]+\\.\[0-9]+\\.\[0-9]+\n$" [lindex $ls_fid 0]]} { set sw_ip $ls_fid add_status "2nd parameter to procedure is an IP address, or an IP address list, not a FID" }
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 daemon_status { } { global cl_ip4_address_list
foreach switch_ip $cl_ip4_address_list {
if {[set_spawn_id $switch_ip] != 0 } { if {[telnet_switch $switch_ip] != 0 } { add_status "Switch: $switch_ip not available" 0 } } add_status " Checking the Daemon status of the Switch" 3 set chkcon [get_command "chkconfig" ] add_status "Chkconfig for Switch IP $switch_ip is $chkcon" 2 add_status "Tracking the memory usage of Daemons" 3 set tp [get_command "ps -acux" ] add_status "Daemon memory usage for Switch IP $switch_ip is $tp" 2 } } ########################################## ######TELNETING SWITCH
proc login_switch {ip_address {user ""} {passwd ""}} { global cl_3x_ip_address_list global cl_ssh_program global cl_secure_telnet global cl_user_name global cl_user_password
if {$user == ""} { set user $cl_user_name
} if {$passwd == ""} { set passwd $cl_user_password }
add_status " User name and password is : $user $passwd" 3 if {[lsearch $cl_3x_ip_address_list $ip_address] != -1} { set old_secure_telnet $cl_secure_telnet set cl_secure_telnet 1 set old_ssh_program $cl_ssh_program set cl_ssh_program "" set ret_val [telnet_switch $ip_address $user $passwd] set cl_secure_telnet $old_secure_telnet set cl_ssh_program $old_ssh_program } else { set ret_val [telnet_switch $ip_address $user $passwd]
} return $ret_val }
#--END--# ##FOR DISABLING ALL THE SWITCHES IN THE FABRIC
proc disable_all_fabric_switches { } {
global cl_ip_address_list
foreach switch_ip $cl_ip_address_list { if {[set_spawn_id $switch_ip] != 0 } { if {[telnet_switch $switch_ip] != 0 } { add_status "Switch: $switch_ip not available" 0 } } do_command "switchdisable" } sleep 30 }
#--END--# proc device_member { member_type } { global device_wwn_list global device_port_list global domain_port_list
set device_wwn_list "" set device_port_list "" set domain_port_list "" set device_wwn_list [get_all_device_wwns node] set device_port_list [get_all_device_wwns] set device_port_list [get_all_device_ports]
foreach domain_port $device_port_list { set member_entry [replace_string $domain_port " " ","] if {$member_entry != ""} { append domain_port_list $member_entry } } switch $member_type { 0{ return $device_wwn_list } 1{ return $device_port_list } 2{ device_port_list } } } #--END--# proc domain_port_members { } { set free_port_list "" set port_count [get_after "switchshow -portcount" "ports = "] set port_count [lindex [split $port_count ","] 0 ] incr port_count -1 set switch_show_list [get_switchshow_info]
set switch_desc_list [lindex $switch_show_list 0] set port_desc_list [lindex $switch_show_list 1] set switch_domain [lindex [lindex $switch_desc_list 5] 1] append free_port_list "$switch_domain,0 " set no_sync_port_list [get_ports "No_Module"] #add_info "==> get_ports(No_Sync) $no_sync_port_list" set no_sync_area "" set area_count 1 foreach slot_port $no_sync_port_list { if {[regexp {.*ge.*} $slot_port ] } { add_status "Must continue" continue; } #
add_status "slot port: $slot_port" set area [convert_slotport_to_area $slot_port]
#
incr area_count 1 if {$area_count < [llength $no_sync_port_list]} { append free_port_list "$switch_domain,$area " } elseif {$area_count == [llength $no_sync_port_list]} { append free_port_list "$switch_domain,$area" } incr area_count 1 } #set area [convert_slotport_to_area [lindex $no_sync_port_list \
#
[llength $no_sync_port_list]]]
#
append free_port_list "$switch_domain,$area" return $free_port_list
} #---END---# proc cfg_zone_trans { config_type {zone_name ""} {zone_member_list ""} \ {cfg_name ""} } { switch $config_type { "clear" { if {[retry_command "cfgclear"] == 0} { if {[retry_command "cfgsave"] == 0} { add_status "Zone configuration is cleared successfully" 3 } else { add_status "Unable to commit cleared zone transaction" 1 } } else { add_status "Unable to clear the existing zone configuration" 1 } } "disable" { if {[retry_command "cfgdisable"] == 0} { if {[retry_command "cfgsave"] == 0} { add_status "Zone configuration disabled successfully" 3 } else { add_status "Unable to commit disabled zone transaction" 1
} } else { add_status "Unable to disable the existing effective zone \ configuration" 1 } } "enable" { if {[retry_command "cfgdisable"] == 0} { if {[retry_command "cfgsave"] == 0} { add_status "Zone configuration enabled successfully" 3 } else { add_status "Unable to commit enabled zone transaction" 1 } } else { add_status "Unable to enable the defined zone configuration" 1 } } "zonecreate" { if {[retry_command "zonecreate \"$zone_name\",\"$zone_member_list\"\
"] == 0} {
add_status "Zone $zone_name created successfully " 3 } else { add_status "Unable to create zone" 1 } }
"cfgcreate" { if {[retry_command "cfgcreate \"$cfg_name\",\"$zone_name\""] == 0} { add_status "Zone configuration $cfg_name created successfully "3 } else { add_status "Unable to create zone configuration" 1 } } default { if {[retry_command "cfgsave"] == 0} { add_status "Zone transaction commited successfully" 3 } else { add_status "Unable commit the zone transaction" 1 } } } } #---END---# proc get_domain_id { } { set switch_show_list [get_switchshow_info] set switch_desc_list [lindex $switch_show_list 0] set port_desc_list [lindex $switch_show_list 1] set switch_domain [lindex [lindex $switch_desc_list 5] 1] return $switch_domain } #---END---#
proc get_core_pid { } { set config_verify "fabric.ops.mode.pidFormat:1" set config_pid "fabric.ops.mode.pidFormat:1" if {[cause "configshow fabric|grep $config_pid" $config_verify] == 0} { return 1 } else { return 2 } } #---END---# proc configure_switch_pid { switch_pid } { if {[configure_items "Switch PID Format" $switch_pid] == 1} { add_status "Core PID value is changed to $switch_pid" 3 } else { add_status "unable to change Core PID value to $switch_pid" 1 } } #---END---# proc change_zone_configuration { config_command } { set max_try 5 set init_try 1 while {$init_try <= $max_try } { set config_result [do_command $config_command] if { $config_result != 0 } { incr init_try 1
sleep 10 } else { return 0 } } return -1 } #---END---# ########################################################################### ## NAME ## init_member ## ## DESCRIPTION ##
This procedure will populate the members needed for zone object
## ald also it will initialize all necessary global variables needed ## for this script. ## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
device_member
##
get_all_device_wwns
##
get_all_device_ports
##
replace_string
##
get_switchshow_info
##
get_switch_platform
## ## RETURN: ##
NONE
## ## USAGE: ##
init_member
########################################################################### proc init_zone_config { args } { #---- Variable declariation ----# global zone_name global cfg_name global zone_count global zone_member_list global zone_scenario global alias_name
global device_wwn_list global domain_port_list
#---- variable initialization ----# set zone_name "zone_art" set cfg_name "cfg_art" set alias_name "alias_art"
set zone_count 1 set zone_member_list "" set zone_scenario 0
set member_type 0
set node_flag [lsearch $args "node"] set pnode_flag [lsearch $args "pnode"] set port_flag [lsearch $args "port"] set lsan_flag [lsearch $args "lsan"] set alias_flag [lsearch $args "alias"] set zone_flag [lsearch $args "zone"]
if {$lsan_flag == 0} { set zone_name "LSAN_zone_art" }
if {$node_flag > -1} { set member_type 0 } elseif {$pnode_flag > -1} { set member_type 2 }
set device_wwn_list ""
if {($pnode_flag > -1 ) || ($node_flag > -1) || ($zone_flag > -1) || ($alias_flag > -1)} { #---- Gathering device WWN list across the fabric ----# set device_wwn_list_temp [device_member $member_type] if {($device_wwn_list_temp != "") && ([llength $device_wwn_list] > 1)} { append device_wwn_list " [lindex $device_wwn_list_temp 0]" } for {set element_index 1} {$element_index <= [expr \ [llength $device_wwn_list_temp] - 2]}\ {incr element_index 1} { if {($device_wwn_list_temp != "") || ([llength $device_wwn_list] > 1)} { append device_wwn_list " [lindex $device_wwn_list_temp $element_index]" } } append device_wwn_list " [lindex $device_wwn_list_temp $element_index]" }
#---- Gathering domain,port list ----# if {($port_flag > -1) || ($zone_flag > -1) || ($alias_flag > -1)} { set domain_port_list [domain_port_members] }
#---- Populating zone member list ----# if {($device_wwn_list != "") || ([llength $device_wwn_list] > 1)} { append zone_member_list $device_wwn_list }
if {$zone_member_list == "" } { set zone_member_list $domain_port_list } else { append zone_member_list " $domain_port_list" }
set zone_members [join $zone_member_list "; " ] set zone_name "$zone_name\_$zone_count" set cfg_name "$cfg_name\_$zone_count" incr zone_count 1 #---- Configuring zone ----# if {[lsearch $args "alias"] > -1} { if {[retry_command "alicreate \"$alias_name\", \"$zone_members\""] == 0} { add_status "Created alias successfully" 3 } else { add_status "Unable to create alias" 1 } if {[retry_command "zonecreate \"$zone_name\", \"$alias_name\""] == 0} { add_status "Created zone with $alias_name alias member successfully" 3 } else { add_status "Unable to create zone with $alias_name alias member" 1 } } if {[lsearch $args "zone"] > -1} {
if {[retry_command "zonecreate \"$zone_name\", \"$zone_members\""] == 0} { add_status "Created zone successfully" 3 } else { add_status "Unable to create zone" 1 } } if {[retry_command "cfgcreate \"$cfg_name\", \"$zone_name\""] == 0} { add_status "Zone configuration created successfully" 3 } else { add_status "Unable to create zone configuration" 1 } if {[change_zone_configuration "cfgsave"] == 0} { add_status "Commited the zone configuration successfully" 3 } else { add_status "Unable to commit the zone transaction" 1 } do_command "cfgshow" } #---END---# proc check_changed_domainid { id } { set domain_list "" set fabric_show_info [get_fabricshow_info] foreach fabric_info $fabric_show_info { set domain_id [lindex $fabric_show_info 0] lappend domain_list $domain_id
}
if {[lsearch $domain_list $id] != -1} { return 0 } else { return 1 } }
proc get_ad_supported_switches { } {
set fabric_info [get_fabricshow_info] global switch_wwn set command_output [get_command "distribute -p pwd -d \"*\""] set command_output [split $command_output "\n"]
# identify AD supported switch ips set position "" set count 0 foreach line $command_output { if {[regexp {.*Wildcard domains are.*} $line] } { set position [ expr $count + 1 ] break; }
incr count } set ad_domain_list [lindex $command_output $position ]
# create list of switch ips which supports AD set ad_ip_addr_list "" foreach switch_info $fabric_info { if {[lsearch $ad_domain_list [lindex $switch_info 0]] != -1 } { set switch_ip [lindex $switch_info 2] lappend ad_ip_addr_list $switch_ip } } return $ad_ip_addr_list } ############################################## ############################################################################## ### ## NAME ## check_nszone_member ## ## SYNOPSIS ## check_nszone_member ## ## DESCRIPTION ## Verifies the local and remote zone members from the given wwn ##
## OPERANDS ##
wwn : check zone membership with this wwn
##
expected_local : number of local devices
##
expected_remote : number of remote devices
## ## DEPENDENCIES ## ## RETURN ##
None.
## ## USAGE ## check_nszone_member "10:00:00:12:19:90:12:12 1 2" ############################################################################## ###
proc check_nszone_member {wwn expected_local expected_remote} { set nszone_mem [get_before "nszonemember $wwn" "zoned members" 1] if {$expected_local == 0} { set expected_local "No local" } else { set expected_local "$expected_local local" }
if {$expected_remote == 0} { set expected_remote "No Remote" } else {
set expected_remote "$expected_remote remote" }
if {[trim_string [lindex $nszone_mem 0]]!=$expected_local} { add_status "Improper display of local nszone membership, Expected $expected_local, Found [lindex $nszone_mem 0] " 1 }
if {[trim_string [lindex $nszone_mem 1]]!=$expected_remote} { add_status "Improper display of remote nszone membership, Expected $expected_remote, Found [lindex $nszone_mem 1] " 1 } }
############################################################################ ############################################################################## ### ## NAME ## lsan_add_zone ## ## SYNOPSIS ## lsan_add_zone ## ## DESCRIPTION ## Additon of devices to existing lsan zone ## ## OPERANDS
##
Zone Name
##
Device WWN in form of string appended by ;
##
One optional Parameter i.e zone configuration
## ## DEPENDENCIES ## ## RETURN ##
None.
## ## USAGE ##
lsan_add_zone lsan_1 10:00:00:12:19:90:12:12;10:00:00:12:19:90:12:13 cfg1
############################################################################## ### proc lsan_add_zone {zone_name zone_mem_string {zone_conf ""}} { global cl_ip_address add_status "Entered into zone addtion Procedure" 3 do_command "zoneadd $zone_name, $zone_mem_string" add_status "Executed zoneadd command" 3 retry_command "cfgsave" if {$zone_conf != ""} { retry_command "cfgenable $zone_conf" sleep 50 do_command "cfgshow" set zone_effective_list [verify_zones $zone_name EFFECTIVE "" $cl_ip_address] set zone_mem_list [split $zone_mem_string ";"] foreach $zone_mem_list $zone_effective_list {
if {[lsearch $zone_mem_list $zone_effective_list]==-1} { add_status "$zone_mem_list is found in the effective configuration list" 3 } else { add_status "Not found in the effective configuration" 3 } } } } ############################################################################## ### ## NAME ## verify_remote_device_presence ## ## SYNOPSIS ## verify_remote_device_presence ## ## DESCRIPTION ## This routine verifies whether given list of devices wwn's can be found through nscamshow. ## ## OPERANDS ##
wwn_list
## ## DEPENDENCIES ##
None
## ## RETURN
##
None.
## ## USAGE ## verify_remote_device_presence "22:00:00:20:37:e1:b6:6f 22:00:00:20:37:e8:c4:1d" ############################################################################## ## proc verify_remote_device_presence {wwn_list} { set ns_remote_wwn_list [get_all_remote_device_wwns] foreach wwn $wwn_list { if {[lsearch $ns_remote_wwn_list $wwn]==-1} { add_status "Not able to view $wwn through nscamshow" 1 } else { add_status "Able to view $wwn through nscamshow" } } } ############################################################################## ### ## NAME ## lsan_remove_zone ## ## SYNOPSIS ## lsan_remove_zone ## ## DESCRIPTION ## Removal of devices from a existing lsan zone
## ## OPERANDS ##
Zone Name
##
Device WWN in form of string
##
One optinal parameter i.e.zone configuration
## ## ## DEPENDENCIES ## ## RETURN ##
None.
## ## USAGE ## lsan_remove_zone lsan_1 10:00:00:12:19:90:12:12;10:00:00:12:19:90:12:13 cfg1
############################################################################## ### proc lsan_remove_zone { zone_name zone_mem_string {zone_conf ""}} { do_command "zoneremove $zone_name, $zone_mem_string" add_status "Executed ZoneRemove Command" 3 retry_command "cfgsave" if {$zone_conf != ""} { retry_command "cfgenable $zone_conf" sleep 50 do_command "cfgshow" global cl_ip_address
set zone_effective_list [verify_zones $zone_name EFFECTIVE "" $cl_ip_address] set zone_mem_list [split $zone_mem_string ";"] foreach $zone_mem_list $zone_effective_list { if {[lsearch $zone_mem_list $zone_effective_list]==-1} { add_status "$zone_mem_list is not found in the effective configuration list" 3 } else { add_status "$zone_mem_list is Found in the effective configuration" 1 } } } }
############################################################################## ### ## NAME ## get_expected_zone ## ## SYNOPSIS ## get_expected_zone zone_list ## ## DESCRIPTION ## Given the list of devices participating in zone, says which type of zone should be. ## (Hard Port, Hard WWN or Session Based zoning type) ## ## OPERANDS ##
zone_list :list of device wwn(D,P or WWN) participating in zone.
## ## DEPENDENCIES ##
None
## ## RETURN ##
0 . Hard Port
##
1 . Hard WWN
##
2 . Session Based
## ## USAGE ## get_expected_zone "3,4 5,2" Returns 0 ############################################################################## ##
proc get_expected_zone {zone_list} { # Find out whether zoning is hard wwn, hard port or soft zone set zone_port 0 set zone_wwn 0 set zone_soft 0 set zone_mem_cnt [llength $zone_list] foreach zone_member $zone_list { if {[regexp {([0-9]+),([0-9]+)} $zone_member]} { incr zone_port } elseif {[regexp {(.*):(.*)} $zone_member]} { incr zone_wwn }
}
if {$zone_port==$zone_mem_cnt} { return 0 } elseif {$zone_wwn==$zone_mem_cnt} { return 1 } else { return 2 } }
########################################################################### ## NAME ## get_ns_info [ip_list] ## ## SYNOPSIS ##
get_ns_info [ip_list]
## ## DESCRIPTION ##
Gets information about wwn and associated D,P in the fabric and
##
initializes the global variables.
##
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 ##
initialize_device_array
## ## RETURN ##
Global variables are set
## ## USAGE ##
get_ns_info
## ###################################################################
proc get_ns_info {{ip_list ""} } { global cl_ip_address_list global cl_ip_address global lportwwn_list fportwwn_list lportdp_list fportdp_list devicewwn_list sw_domain_list sw_wwn_list global array lportwwn fportwwn fportdp lportdp global array fportlist global array lportlist
if {$ip_list==""} { initialize_device_array set ip_list $cl_ip_address_list } else {
initialize_device_array $ip_list }
foreach ip $ip_list { add_status "fport list for $ip is $fportlist($ip)" add_status "lport list for $ip is $lportlist($ip)" } add_status "LPORTLIST=$lportlist($ip)####==>" 3 # Creating F-Port/L-Port WWN and D,P list foreach ip $ip_list { if {$lportlist($ip)!=""} { #
add_status "LPORTLIST=$lportlist($ip)####==>" 3 for {set i 1} {$i<=[expr [llength $lportlist($ip)]+1]} {incr i 2} { append lportwwn_list [lindex $lportlist($ip) $i] append lportwwn_list " " } } else { set lportwwn_list "" } }
foreach ip $ip_list { if {$fportlist($ip)!=""} { for {set i 1} {$i<=[expr [llength $fportlist($ip)]+1]} {incr i 2} { append fportwwn_list [lindex $fportlist($ip) $i]
append fportwwn_list " " } } }
foreach ip $ip_list { if {$lportlist($ip)!=""} { for {set i 0} {$i<=[llength $lportlist($ip)]} {incr i 2} { append lportdp_list [lindex $lportlist($ip) $i] append lportdp_list " " } } }
foreach ip $ip_list { for {set i 0} {$i<=[llength $fportlist($ip)]} {incr i 2} { append fportdp_list [lindex $fportlist($ip) $i] append fportdp_list " " } }
# Creating portwwn list for each switch foreach ip $ip_list { if {$lportlist($ip)!=""} { for {set i 1} {$i<=[expr [llength $lportlist($ip)]+1]} {incr i 2} {
append lportwwn($ip) [lindex $lportlist($ip) $i] append lportwwn($ip) " " } } else { set lportwwn($ip) "" } }
foreach ip $ip_list { if {$fportlist($ip)!=""} { for {set i 1} {$i<=[expr [llength $fportlist($ip)]+1]} {incr i 2} { append fportwwn($ip) [lindex $fportlist($ip) $i] append fportwwn($ip) " " } } else { set fportwwn($ip) "" } }
# Creating dp list for each switch foreach ip $ip_list { if {$fportlist($ip)!=""} { for {set i 0} {$i<=[llength $fportlist($ip)]} {incr i 2} { append fportdp($ip) [lindex $fportlist($ip) $i] append fportdp($ip) " "
} } else { set fportdp($ip) "" } } foreach ip $ip_list { if {$lportlist($ip)!=""} { for {set i 0} {$i<=[llength $lportlist($ip)]} {incr i 2} { append lportdp($ip) [lindex $lportlist($ip) $i] append lportdp($ip) " " } } else { set lportdp($ip) "" } }
foreach ip $ip_list { if {($fportwwn($ip)=="") && ($lportwwn($ip)=="")} { set devicewwn($ip) "" } elseif {$fportwwn($ip)==""} { set devicewwn($ip) $lportwwn($ip) } elseif {$lportwwn($ip)==""} { set devicewwn($ip) $fportwwn($ip) } else { append devicewwn($ip) $fportwwn($ip) " " $lportwwn($ip)
} } append devicewwn_list $lportwwn_list " " $fportwwn_list
set fabric_info [get_fabric_info]
# Storing all the wwn's available for a switch foreach individual_switch $fabric_info { append sw_domain_list [lindex $individual_switch 0] append sw_domain_list " " }
foreach individual_switch $fabric_info { append sw_wwn_list [lindex $individual_switch 1] append sw_wwn_list " " } } ########################################################################### ## NAME ## default_zone ## ## SYNOPSIS ##
default_zone type
## ## DESCRIPTION
##
Sets default zone to noaccess or allaccess based on type given
## ## OPERANDS ##
type - Type of default zone, can be all or no access
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
default_zone noaccess
## ###################################################################
proc default_zone {type {cfg_verify "yes"}} { if {$type=="noaccess"} { do_command "defzone --noaccess" if {$cfg_verify == "yes"} { 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 {$cfg_verify == "yes"} { 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 } } } elseif {$type=="allaccess"} { 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 } } }
########################################################################### ## NAME ## verify_session_zone ## ## SYNOPSIS ##
verify_session_zone dp_wwn_list
## ## DESCRIPTION ## Verifies zone type is session based and checks portcam entries are empty ## ## OPERANDS ##
dp_wwn_list - D,P or WWN whose area will be used to find zone type
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
verify_session_zone 1,3
## ################################################################### proc verify_session_zone {dp_wwn_list} { set dp_wwn [lindex $dp_wwn_list 0] if {[regexp {([0-9]+),([0-9]+)} $dp_wwn complete domain area]} { set area $area } elseif {[regexp {(.*):(.*)} $dp_wwn]} { set input_pid [get_wwn_pid [lindex $dp_wwn 0]] set area [convert_to_dec [get_pid_port $input_pid]] } else { set area $dp_wwn } verify_session_zonetype $area verify_empty_cam $area }
########################################################################### ## NAME ## verify_hardport_zone ## ## SYNOPSIS ##
verify_hardport_zone dp member_list
## ## DESCRIPTION ## Verifies zone type is Hard Port and checks portcam entries ## ## OPERANDS ## dp - D,P which will be converted to DID also whose area will be used for portcamshow and portzoneshow ##
member_list - D,P which will be converted to SID and verified
##
ad - 0: wwn is converted to PID using nsshow and nscamshow
##
1: PID is got from database this can happen when its shared device
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
verify_hardport_zone 1,3 "4,5 12,3"
## ###################################################################
proc verify_hardport_zone {dp member_list} { if {[regexp {([0-9]+),([0-9]+)} $dp complete domain area]} { verify_hardport_zonetype $area check_cam_entries $dp $member_list
} else { verify_hardport_zonetype $dp } }
########################################################################### ## NAME ## verify_hardwwn_zone ## ## SYNOPSIS ## verify_hardwwn_zone area ## ## DESCRIPTION ## Verifies zone type is Hard WWN and checks portcam entries ## ## OPERANDS ##
wwn - wwn of DID whose area will be used for portcamshow and portzoneshow
##
member_list - wwn's which will be converted to SID and verified
##
ad<optional> - 0: wwn is converted to PID using nsshow and nscamshow
## shared device ## ## DEPENDENCIES ##
NONE
## ## RETURN
1: PID is got from database, this will be used when its
##
NONE
## ## USAGE ##
verify_hardwwn_zone 10:00:00:00:c9:2b:9d:30 10:00:00:00:c9:2b:9d:31
## ###################################################################
proc verify_hardwwn_zone {wwn member_list {ad 0}} { if {$ad==0} { set input_pid [get_wwn_pid [lindex $wwn 0]] } else { set input_pid [get_wwn_pid_db [lindex $wwn 0]] } set area [convert_to_dec [get_pid_port $input_pid]] verify_hardwwn_zonetype $area if {$ad==0} { check_cam_entries $wwn $member_list } else { check_cam_entries $wwn $member_list 1 } }
########################################################################### ## NAME ## verify_allaccess_zonetype
## ## SYNOPSIS ##
verify_allaccess_zonetype
## ## DESCRIPTION ## Verify whether the zone type is all access ## ## OPERANDS ##
area - Area of the port whose zone type needs to be All access
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
verify_allaccess_zonetype 4
###################################################################
proc verify_allaccess_zonetype {area} { set exp_zone_type "ALL" set zone_type [get_zone_type $area] if {$exp_zone_type !=$zone_type} { add_status "Expected $exp_zone_type, Found $zone_type zone type at $area" 1
} }
########################################################################### ## NAME ## verify_session_zonetype ## ## SYNOPSIS ## verify_session_zonetype area ## ## DESCRIPTION ## Verify whether the zone type is Session Based ## ## OPERANDS ##
area - Area of the port whose zone type needs to be Session Based
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ## ##
verify_session_zonetype 4
###################################################################
proc verify_session_zonetype {area} { set exp_zone_type "SESSION BASED HARD" set zone_type [get_zone_type $area] if {$exp_zone_type !=$zone_type} { add_status "Expected $exp_zone_type, Found $zone_type zone type" 1 } } ########################################################################### ## NAME ## verify_hardport_zonetype ## ## SYNOPSIS ## verify_hardport_zonetype area ## ## DESCRIPTION ## Verify whether the zone type is Hard port ## ## OPERANDS ##
area - Area of the port whose zone type needs to be HARD PORT
## ## DEPENDENCIES ## ##
NONE
## RETURN ##
NONE
## ## USAGE ##
verify_hardwwn_zonetype 4
## ################################################################### proc verify_hardport_zonetype {area} { set exp_zone_type "HARD PORT" set zone_type [get_zone_type $area] if {$exp_zone_type !=$zone_type} { add_status "Expected $exp_zone_type, Found $zone_type zone type at $area" 1 } }
########################################################################### ## NAME ## verify_hardwwn_zonetype ## ## SYNOPSIS ## verify_hardwwn_zonetype area ## ## DESCRIPTION ## Verify whether the zone type given area is Hard WWN ##
## OPERANDS ##
area - Area of the port whose zone type needs to be HARD WWN
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
verify_hardwwn_zonetype 4
## ################################################################### proc verify_hardwwn_zonetype {area} { set exp_zone_type "HARD WWN" set zone_type [get_zone_type $area] if {$exp_zone_type !=$zone_type} { add_status "Expected $exp_zone_type, Found $zone_type zone type" 1 } }
########################################################################### ## NAME ## get_zone_type ##
## SYNOPSIS ## get_zone_type area ## ## DESCRIPTION ##
Get the zone type given area of port. It can be Session based,
##
Hard port or wwn based
## ## OPERANDS ##
port_area - Area of the port whose zone type needs to be found
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
Zone type: HARD WWN, HARD PORT OR SESSION BASED
## ## USAGE ##
get_zone_type 4
## ################################################################### proc get_zone_type {area} { set zone_type_string [get_after "portzoneshow" "PORT: $area"] set zone_type_list [split $zone_type_string ":"] set zone_type [lindex $zone_type_list 1] regexp (.*)default $zone_type expres zone_type
add_status "Zone type on port $area is $zone_type" return [trim_string $zone_type] }
########################################################################### ## NAME ## check_cam_entries ## ## SYNOPSIS ##
check_cam_entries dp_wwn src_dp_wwn
## ## DESCRIPTION ##
Check whether CAM entries are proper for given wwn
## ## OPERANDS ##
dp_wwn - D,P or wwn whose PID will be compared to DID
##
src_dp_wwn - D,P or wwn whose PID will be compared to SID
##
ad - 0(if wwn is used gets PID from nsshow/nscamshow)
## ##
- 1(if wwn is used which is not part of AD takes from global database port_area - Area of the port whose CAM entries is required
## ## DEPENDENCIES ##
NONE
## ## RETURN
##
add_status message indicating pass or fail
## ## USAGE ##
get_siddid_entries 5,1 4,2
## ################################################################### proc check_cam_entries {dp_wwn src_dp_wwn {ad 0}} { global array wwn_pid_list #
Portcam entries checking with D,P if {[regexp {([0-9]+),([0-9]+)} $dp_wwn complete domain area]} {
#
DID Verification set exp_did "" set cam_list [get_siddid_entries $area] set did [lindex $cam_list 1] if {($domain<10)&&($area<10)} { set domain 0$domain set area 0$area set exp_did "$domain$area" } elseif {($domain<10)&&($area>=10)} { set domain 0$domain set exp_did "$domain[convert_to_hex $area]" } elseif {($domain>=10)&&($area<10)} { set area 0$area set exp_did [convert_to_hex $domain]$area } else {
set exp_did "[convert_to_hex $domain][convert_to_hex $area]" } append exp_did 00 if {$exp_did==$did} { add_status "DID is proper" 3 } else { add_status "DID is wrong Expected $exp_did Found $did" 1 } #
SID Verification set exp_sid_list "" set sid_list [lindex $cam_list 0] foreach src_dp $src_dp_wwn { if {[regexp {([0-9]+),([0-9]+)} $src_dp complete domain area]} { if {($domain<10)&&($area<10)} { set domain 0$domain set area 0$area set exp_sid "$domain$area" } elseif {($domain<10)&&($area>=10)} { set domain 0$domain set exp_sid "$domain[convert_to_hex $area]" } elseif {($domain>=10)&&($area<10)} { set area 0$area set exp_sid [convert_to_hex $domain]$area } else { set exp_sid "[convert_to_hex $domain][convert_to_hex
$area]"
} set exp_sid [append $exp_sid $exp_sid 00] append exp_sid_list $exp_sid " " } } set sid_list [lsort $sid_list] ## Raghavan: set new_sid_list "" foreach sid $sid_list { if {[lsearch $did $sid]==-1} { append new_sid_list $sid " " } } set new_sid_list [lsort $new_sid_list] set exp_sid_list [lsort $exp_sid_list] set compare_result [compare_lists $new_sid_list $exp_sid_list] if {$compare_result != ""} { add_status "sid did not match expected $exp_sid_list and found $new_sid_list" 1 } else { add_status "SID is proper" 3 } } else { #
Zoned devices are WWN foreach wwn $dp_wwn { if {$ad==0} {
append exp_did_list [get_wwn_pid $wwn] " " } else { append exp_did_list [get_wwn_pid_db $wwn] " " } } #
DID Verification set exp_did_list [trim_string $exp_did_list] set exp_did_list [lsort $exp_did_list] set input_pid [lindex $exp_did_list 0] set area [convert_to_dec [get_pid_port $input_pid]] set cam_list [get_siddid_entries $area] set did_list [lsort [lindex $cam_list 1]] set compare_result [compare_lists $did_list $exp_did_list] if {$compare_result != ""} { add_status "Did did not match expected $exp_did_list found $did_list" 1 } else { add_status "Did is proper" }
#
Verification of SID Entries set sid_list [lindex $cam_list 0] set new_sid_list "" foreach sid $sid_list { if {[lsearch $did_list $sid]==-1} { append new_sid_list $sid " " }
} foreach src_wwn $src_dp_wwn { if {$ad==0} { append exp_sid_list [get_wwn_pid $src_wwn] " " } else { append exp_sid_list [get_wwn_pid_db $src_wwn] " " } } set new_sid_list [lsort $new_sid_list] set exp_sid_list [lsort $exp_sid_list] set compare_result [compare_lists $new_sid_list $exp_sid_list] if {$compare_result != ""} { add_status "Sid did not match expect $exp_sid_list found $new_sid_list" 1 } else { add_status "Sid is proper" } } }
########################################################################### ## NAME ## get_siddid_entries ## ## SYNOPSIS ##
get_siddid_entries port_area
## ## DESCRIPTION ##
Get SID and DID entries for given port
## ## OPERANDS ##
port_area - Area of the port whose CAM entries is required
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
{019293 121112} {018909}
## ## USAGE ##
get_siddid_entries 39
## ################################################################### proc get_siddid_entries {port_area} { set portcam_list [get_portcam_entries $port_area] set sid [lindex $portcam_list 2] set did [lindex $portcam_list 3] set sid_did "{$sid} {$did}" return $sid_did }
########################################################################### ## NAME ##
verify_empty_cam
## ## SYNOPSIS ##
verify_empty_cam port_area
## ## DESCRIPTION ##
Verify whether port should not show any portcam entries
## ## OPERANDS ##
port_area - Area of the port whose CAM entries is required
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
None
## ## USAGE ##
verify_empty_cam 39
## ###################################################################
proc verify_empty_cam {port_area} {
set portcam_list [get_portcam_entries $port_area] set sid [lindex $portcam_list 2] set did [lindex $portcam_list 3] set domain [trim_string [parse_integer [get_after "switchshow" "switchDomain:"]]] if {($domain<10)&&($port_area<10)} { set domain 0$domain set area 0$port_area set exp_did "$domain$area" } elseif {($domain<10)&&($port_area>=10)} { set domain 0$domain set exp_did "$domain[convert_to_hex $port_area]" } elseif {($domain>=10)&&($port_area<10)} { set area 0$port_area set exp_did [convert_to_hex $domain]$port_area } else { set exp_did "[convert_to_hex $domain][convert_to_hex $port_area]" }
if {(($sid==000000)&&($did==000000))||([string match $exp_did* $did])||([string match $exp_did* $sid])} { add_status "CAM entries are empty as expected" 3 } else { add_status "CAM entries are not empty" 1 } }
########################################################################### ## NAME ##
get_portcam_entries
## ## SYNOPSIS ##
get_portcam_entries port_area
## ## DESCRIPTION ##
Gives the portcam entries, SID/DID used in a list
## ## OPERANDS ##
port_area - Area of the port whose CAM entries is required
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
List containing SID/DID used, SID/DID portcam entries
## ## USAGE ## ##
get_portcam_entries 39 Return value->3 1 {012700 010100 010200} 012700
## ################################################################### proc get_portcam_entries {port_area} {
if {[get_switch_platform] >= 12000} { set port_area [convert_to_slotport $port_area] } set port_cam_list [make_matrix "portcamshow $port_area" "----------" "SID free" 6 10 10 9 13] set port_cam_list [lreplace $port_cam_list [expr [llength $port_cam_list]-1] [expr [llength $port_cam_list]-1]] set port_cam_list [lreplace $port_cam_list 0 0] foreach row $port_cam_list { set row [lreplace $row [expr [llength $row]-1] [expr [llength $row]-1]] lappend final_portcam_list $row } foreach portcam_entry $final_portcam_list { set did [trim_string [lindex $portcam_entry 3]] append did_list $did " " } foreach portcam_entry $final_portcam_list { set sid [trim_string [lindex $portcam_entry 4]] append sid_list $sid " " } set portcam_entry [lindex $final_portcam_list 0] set portcam_list "[lindex $portcam_entry 1] [lindex $portcam_entry 2] {[trim_string $did_list]} {[trim_string $sid_list]}" return $portcam_list }
###########################################################################
## NAME ##
get_free_sid_did
## ## SYNOPSIS ##
get_free_sid_did port_area
## ## DESCRIPTION ##
Tests basic zoneobjectrename and zoneobjectcopy commands
## ## OPERANDS ##
port_area - Area of the port whose CAM entries is required
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
list containing free SID and DID
## ## USAGE ## ##
get_free_sid_did 39 Return->61 511
################################################################### proc get_free_sid_did {port_area} { if {[get_switch_platform] >= 12000} { set port_area [convert_to_slotport $port_area]
} set free_id [get_after "portcamshow $port_area" "SID free, DID free: "] regexp {\((.*),(.*)\)} $free_id strg sid did set did [trim_string $did] return "$sid $did" }
########################################################################### ## NAME ##
zone_renamecopy_test -tests zoneobject rename and copy
## ## SYNOPSIS ##
zone_renamecopy_test
## ## DESCRIPTION ##
Tests basic zoneobjectrename and zoneobjectcopy commands
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
zone_renamecopy_test
## ################################################################### proc zone_renamecopy_test { } { # Testing zoneobjectrename by renaming zone_copy to zone_copy1 set key eng set wwn_list [get_all_device_wwns] create_zone $key $wwn_list
set zone_name zone_eng do_command "zoneobjectrename $zone_name,zone_partner" do_command "cfgsave"
# Verification of defined zone set zone_defined_list [verify_zones zone_partner Defined] set compare_result [compare_lists [lsort $zone_defined_list] [lsort $wwn_list]] if {$compare_result != ""} { add_status "There is variation in defined zone configuration and given zone configuration: $compare_result" 1 }
# Testing zoneobjectcopy by copying zone_copy1 to zone_copy do_command "zoneobjectcopy zone_partner,zone_eng" do_command "cfgsave"
# Verification of the zone copied in the defined configuration set zone_defined_list [verify_zones zone_eng Defined] set compare_result [compare_lists [lsort $zone_defined_list] [lsort $wwn_list]] if {$compare_result != ""} { add_status "There is variation in defined zone configuration and given zone configuration: $compare_result" 1 }
# Testing of zoneobjectexpunge by removing zone_partner zone do_command "zoneobjectexpunge zone_eng" do_command "cfgsave"
if {[count_number "cfgshow" "zone_partner"]==1} { add_status "zoneobjectexpunge did not sucessfully remove zone" 1 } else { add_status "zoneobjectexpunge sucessfully removed the zone" 3 } }
########################################################################### ## NAME ##
default_zone_test -tests default zone property
## ## SYNOPSIS ##
default_zone_test
## ## DESCRIPTION ##
Tests basic defaultzone property
## ## OPERANDS ##
NONE
## ## DEPENDENCIES ##
NONE
## ## RETURN ##
NONE
## ## USAGE ##
default_zone_test