2
puts "FLOW: duplicate some port guid"
4
# duplicate the port guid from the source to the dest
5
proc dupPortGuid {fromNodeNPort toNodeNPort} {
7
# IBDM has a limitation of not holding "end ports"
8
# instead only physical ports are available.
9
# So in case of a switch port (port num 0) we need to handle all physical ports
12
# do we have a switch as the guid to duplicate?
13
set node [lindex $fromNodeNPort 0]
14
if {[lindex $fromNodeNPort 1] == 0} {
15
# just use the port 1 instead
16
set port [IBNode_getPort $node 1]
17
set fromPortName "[IBNode_name_get $node]/P0"
19
set port [IBNode_getPort $node [lindex $fromNodeNPort 1]]
20
set fromPortName [IBPort_getName $port]
22
set newGuid [IBPort_guid_get $port]
24
# do we have a switch port 0 as a target?
25
set node [lindex $toNodeNPort 0]
26
if {[lindex $toNodeNPort 1] == 0} {
27
set numPorts [IBNode_numPorts_get $node]
28
for {set pn 1} {$pn <= $numPorts} {incr pn} {
29
set port [IBNode_getPort $node $pn]
31
lappend targetPorts $port
34
set simNodeInfo [IBMSNode_getNodeInfo sim$node]
35
puts "-I- Overriding node:[IBNode_name_get $node] port guid to $newGuid (dup of $fromPortName)"
36
ib_node_info_t_port_guid_set $simNodeInfo $newGuid
38
set port [IBNode_getPort $node [lindex $toNodeNPort 1]]
43
foreach port $targetPorts {
44
puts "-I- Overriding port:[IBPort_getName $port] guid to $newGuid (dup of $fromPortName)"
45
IBPort_guid_set $port $newGuid
49
# get a random order of all the fabric endports:
50
# a list of {node port-num random}
51
proc getEndPortsByRandomOreder {fabric} {
52
# get number of nodes:
53
set nodesByName [IBFabric_NodeByName_get $fabric]
55
set nodePortNOrderList {}
56
foreach nodeNameNId [IBFabric_NodeByName_get $fabric] {
57
set node [lindex $nodeNameNId 1]
59
# each node might be a switch (then take port 0)
60
if {[IBNode_type_get $node] == 1} {
61
lappend nodePortNOrderList [list $node 0 [rmRand]]
63
# only connected ports please:
64
set numPorts [IBNode_numPorts_get $node]
65
for {set pn 1} {$pn <= $numPorts} {incr pn} {
66
set port [IBNode_getPort $node $pn]
67
if {($port != "") && ([IBPort_p_remotePort_get $port] != "")} {
68
lappend nodePortNOrderList [list $node $pn [rmRand]]
75
foreach nodePortNRnd [lsort -index 2 -real $nodePortNOrderList] {
76
lappend randNodes [lrange $nodePortNRnd 0 1]
81
# setup post SM run changes:
82
proc postSmSettings {fabric} {
83
return "-I- Nothing to be done post SM"
86
# make sure ibdiagnet reported the bad links
87
proc verifyDiagRes {fabric logFile} {
88
return "-I- Could not figure out if OK yet"
91
set fabric [IBMgtSimulator getFabric]
93
# get a random order of the end ports:
94
set randEndPorts [getEndPortsByRandomOreder $fabric]
95
set numEndPorts [llength $randEndPorts]
97
set swaps [expr int([rmRand]*$numEndPorts)/5]
98
if {!$swaps} {set swaps 1}
100
puts "Swapping $swaps PortGuis"
101
for {set i 1} {$i <= $swaps } {incr i} {
102
set idx [expr ($i + int([rmRand]*$numEndPorts))%$numEndPorts]
103
set fromNodeNPort [lindex $randEndPorts $idx]
104
set clones [expr int([rmRand]*2)]
105
if {!$clones} {set clones 1}
106
puts "Swap #$i with #$clones clones"
107
for {set j 1} {$j <= $clones} {incr j} {
108
set toNodeNPort [lindex $randEndPorts [expr ($idx+$j)%$numEndPorts]]
109
if {[catch {dupPortGuid $fromNodeNPort $toNodeNPort} e]} {