1
# This code should be sourced into ibis through ibdiagui wrapper
2
source [file join [file dirname [info script]] ibdebug.tcl]
4
if {[catch {package require ibdm} e]} {
5
puts "-E- ibdiagui depends on a 'IBDM' installation"
6
puts " Your ib_utils installation must be broken. Please reinstall"
11
if {[catch {package require ibis} e]} {
12
puts "-E- ibdiagui depends on a 'ibis' installation"
13
puts " Your ib_utils installation must be broken. Please reinstall"
18
##############################################################################
20
# GENERIC CANVAS ZOOMING UTILITIES
22
##############################################################################
24
#--------------------------------------------------------
28
# Mark the first (x,y) coordinate for zooming.
30
#--------------------------------------------------------
31
proc zoomMark {c x y} {
33
set zoomArea(x0) [$c canvasx $x]
34
set zoomArea(y0) [$c canvasy $y]
35
$c create rectangle $x $y $x $y -outline black -tag zoomArea
38
#--------------------------------------------------------
42
# Zoom in to the area selected by itemMark and
45
#--------------------------------------------------------
46
proc zoomStroke {c x y} {
48
set zoomArea(x1) [$c canvasx $x]
49
set zoomArea(y1) [$c canvasy $y]
50
$c coords zoomArea $zoomArea(x0) $zoomArea(y0) $zoomArea(x1) $zoomArea(y1)
53
#--------------------------------------------------------
57
# Zoom in to the area selected by itemMark and
60
#--------------------------------------------------------
61
proc zoomArea {c x y} {
64
#--------------------------------------------------------
65
# Get the final coordinates.
66
# Remove area selection rectangle
67
#--------------------------------------------------------
68
set zoomArea(x1) [$c canvasx $x]
69
set zoomArea(y1) [$c canvasy $y]
72
#--------------------------------------------------------
73
# Check for zero-size area
74
#--------------------------------------------------------
75
if {($zoomArea(x0)==$zoomArea(x1)) || ($zoomArea(y0)==$zoomArea(y1))} {
79
#--------------------------------------------------------
80
# Determine size and center of selected area
81
#--------------------------------------------------------
82
set areaxlength [expr {abs($zoomArea(x1)-$zoomArea(x0))}]
83
set areaylength [expr {abs($zoomArea(y1)-$zoomArea(y0))}]
84
set xcenter [expr {($zoomArea(x0)+$zoomArea(x1))/2.0}]
85
set ycenter [expr {($zoomArea(y0)+$zoomArea(y1))/2.0}]
87
#--------------------------------------------------------
88
# Determine size of current window view
89
# Note that canvas scaling always changes the coordinates
90
# into pixel coordinates, so the size of the current
91
# viewport is always the canvas size in pixels.
92
# Since the canvas may have been resized, ask the
93
# window manager for the canvas dimensions.
94
#--------------------------------------------------------
95
set winxlength [winfo width $c]
96
set winylength [winfo height $c]
98
#--------------------------------------------------------
99
# Calculate scale factors, and choose smaller
100
#--------------------------------------------------------
101
set xscale [expr {$winxlength/$areaxlength}]
102
set yscale [expr {$winylength/$areaylength}]
103
if { $xscale > $yscale } {
109
#--------------------------------------------------------
110
# Perform zoom operation
111
#--------------------------------------------------------
112
zoom $c $factor $xcenter $ycenter $winxlength $winylength
115
#--------------------------------------------------------
120
#--------------------------------------------------------
121
proc fit { canvas } {
122
set bbox [$canvas bbox all]
123
# provided view is the start and end of the viewed window in 0.0-1.0 of the
125
set xv [$canvas xview]
126
set yv [$canvas yview]
127
set xf [expr [lindex $xv 1] - [lindex $xv 0]]
128
set yf [expr [lindex $yv 1] - [lindex $yv 0]]
134
# we want to set the center of the canvas to the bbox / 2
135
foreach {x0 y0 x1 y1} $bbox {break}
136
set x [expr ($x0 + $x1)/2.0]
137
set y [expr ($y0 + $y1)/2.0]
138
zoom $canvas $scale $x $y
141
#--------------------------------------------------------
145
# Zoom the canvas view, based on scale factor
146
# and centerpoint and size of new viewport.
147
# If the center point is not provided, zoom
148
# in/out on the current window center point.
150
# This procedure uses the canvas scale function to
151
# change coordinates of all objects in the canvas.
153
#--------------------------------------------------------
154
proc zoom { canvas factor \
155
{xcenter ""} {ycenter ""} \
156
{winxlength ""} {winylength ""} } {
158
#--------------------------------------------------------
159
# If (xcenter,ycenter) were not supplied,
160
# get the canvas coordinates of the center
161
# of the current view. Note that canvas
162
# size may have changed, so ask the window
163
# manager for its size
164
#--------------------------------------------------------
165
if { [string equal $winxlength ""] } {
166
set winxlength [winfo width $canvas]
168
if { [string equal $winylength ""] } {
169
set winylength [winfo height $canvas]
171
if { [string equal $xcenter ""] } {
172
set xcenter [$canvas canvasx [expr {$winxlength/2.0}]]
174
if { [string equal $ycenter ""] } {
175
set ycenter [$canvas canvasy [expr {$winylength/2.0}]]
178
#--------------------------------------------------------
179
# Scale all objects in the canvas
180
# Adjust our viewport center point
181
#--------------------------------------------------------
182
$canvas scale all 0 0 $factor $factor
183
set xcenter [expr {$xcenter * $factor}]
184
set ycenter [expr {$ycenter * $factor}]
186
#--------------------------------------------------------
187
# Get the size of all the items on the canvas.
189
# This is *really easy* using
191
# but it is also wrong. Non-scalable canvas
192
# items like text and windows now have a different
193
# relative size when compared to all the lines and
194
# rectangles that were uniformly scaled with the
195
# [$canvas scale] command.
197
# It would be better to tag all scalable items,
198
# and make a single call to [bbox].
199
# Instead, we iterate through all canvas items and
200
# their coordinates to compute our own bbox.
201
#--------------------------------------------------------
202
set x0 1.0e30; set x1 -1.0e30 ;
203
set y0 1.0e30; set y1 -1.0e30 ;
204
foreach item [$canvas find all] {
205
switch -exact [$canvas type $item] {
211
set coords [$canvas coords $item]
212
foreach {x y} $coords {
213
if { $x < $x0 } {set x0 $x}
214
if { $x > $x1 } {set x1 $x}
215
if { $y < $y0 } {set y0 $y}
216
if { $y > $y0 } {set y1 $y}
222
#--------------------------------------------------------
223
# Now figure the size of the bounding box
224
#--------------------------------------------------------
225
set xlength [expr {$x1-$x0}]
226
set ylength [expr {$y1-$y0}]
228
#--------------------------------------------------------
229
# But ... if we set the scrollregion and xview/yview
230
# based on only the scalable items, then it is not
231
# possible to zoom in on one of the non-scalable items
232
# that is outside of the boundary of the scalable items.
234
# So expand the [bbox] of scaled items until it is
235
# larger than [bbox all], but do so uniformly.
236
#--------------------------------------------------------
237
foreach {ax0 ay0 ax1 ay1} [$canvas bbox all] {break}
239
while { ($ax0<$x0) || ($ay0<$y0) || ($ax1>$x1) || ($ay1>$y1) } {
240
# triple the scalable area size
241
set x0 [expr {$x0-$xlength}]
242
set x1 [expr {$x1+$xlength}]
243
set y0 [expr {$y0-$ylength}]
244
set y1 [expr {$y1+$ylength}]
245
set xlength [expr {$xlength*3.0}]
246
set ylength [expr {$ylength*3.0}]
249
#--------------------------------------------------------
250
# Now that we've finally got a region defined with
251
# the proper aspect ratio (of only the scalable items)
252
# but large enough to include all items, we can compute
253
# the xview/yview fractions and set our new viewport
255
#--------------------------------------------------------
256
set newxleft [expr {($xcenter-$x0-($winxlength/2.0))/$xlength}]
257
set newytop [expr {($ycenter-$y0-($winylength/2.0))/$ylength}]
258
$canvas configure -scrollregion [list $x0 $y0 $x1 $y1]
259
$canvas xview moveto $newxleft
260
$canvas yview moveto $newytop
262
#--------------------------------------------------------
263
# Change the scroll region one last time, to fit the
264
# items on the canvas.
265
#--------------------------------------------------------
266
$canvas configure -scrollregion [$canvas bbox all]
269
##############################################################################
271
# NETWORK GRAPH UTILITIES
273
##############################################################################
275
# provide back color based on port speed / speed
276
proc portColor {port} {
277
set width [IBPort_width_get $port]
278
set speed [IBPort_speed_get $port]
280
set color [getColor $width${speed}G]
285
proc LoadAnnotationsFile {} {
287
global ANNOTATION_FILE P
289
if {![info exists ANNOTATION_FILE]} {
292
if {![file readable $ANNOTATION_FILE]} {
296
set f [open $ANNOTATION_FILE r]
298
if {[info exists ANNOTATIONS]} {unset ANNOTATIONS}
300
while {[gets $f sLine] >= 0} {
301
# TODO: Support not only sysPort annotations
302
if {![regexp {(\S+)\s+(.+)} $sLine d1 name anno]} {
303
puts "-W- Skipping annotation file line:$sLine"
306
set ANNOTATIONS(sysport:$name) $anno
310
proc DrawAnnotationFromFile {} {
314
# clear all annotations
315
$C delete withtag anno
317
# TODO: Support not only sysPort annotations
318
foreach e [array names ANNOTATIONS sysport:*] {
319
set sysPortName [string range $e [string length sysport:] end]
320
set anno $ANNOTATIONS($e)
323
set sysPort [findSysPortByName $sysPortName]
324
if {$sysPort == ""} {
325
puts "-W- failed to find sys port:$sysPortName"
329
set sysName [IBSystem_name_get [IBSysPort_p_system_get $sysPort]]
330
set portName [IBSysPort_name_get $sysPort]
331
# get the items of this port
332
set items [$C find withtag ${portName}&&sysport&&of:$sysName]
333
if {[llength $items] == 0} {
334
puts "-W- No items for sys port:$sysPortName"
338
set bbox [$C bbox $items]
339
set outCoords [bboxCenter $bbox [expr rand()*0.95]]
340
$C create text $outCoords -tags anno -fill red \
342
puts "-I- Annotated $sysPortName with $anno"
348
proc drawNode {node graph} {
351
set nodeName [IBNode_name_get $node]
353
if {[regexp {^node:(.*)} $nodeName d1 n]} {
357
set nodeLabel "\{$nodeName|"
358
set numPorts [IBNode_numPorts_get $node]
360
1 {append nodeLabel "{<f1> P1}\}"}
361
2 {append nodeLabel "{<f1> P1|<f2> P2}\}"}
363
append nodeLabel "{<f1> P1|<f2> P2|<f3> P3|<f4> P4}|"
364
append nodeLabel "{<f5> P5|<f6> P6|<f7> P7|<f8> P8}\}"
367
append nodeLabel "{<f1> P1|<f2> P2|<f3> P3|<f4> P4}|"
368
append nodeLabel "{<f5> P5|<f6> P6|<f7> P7|<f8> P8}|"
369
append nodeLabel "{<f9> P9|<f10> P10|<f11> P11|<f12> P12}|"
370
append nodeLabel "{<f13> P13|<f14> P14|<f15> P15|<f16> P16}|"
371
append nodeLabel "{<f17> P17|<f18> P18|<f19> P19|<f20> P20}|"
372
append nodeLabel "{<f21> P21|<f22> P22|<f23> P23|<f24> P24}\}"
375
puts "-E- Fail to handle $nodeName with $numPorts ports"
379
[$graph addnode $nodeName shape record \
380
fontsize 7 label $nodeLabel \
381
fillcolor lightblue2 style filled \
384
if {[IBNode_type_get $node] == $IB_CA_NODE} {
385
$NODE($node) setattributes fillcolor lightgrey
389
proc drawSystem {sys graph} {
391
global SYS_PORT_IDX_BY_NAME
392
global EXPAND_SYSTEMS
395
# puts "-I- Drawing system $sys"
396
set sysName [IBSystem_name_get $sys]
398
# remove extra "system" from auto systems
399
if {[regexp {^system:(.*)} $sysName d1 n]} {
403
# the system might be expanded
404
if {[info exists EXPAND_SYSTEMS($sysName)]} {
405
set subGraph [$graph addsubgraph \
406
cluster_$sysName label $sysName labelfontsize 7 \
407
bgcolor wheat color black]
408
foreach nameNNode [IBSystem_NodeByName_get $sys] {
409
set node [lindex $nameNNode 1]
410
drawNode $node $subGraph
415
set sysLabel "\{$sysName|"
417
# we only draw system ports that are connected
423
set sysPorts [IBSystem_PortByName_get $sys]
424
foreach sysNameNPort [lsort -dictionary -index 0 $sysPorts] {
425
foreach {portName sysPort} $sysNameNPort {break}
427
set fullName "$sysName/$portName"
428
set isAnnotated [info exists ANNOTATIONS(sysport:$fullName)]
429
set remSysPort [IBSysPort_p_remoteSysPort_get $sysPort]
430
if {$isAnnotated == 0 && $remSysPort == ""} {continue}
432
# we use heuristic to know when to break the ports line
433
if {![regexp {(.*)/[^/]+$} $portName d1 prefix]} {
437
if {$prefix != $prevPrefix || $numInLine == 6} {
443
append sysLabel "\}|\{"
445
set prevPrefix $prefix
454
append sysLabel "<f$sysPortIdx> $portName"
455
set SYS_PORT_IDX_BY_NAME($sys,$portName) $sysPortIdx
459
append sysLabel "\}\}"
464
if {[regexp {^S[0-9a-fA-F]+$} $sysName]} {
465
set fillColor lightgrey
467
set fillColor lightyellow
471
if {[info exist SYSTEM_ORDER] && [lsearch $SYSTEM_ORDER $sysName] >= 0} {
473
[$graph addnode $sysName shape record \
474
fontsize 7 label $sysLabel labelfontcolor red \
475
fillcolor $fillColor style filled \
479
[$graph addnode $sysName shape record \
480
fontsize 7 label $sysLabel labelfontcolor red \
481
fillcolor $fillColor style filled \
486
# draw a single node connections
487
proc drawNodeConns {node graph} {
488
global SYS_PORT_IDX_BY_NAME
490
global EXPAND_SYSTEMS
493
# puts "-V- Drawing connections of node:[IBNode_name_get $node]"
494
set sys [IBNode_p_system_get $node]
495
set sysName [IBSystem_name_get $sys]
496
set isExpanded [info exists EXPAND_SYSTEMS($sysName)]
497
for {set pn 1} {$pn <= [IBNode_numPorts_get $node]} {incr pn} {
498
set port [IBNode_getPort $node $pn]
499
if {$port == ""} {continue}
500
set portName [IBPort_getName $port]
502
set remPort [IBPort_p_remotePort_get $port]
503
if {$remPort == ""} {continue}
505
set remPortName [IBPort_getName $remPort]
506
if {[info exists CONN($remPortName)] } {continue}
508
set toNode [IBPort_p_node_get $remPort]
509
set toPortNum [IBPort_num_get $remPort]
510
set toSys [IBNode_p_system_get $toNode]
511
set toSysName [IBSystem_name_get $toSys]
513
# we can skip connections within same system if it
515
if {($sys == $toSys) && !$isExpanded} {continue}
517
# now we need to figure out if we are connecting
518
# system ports or not
519
set sysPort [IBPort_p_sysPort_get $port]
520
if {$sysPort == "" || $isExpanded} {
521
set isDrawn [info exists NODE($node)]
522
if {$isDrawn == 0} {continue}
523
set fromRec $NODE($node)
526
if {![info exists SYSTEM($sys)]} {
527
puts "-W- System $sys is not drawn???"
530
set fromRec $SYSTEM($sys)
531
set fromPortName [IBSysPort_name_get $sysPort]
532
if {![info exists SYS_PORT_IDX_BY_NAME($sys,$fromPortName)]} {
533
puts "-W- System $sys port $fromPortName is not drawn???"
536
set fromPort "f$SYS_PORT_IDX_BY_NAME($sys,$fromPortName)"
539
set remSysPort [IBPort_p_sysPort_get $remPort]
540
set isRemExpanded [info exists EXPAND_SYSTEMS($toSysName)]
541
if {$remSysPort == "" || $isRemExpanded} {
542
set toRec $NODE($toNode)
543
set toPort f$toPortNum
545
set toRec $SYSTEM($toSys)
546
set toPortName [IBSysPort_name_get $remSysPort]
547
set toPort "f$SYS_PORT_IDX_BY_NAME($toSys,$toPortName)"
550
# puts "-V- Connecting from:$fromRec / $fromPort -> $toRec / $toPort ... "
552
[$graph addedge "$toRec" "$fromRec" \
553
tailport $toPort headport $fromPort \
554
arrowhead normal arrowtail normal \
557
set CONN($portName) $conn
559
# use coloring for link speed/width
560
$conn setattributes color [portColor $port]
564
# process the code generated by graphviz
565
proc tagGraphVizCode {fabric code} {
569
# We scan through the code for text and on the first
570
# appearence of a node tag. Then try matching against known
577
foreach sLine [split $code "\n"] {
578
if {[regexp {^(.*-text.*-tags\s+)(.*graph.*)} $sLine d1 pf tags]} {
579
append newCode "$pf {$tags system}\n"
581
} elseif {[regexp {^(.*-text\s+(\S+).*-tags\s+)(.*node.*)} \
582
$sLine d1 pf txt tags]} {
583
# we can be on a new node -
584
if {$prevNode != $tags} {
585
# new node tag is it a system or node?
586
set sys [IBFabric_getSystem $fabric $txt]
588
# puts "-V- TAGS: new sys $tags txt:$txt"
590
append newCode "$pf {$tags system}\n"
592
set portTagType sysport
595
# puts "-V- TAGS: new node $tags txt:$txt"
597
append newCode "$pf {$tags node}\n"
603
# puts "-V- TAGS: new $portTagType $tags txt:$txt"
606
append newCode "$pf {$tags $portTagType of:$parent}\n"
610
append newCode "$sLine\n"
613
# avoid the disabling of the widgets
614
regsub -all -- {-disabled} $newCode {} newCode
615
puts "-I- Marked $numSystems systems $numNodes nodes $numPorts ports"
619
# create selection box for each object type and assign bindings
620
proc bindMenusToTags {c} {
626
sysport showSysPortMenu
629
foreach {type hdlFunc} $objNHdl {
630
foreach item [$c find withtag $type] {
631
foreach {x0 y0 x1 y1} [$c bbox $item] {break}
632
set dy [expr $y1 - $y0]
633
if {[catch {set name [$c itemcget $item -text]}]} {continue}
634
set tags [$c itemcget $item -tags]
635
$c addtag $name withtag $item
636
lappend tags name:$name
637
lappend tags ${type}Handle
638
set handleItem [$c create rectangle $x0 \
639
[expr $y0 - $dy] $x1 [expr $y1 + $dy] \
640
-outline {} -tags $tags]
642
$c bind $handleItem <1> [list $hdlFunc %W %x %y]
647
# provide a system list in the order stored by system names
648
# return a list of {name id} pairs
649
proc getSysList {fabric} {
652
# first get all the systems sorted by name
655
if {[info exists SYSTEM_ORDER]} {
656
foreach sysName $SYSTEM_ORDER {
657
set sys [IBFabric_getSystem $fabric $sysName]
659
puts "-I- Adding root $sysName"
660
lappend sysList [list $sysName $sys]
661
lappend nameList $sysName
666
# now build the name list not including the
667
foreach nameNSys [lsort -index 0 [IBFabric_SystemByName_get $fabric]] {
668
set name [lindex $nameNSys 0]
669
set sys [lindex $nameNSys 1]
670
if {[lsearch -exact $nameList $name] < 0} {
671
lappend sysList [list $name $sys]
672
lappend nameList $name
678
# take a canvans and a fabric and draw the fabric on the canvas
679
proc drawFabric {fabric c} {
680
global NODE SYSTEM CONN SYS_PORT_IDX_BY_NAME
681
global EXPAND_SYSTEMS
683
foreach g {CONN NODE SYSTEM SYS_PORT_IDX_BY_NAME} {
684
if {[info exists $g]} {
692
# set graph [dotnew graph mode hier rankdir TB fontsize 7 \
693
# ranksep equaly labelfontsize 7 size 300,300]
694
set cbg [option get $c background *]
695
set graph [dotnew graph mode hier fontsize 7 \
696
ranksep equaly labelfontsize 7 bgcolor $cbg]
698
# we add each system as a subgraph and then
699
foreach nameNSys [getSysList $fabric] {
700
set sys [lindex $nameNSys 1]
701
drawSystem $sys $graph
704
# go over all nodes and connect them
705
foreach nameNNode [IBFabric_NodeByName_get $fabric] {
706
set node [lindex $nameNNode 1]
707
drawNodeConns $node $graph
710
SetStatus "-I- Calculating graph layout ..."
712
SetStatus "-I- Packing graph ..."
713
set code [$graph render]
714
SetStatus "-I- Packing graph ... done"
716
set newCode [tagGraphVizCode $fabric $code]
724
#assume there is a name:* tag in teh list return the name
725
proc getNameTag {tags} {
726
set idx [lsearch -glob $tags name:*]
730
return [string range [lindex $tags $idx] 5 end]
733
proc getOfTag {tags} {
734
set idx [lsearch -glob $tags of:*]
738
return [string range [lindex $tags $idx] 3 end]
741
# set the EXPANDED for the system under the cursor and
743
proc expand {c x y} {
744
global EXPAND_SYSTEMS
746
set tags [$c itemcget current -tags]
747
if {[llength $tags] == 0} {return}
748
set sysName [getNameTag $tags]
750
SetStatus "-I- Expanding System: $sysName ..."
751
puts "-I- Expanding System: $sysName ..."
753
set EXPAND_SYSTEMS($sysName) 1
755
after 100 drawFabric $gFabric $C
758
# set the EXPANDED for the system under the cursor and
760
proc deExpand {c x y} {
761
global EXPAND_SYSTEMS
763
set tags [$c itemcget current -tags]
764
if {[llength $tags] == 0} {return}
765
set sysName [getNameTag $tags]
767
SetStatus "-I- De-Expanding System: $sysName ..."
768
puts "-I- De-Expanding System: $sysName ..."
770
if {[info exists EXPAND_SYSTEMS($sysName)]} {
771
unset EXPAND_SYSTEMS($sysName)
774
after 100 drawFabric $gFabric $C
777
proc showSysMenu {c x y} {
779
set tags [$c itemcget current -tags]
780
set sysName [getNameTag $tags]
781
puts "System: $sysName"
783
set sys [IBFabric_getSystem $gFabric $sysName]
785
puts "-E- fail to find system $sysName in the fabric"
788
PropsUpdate system $sys
791
proc showNodeMenu {c x y} {
793
set tags [$c itemcget current -tags]
794
set nodeName [getNameTag $tags]
796
if {[regexp {0x([0-9a-fA-F]{16})} $nodeName d1 n]} {
797
set nodeName "node:$n"
799
puts "Node: $nodeName"
801
set node [IBFabric_getNode $gFabric $nodeName]
803
puts "-E- fail to find node $nodeName in the fabric"
804
puts " [IBFabric_NodeByName_get $gFabric]"
808
PropsUpdate node $node
811
proc showPortMenu {c x y} {
813
set tags [$c itemcget current -tags]
815
set ntag [getOfTag $tags]
816
set node [$c find withtag ${ntag}&&node ]
817
set nodeName [$c itemcget $node -text]
818
set portName [getNameTag $tags]
819
puts "Port: $nodeName $portName"
822
set node [IBFabric_getNode $gFabric $nodeName]
824
puts "-E- fail to find node $nodeName in the fabric"
825
puts " [IBFabric_NodeByName_get $gFabric]"
829
regexp {[0-9]+} $portName portNum
830
set port [IBNode_getPort $node $portNum]
832
puts "-E- fail to find port $nodeName/$portName in the fabric"
836
PropsUpdate port $port
839
proc showSysPortMenu {c x y} {
841
set tags [$c itemcget current -tags]
842
set ntag [getOfTag $tags]
843
set systag [$c find withtag ${ntag}&&system ]
844
set sysName [$c itemcget $systag -text]
846
if {[regexp {0x([0-9a-fA-F]{16})} $sysName d1 n]} {
847
set nodeName "system:$n"
849
set portName [getNameTag $tags]
850
puts "SysPort: $sysName $portName"
853
set sys [IBFabric_getSystem $gFabric $sysName]
855
puts "-E- fail to find system $sysName in the fabric"
859
set sysPort [IBSystem_getSysPort $sys $portName]
860
if {$sysPort == ""} {
861
puts "-E- fail to find system port $sysName/$portName in the fabric"
865
PropsUpdate sysport $sysPort
868
# Perform the fabric update based on the availability of a topology
870
proc GraphUpdate {lstFile} {
878
foreach fType {gFabric gTopoFabric gLstFabric} {
879
if {[info exists $fType]} {
880
delete_IBFabric [set $fType]
884
set gFabric [new_IBFabric]
886
if {![info exists G(argv:topo.file)]} {
887
puts "-I- Parsing subnet lst: $lstFile"
888
IBFabric_parseSubnetLinks $gFabric $lstFile
891
set gTopoFabric [new_IBFabric]
892
IBFabric_parseTopology $gTopoFabric $G(argv:topo.file)
895
set gLstFabric [new_IBFabric]
896
IBFabric_parseSubnetLinks $gLstFabric $lstFile
899
set m [ibdmMatchFabrics $gTopoFabric $gLstFabric \
900
$G(argv:sys.name) $G(argv:port.num) $G(data:root.port.guid)]
903
ibdmBuildMergedFabric $gTopoFabric $gLstFabric $gFabric
904
puts "-I- Topo merged"
907
drawFabric $gFabric $C
910
# clear all highlights
911
proc guiClearAllMarking {} {
914
set items [$C find withtag mark]
915
puts "-I- Clearing mark on $items"
916
foreach item $items {
917
if {[llength [$C gettags $item]] == 1} {
921
$C itemconfigure $item -fill black -activefill black
926
proc SetStatus {msg} {
927
global S O StatusLine
928
$S configure -state normal
930
$S configure -state readonly
931
set color $O(color:txtDef)
932
if {[regexp {^-([WEI])-} $msg d1 type]} {
934
E {set color $O(color:txtErr)}
935
W {set color $O(color:txtWarn)}
936
I {set color $O(color:txtInfo)}
939
$S configure -foreground [lindex $color 2]
943
# zoom to object by ibdm id
944
proc zoomToObjByIbdmId {type obj} {
949
set name [IBSystem_name_get $obj]
950
set items [$C find withtag ${name}&&system]
953
set name [IBNode_name_get $obj]
954
set items [$C find withtag ${name}&&node]
957
set sys [IBSysPort_p_system_get $obj]
958
set sysName [IBSystem_name_get $sys]
959
set name [IBSysPort_name_get $obj]
960
set items [$C find withtag ${name}&&sysport&&of:$sysName]
963
set node [IBPort_p_node_get $obj]
964
set nodeName [IBNode_name_get $node]
965
set name "P[IBPort_num_get $obj]"
966
set items [$C find withtag ${name}&&port&&of:$nodeName]
969
if {[llength $items]} {
970
set bbox [$C bbox $items]
971
set xy [bboxCenter $bbox]
972
zoom $C 1.0 [lindex $xy 0] [lindex $xy 1]
973
puts "-I- Zooming on $bbox"
975
puts "-I- No items for $type $obj"
979
# find and highlight a system by name
980
proc guiHighLightByName {objType name} {
985
set sys [IBFabric_getSystem $gFabric $name]
987
SetStatus "-W- Fail to find system by name:$name"
990
PropsUpdate system $sys
992
set items [$C find withtag ${name}&&system]
995
# we need to try each hier sep
998
set subNames [split $name /]
1000
while {[llength $subNames]} {
1001
set n [lindex $subNames 0]
1002
set subNames [lrange $subNames 1 end]
1003
if {$sysName != ""} { append sysName / }
1005
set sys [IBFabric_getSystem $gFabric $sysName]
1006
if {$sys != ""} { break }
1010
SetStatus "-W- Fail to find system for port by name:\"$name\""
1014
set portName [join $subNames /]
1015
set sysPort [IBSystem_getSysPort $sys $portName]
1016
if {$sysPort == ""} {
1017
SetStatus "-W- Fail to find system port by name:\"$name\""
1020
PropsUpdate sysport $sysPort
1021
set items [$C find withtag ${portName}&&sysport&&of:$sysName]
1024
set node [IBFabric_getNode $gFabric $name]
1026
SetStatus "-W- Fail to find node by name:$name"
1029
PropsUpdate node $node
1030
set items [$C find withtag ${name}&&node]
1031
# we might need to look for a system...
1032
if {[llength $items] == 0} {
1033
set sys [IBNode_p_system_get $node]
1034
set sysName [IBSystem_name_get $sys]
1035
return [guiHighLightByName system $sysName]
1039
if {![regexp {(.*)/P([0-9]+)} $name d1 nodeName portNum]} {
1040
SetStatus "-W- Fail to find node for port by name:\"$name\""
1043
set node [IBFabric_getNode $gFabric $nodeName]
1045
SetStatus "-W- Fail to find node for port by name:\"$name\""
1049
set port [IBNode_getPort $node $portNum]
1051
SetStatus "-W- Fail to find port by name:\"$name\""
1054
PropsUpdate port $port
1055
set portName "P$portNum"
1057
set items [$C find withtag ${portName}&&port&&of:$nodeName]
1059
if {[llength $items] == 0} {
1060
set sysPort [IBPort_p_sysPort_get $port]
1061
set sys [IBNode_p_system_get $node]
1062
set sysName [IBSystem_name_get $sys]
1063
if {$sysPort == ""} {
1064
# it is internal - just highlight the sys
1065
return [guiHighLightByName system $sysName]
1067
set sysPortName "$sysName/[IBSysPort_name_get $sysPort]"
1068
return [guiHighLightByName sysport $sysPortName]
1075
if {![llength $items]} {
1076
SetStatus "-W- Fail to find any displayed obejct for $objType name:\"$name\""
1080
set bbox [$C bbox $items]
1081
zoom $C 1.0 [lindex $bbox 0] [lindex $bbox 1]
1082
foreach item $items {
1083
$C itemconfigure $item -fill [getColor mark] -activefill [getColor mark]
1084
$C addtag mark withtag $item
1090
# find and highlight a system by name
1091
proc guiHighLightByGuid {objType guid} {
1094
# we try getting by system/node/port
1095
set sys [IBFabric_getSystemByGuid $gFabric $guid]
1096
set node [IBFabric_getNodeByGuid $gFabric $guid]
1097
set port [IBFabric_getPortByGuid $gFabric $guid]
1102
set name [IBSystem_name_get $sys]
1103
} elseif {$node != ""} {
1104
set sys [IBNode_p_system_get $node]
1105
set name [IBSystem_name_get $sys]
1106
} elseif {$port != ""} {
1107
set node [IBPort_p_node_get $port]
1108
set sys [IBNode_p_system_get $node]
1109
set name [IBSystem_name_get $sys]
1111
SetStatus "-W- Fail to find system by guid:$guid"
1116
set items [$C find withtag ${name}&&system]
1120
set name [IBNode_name_get $node]
1121
} elseif {$port != ""} {
1122
set node [IBPort_p_node_get $port]
1123
set name [IBNode_name_get $node]
1125
SetStatus "-W- Fail to find node by guid:$guid"
1129
set items [$C find withtag ${name}&&node]
1133
SetStatus "-W- Fail to find port by guid:$guid"
1138
set nodeName [IBNode_name_get [IBPort_p_node_get $port]]
1139
set name "P[IBPort_num_get $port]"
1140
set items [$C find withtag ${name}&&port&&of:$nodeName]
1144
SetStatus "-W- Fail to find system port by guid:$guid"
1148
set sysPort [IBPort_p_sysPort_get $port]
1149
if {$sysPort == ""} {
1150
SetStatus "-W- Fail to find system port for port with guid:$guid"
1154
set sys [IBSysPort_p_system_get $sysPort]
1155
set sysName [IBSystem_name_get $sys]
1156
set name [IBSysPort_name_get $sysPort]
1158
set items [$C find withtag ${name}&&sysport&&of:$sysName]
1162
if {![llength $items]} {
1163
SetStatus "-W- Fail to find any displayed obejct for $objType name:\"$name\""
1167
PropsUpdate $objType $obj
1168
set bbox [$C bbox $items]
1169
zoom $C 1.0 [lindex $bbox 0] [lindex $bbox 1]
1170
foreach item $items {
1171
$C itemconfigure $item -fill [getColor mark] -activefill [getColor mark]
1172
$C addtag mark withtag $item
1177
# find and highlight a system by name
1178
proc guiHighLightByLid {objType lid} {
1181
# we try getting port by lid:
1182
set port [IBFabric_getPortByLid $gFabric $lid]
1184
SetStatus "-W- Fail to find port by lid:$lid"
1190
set node [IBPort_p_node_get $port]
1191
set sys [IBNode_p_system_get $node]
1192
set name [IBSystem_name_get $sys]
1193
set items [$C find withtag ${name}&&system]
1196
set node [IBPort_p_node_get $port]
1197
set name [IBNode_name_get $node]
1198
set items [$C find withtag ${name}&&node]
1201
set nodeName [IBNode_name_get [IBPort_p_node_get $port]]
1202
set name "P[IBPort_num_get $port]"
1203
set items [$C find withtag ${name}&&port&&of:$nodeName]
1206
set sysPort [IBPort_p_sysPort_get $port]
1207
if {$sysPort == ""} {
1208
SetStatus "-W- Fail to find system port for port with lid:$lid"
1212
set sys [IBSysPort_p_system_get $sysPort]
1213
set sysName [IBSystem_name_get $sys]
1214
set name [IBSysPort_name_get $sysPort]
1215
set items [$C find withtag ${name}&&sysport&&of:$sysName]
1219
if {![llength $items]} {
1220
SetStatus "-W- Fail to find any displayed obejct for $objType lid:$lid"
1224
set bbox [$C bbox $items]
1225
zoom $C 1.0 [lindex $bbox 0] [lindex $bbox 1]
1226
foreach item $items {
1227
$C itemconfigure $item -fill [getColor mark] -activefill [getColor mark]
1228
$C addtag mark withtag $item
1233
# return a sys port if exists
1234
proc findSysPortByName {name} {
1236
# we need to try each hier sep
1239
set subNames [split $name /]
1241
while {[llength $subNames]} {
1242
set n [lindex $subNames 0]
1243
set subNames [lrange $subNames 1 end]
1244
if {$sysName != ""} { append sysName / }
1246
set sys [IBFabric_getSystem $gFabric $sysName]
1247
if {$sys != ""} { break }
1251
set portName [join $subNames /]
1252
set sysPort [IBSystem_getSysPort $sys $portName]
1257
# simpler as we know the node ports end with P[0-9]+
1258
proc findPortByName {name} {
1261
if {![regexp {(.*)/P([0-9]+)$} $name d1 nodeName portNum]} {
1265
set node [IBFabric_getNode $gFabric $nodeName]
1270
return [IBNode_getPort $node $portNum]
1273
proc bboxCenter {bbox {xScale 0.5} {yScale 0.5}} {
1274
foreach {x0 y0 x1 y1} $bbox {break}
1275
return [list [expr ($x0*(1-$xScale) + $x1*$xScale)] \
1276
[expr ($y0*(1-$yScale) + $y1*$yScale)] ]
1279
# highlight all objects accross the directed route
1280
proc guiHighLightByDR {startPort route} {
1282
# first we try to get the given start port
1285
set sysPort [findSysPortByName $startPort]
1286
if {$sysPort == ""} {
1287
# try to get a port by that name
1288
set port [findPortByName $startPort]
1290
SetStatus "-W- Fail to find system port or port with name:\"$startPort\""
1294
set port [IBSysPort_p_nodePort_get $sysPort]
1297
# need to traverse from that port/sysport
1298
# if the given path is made of [] we need to convert hex to dec
1299
if {[regexp {^\s*([[][0-9a-fA-F][]])+\s*$} $route]} {
1301
foreach h [split $route {[]}] {
1303
lappend dr [expr 0x$h]
1307
set dr [split $route ", "]
1310
if {[lindex $dr 0] == 0} {
1311
set dr [lrange $dr 1 end]
1318
set node [IBPort_p_node_get $port]
1319
set outPort [IBNode_getPort $node $p]
1320
if {$outPort == ""} {
1321
SetStatus "-W- Got dead end on path at node:\"[IBNode_name_get $node]\" port:$p\""
1325
# highlight outgoing port and sysport
1326
set nodeName [IBNode_name_get [IBPort_p_node_get $outPort]]
1327
set name "P[IBPort_num_get $outPort]"
1328
set iItems [$C find withtag ${name}&&port&&of:$nodeName]
1329
set allItems [concat $allItems $iItems]
1331
set sysPort [IBPort_p_sysPort_get $outPort]
1332
if {$sysPort != ""} {
1333
set sys [IBSysPort_p_system_get $sysPort]
1334
set sysName [IBSystem_name_get $sys]
1335
set name [IBSysPort_name_get $sysPort]
1336
set items [$C find withtag ${name}&&sysport&&of:$sysName]
1337
set iItems [concat $iItems $items]
1339
set allItems [concat $allItems $iItems]
1341
if {[llength $iItems]} {
1342
set outCoords [bboxCenter [$C bbox [lindex $iItems 0]] [expr rand()*0.95]]
1345
set port [IBPort_p_remotePort_get $outPort]
1347
SetStatus "-W- No remote port on path at node:\"[IBNode_name_get $node]\" port:$p\""
1348
$C create text $outCoords -tags mark -fill [getColor mark] -text "DEAD END ($p)"
1352
# highlight input port and sysport
1354
set nodeName [IBNode_name_get [IBPort_p_node_get $port]]
1355
set name "P[IBPort_num_get $port]"
1356
set items [$C find withtag ${name}&&port&&of:$nodeName]
1357
set allItems [concat $allItems $items]
1360
set sysPort [IBPort_p_sysPort_get $port]
1361
if {$sysPort != ""} {
1362
set sys [IBSysPort_p_system_get $sysPort]
1363
set sysName [IBSystem_name_get $sys]
1364
set name [IBSysPort_name_get $sysPort]
1365
set items [$C find withtag ${name}&&sysport&&of:$sysName]
1366
set oItems [concat $oItems $items]
1368
set allItems [concat $allItems $oItems]
1370
if {[llength $oItems]} {
1371
set inCoords [bboxCenter [$C bbox [lindex $oItems 0]] [expr rand()*0.95]]
1374
$C create line [concat $outCoords $inCoords] \
1375
-tags mark -fill [getColor mark] -arrow last
1376
set x [expr ([lindex $outCoords 0] + [lindex $inCoords 0]) / 2.0]
1377
set y [expr ([lindex $outCoords 1] + [lindex $inCoords 1]) / 2.0]
1378
$C create text $x $y -anchor w -text $hop -tags mark -fill [getColor mtxt]
1384
foreach item $allItems {
1385
$C itemconfigure $item -fill [getColor mark] -activefill [getColor mark]
1386
$C addtag mark withtag $item
1391
##############################################################################
1393
# PROPS Widget Commands
1395
##############################################################################
1396
proc PropsUpdate {objType ibdmHandle {zoom 0}} {
1398
# prevents recursion loop
1399
global _PropsUpdate_inside
1400
if {$ibdmHandle == ""} {return}
1402
if {[info exists _PropsUpdate_inside] && $_PropsUpdate_inside} {return}
1403
set _PropsUpdate_inside 1
1405
if {$ibdmHandle == ""} { return }
1407
foreach c [winfo child $P] {
1412
system {PropsSystem $ibdmHandle}
1413
node {PropsNode $ibdmHandle}
1414
port {PropsPort $ibdmHandle}
1415
sysport {PropsSysPort $ibdmHandle}
1418
# zoom to that object
1420
zoomToObjByIbdmId $objType $ibdmHandle
1422
set _PropsUpdate_inside 0
1425
proc PropsSystem {sys} {
1427
set PROPS(sys,id) $sys
1428
set PROPS(sys,name) [IBSystem_name_get $sys]
1429
set PROPS(sys,type) [IBSystem_type_get $sys]
1430
set PROPS(sys,guid) [IBSystem_guid_get $sys]
1431
set PROPS(sys,nodes,id) [IBSystem_NodeByName_get $sys]
1432
set PROPS(sys,nodes) [llength $PROPS(sys,nodes,id)]
1433
set b $PROPS(sys,nodes,menu)
1436
foreach nameNNode $PROPS(sys,nodes,id) {
1437
$b insert $i command -label [lindex $nameNNode 0] \
1438
-command "PropsUpdate node [lindex $nameNNode 1]"
1441
pack $P.sys -expand yes -fill x -anchor nw
1444
proc PropsNode {node} {
1446
pack $P.node -expand yes -fill x -anchor nw
1447
set PROPS(node,id) $node
1448
set PROPS(node,name) [IBNode_name_get $node]
1449
set PROPS(node,guid) [IBNode_guid_get $node]
1450
set PROPS(node,ports) [IBNode_numPorts_get $node]
1451
set PROPS(node,dev) [IBNode_devId_get $node]
1452
set PROPS(node,rev) [IBNode_revId_get $node]
1453
set PROPS(node,vend) [IBNode_vendId_get $node]
1454
set PROPS(node,sys,id) [IBNode_p_system_get $node]
1455
set PROPS(node,sys) [IBSystem_name_get $PROPS(node,sys,id)]
1456
set PROPS(node,dr) [getDrToNode $node]
1457
set b $PROPS(node,ports,menu)
1460
for {set pn 1} {$pn <= $PROPS(node,ports)} {incr pn} {
1461
set port [IBNode_getPort $node $pn]
1463
$b insert $i command -label "P$pn" \
1464
-command "PropsUpdate port $port 1"
1470
proc PropsPort {port} {
1472
pack $P.port -expand yes -fill x -anchor nw
1473
set PROPS(port,id) $port
1474
set PROPS(port,name) [IBPort_getName $port]
1475
set PROPS(port,guid) [IBPort_guid_get $port]
1476
set PROPS(port,lid) [IBPort_base_lid_get $port]
1477
set PROPS(port,speed) [IBPort_speed_get $port]
1478
set PROPS(port,width) [IBPort_width_get $port]
1479
set node [IBPort_p_node_get $port]
1480
set PROPS(port,node,id) $node
1481
set PROPS(port,node) [IBNode_name_get $node]
1482
set remPort [IBPort_p_remotePort_get $port]
1483
set PROPS(port,rem,id) $remPort
1484
if {$remPort != ""} {
1485
set PROPS(port,rem) [IBPort_getName $remPort]
1487
set PROPS(port,rem) "NOT CONNECTED"
1489
set sysPort [IBPort_p_sysPort_get $port]
1490
set PROPS(port,sysp,id) $sysPort
1491
if {$sysPort != ""} {
1492
set sys [IBSysPort_p_system_get $sysPort]
1493
set PROPS(port,sysp) \
1494
"[IBSystem_name_get $sys]/[IBSysPort_name_get $sysPort]"
1496
set PROPS(port,sysp) "NONE"
1500
proc PropsSysPort {sysPort} {
1501
global P PROPS ANNOTATIONS
1502
pack $P.sysport -expand yes -fill x -anchor nw
1503
set PROPS(sysport,id) $sysPort
1504
set PROPS(sysport,name) [IBSysPort_name_get $sysPort]
1505
set PROPS(sysport,sys,id) [IBSysPort_p_system_get $sysPort]
1506
set PROPS(sysport,sys) [IBSystem_name_get $PROPS(sysport,sys,id)]
1507
set port [IBSysPort_p_nodePort_get $sysPort]
1508
set PROPS(sysport,width) [IBPort_width_get $port]
1509
set PROPS(sysport,speed) [IBPort_speed_get $port]
1510
set node [IBPort_p_node_get $port]
1511
set PROPS(sysport,port,id) $port
1512
set PROPS(sysport,port) \
1513
"[IBNode_name_get $node]/P[IBPort_num_get $port]"
1514
set remSysPort [IBSysPort_p_remoteSysPort_get $sysPort]
1515
set PROPS(sysport,rem,id) $remSysPort
1516
if {$remSysPort != ""} {
1517
set remSys [IBSysPort_p_system_get $remSysPort]
1518
set PROPS(sysport,rem) \
1519
"[IBSystem_name_get $remSys]/[IBSysPort_name_get $remSysPort]"
1521
set PROPS(sysport,rem) "NOT CONNECTED"
1523
set fullName "$PROPS(sysport,sys)/$PROPS(sysport,name)"
1524
if {[info exists ANNOTATIONS(sysport:$fullName)]} {
1525
set PROPS(sysport,anno) $ANNOTATIONS(sysport:$fullName)
1527
set PROPS(sysport,anno) ""
1531
# get a DR to a port by its ID
1532
# BFS untill finding it ...
1533
proc getDrToNode {targetNode} {
1537
set startPort [IBFabric_getPortByGuid $gFabric $G(data:root.port.guid)]
1538
if {$startPort == ""} {
1539
puts "-E- Fail to find start port !"
1543
set Q [list [list [IBPort_p_node_get $startPort] "0"]]
1544
while {[llength $Q]} {
1545
set nodeNPath [lindex $Q 0]
1546
set Q [lreplace $Q 0 0]
1548
set node [lindex $nodeNPath 0]
1549
set path [lindex $nodeNPath 1]
1551
if {$node == $targetNode} {
1552
puts "-I- Found node [IBNode_name_get $targetNode] at path:$path"
1556
set VISITED($node) 1
1558
for {set pn 1} {$pn <= [IBNode_numPorts_get $node]} {incr pn} {
1559
set port [IBNode_getPort $node $pn]
1560
if {$port == ""} {continue}
1561
set remPort [IBPort_p_remotePort_get $port]
1562
if {$remPort == ""} {continue}
1563
set remNode [IBPort_p_node_get $remPort]
1564
if {[info exists VISITED($remNode)]} {continue}
1565
lappend Q [list $remNode "$path,$pn"]
1568
puts "-W- Failed to find node [IBNode_name_get $targetNode]"
1572
# select a port number gui
1573
proc numSelector {maxNum title} {
1574
global numSelectorVal
1575
if {![winfo exists .num_select]} {
1576
set t [toplevel .num_select]
1578
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
1579
label $t.l -text $title
1580
pack $t.l -side top -expand yes -fill x
1581
set o [tk_optionMenu $f.b numSelectorVal 1]
1582
for {set i 2} {$i < $maxNum} {incr i} {
1583
$o insert $i command -label $i \
1584
-command "global numSelectorVal; update;set numSelectorVal $i"
1586
set numSelectorVal 1
1587
pack $f.b -side left -padx 2 -pady 2
1590
wm title .num_select $title
1591
wm deiconify .num_select
1593
tkwait variable numSelectorVal
1595
return $numSelectorVal
1598
# we rely on the current PROP for
1599
proc setPortState {state {port 0}} {
1603
set port $PROPS(port,id)
1606
set node [IBPort_p_node_get $port]
1608
set drPath [getDrToNode $node]
1609
if {$drPath == -1} {
1613
set portNum [IBPort_num_get $port]
1614
if {[catch {set res [exec ibportstate -D $drPath $portNum $state]} e]} {
1615
LogAppend "\n-E---------------------------------------------------\n$e"
1617
LogAppend "\n-I---------------------------------------------------\n$res"
1621
proc setNodePortState {state} {
1623
set node $PROPS(node,id)
1625
set drPath [getDrToNode $node]
1626
if {$drPath == -1} {
1630
set portNum [numSelector [IBNode_numPorts_get $node] \
1631
"Select a port number"]
1632
if {$portNum == ""} { return }
1634
if {[catch {set res [exec ibportstate -D $drPath $portNum $state]} e]} {
1635
LogAppend "\n-E---------------------------------------------------\n$e"
1637
LogAppend "\n-I---------------------------------------------------\n$res"
1641
proc setSysPortState {state} {
1644
set sysPort $PROPS(sysport,id)
1645
set port [IBSysPort_p_nodePort_get $sysPort]
1646
setPortState $state $port
1649
proc portCounters {op {port 0}} {
1653
set port $PROPS(port,id)
1656
set lid [IBPort_base_lid_get $port]
1659
set portNum [IBPort_num_get $port]
1666
set cmd "perfquery $opt $lid $portNum"
1667
if {[catch {eval "set res \[exec $cmd\]"} e]} {
1668
LogAppend "\n-E---------------------------------------------------\n$cmd\n$e"
1670
LogAppend "\n-I---------------------------------------------------\n$cmd\n$res"
1674
# when port counters are queries from Node
1675
# NOTE: we can not rely on the existance of the port
1676
proc nodePortCounters {op} {
1678
set node $PROPS(node,id)
1680
set portNum [numSelector [IBNode_numPorts_get $node] \
1681
"Select a port number"]
1682
if {$portNum == ""} { return }
1684
# find first port that match
1686
for {set pn 1} {$pn < [IBNode_numPorts_get $node]} {incr pn} {
1687
set port [IBNode_getPort $node $pn]
1688
if {$port != ""} {break}
1690
if {$port == ""} {return}
1692
set lid [IBPort_base_lid_get $port]
1699
if {[catch {eval "set res [exec perfquery $opt $lid $portNum]"} e]} {
1700
LogAppend "\n-E---------------------------------------------------\n$e"
1702
LogAppend "\n-I---------------------------------------------------\n$res"
1706
proc sysPortCounters {op} {
1709
set sysPort $PROPS(sysport,id)
1710
set port [IBSysPort_p_nodePort_get $sysPort]
1711
portCounters $op $port
1714
##############################################################################
1716
# LOG WIDGET COMMANDS
1718
##############################################################################
1720
# perform log analysis from the given index
1721
proc LogAnalyze {{startIndex 0.0}} {
1723
set text [$L get $startIndex end]
1724
# loop through the text for sections:
1730
set rex "\n-(\[IWE\])-\[^\n\]*(\n\[^-\]\[^\n\]*)*"
1731
while {[regexp -start $startChar -indices -- $rex $text all type]} {
1732
set start [lindex $all 0]
1733
set type [string range $text [lindex $type 0] [lindex $type 1]]
1734
set sIdx [lindex $all 0]
1735
set eIdx [expr [lindex $all 1] + 1]
1737
E { set tagName errors; incr numErrs }
1738
W { set tagName warnings; incr numWarnings }
1739
I { set tagName infos; incr numInfos }
1741
$L tag add $tagName "$startIndex + $sIdx chars" "$startIndex + $eIdx chars"
1742
set startChar [lindex $all 1]
1744
puts "-I- Found $numErrs errors $numWarnings warnings $numInfos infos"
1746
# Now scan for names guids and routes...
1750
set rex "\\s+\"(\[^0-9\]\[^\"\]+)\"\\s+"
1751
while {[regexp -start $startChar -indices -- $rex $text all name]} {
1752
set sIdx [lindex $name 0]
1753
set eIdx [expr [lindex $name 1] + 1]
1754
$L tag add NAME "$startIndex + $sIdx chars" "$startIndex + $eIdx chars"
1755
set startChar [lindex $all 1]
1761
set rex {(lid|LID)[\s:=]*(0x[0-9a-fA-F]+|[0-9]+)}
1762
while {[regexp -start $startChar -indices -- $rex $text all pre lid]} {
1763
set sIdx [lindex $lid 0]
1764
set eIdx [expr [lindex $lid 1] + 1]
1765
$L tag add LID "$startIndex + $sIdx chars" "$startIndex + $eIdx chars"
1766
set startChar [lindex $all 1]
1772
set rex {[Gg][Uu][Ii][Dd]=*(0x[0-9a-fA-F]+)}
1773
while {[regexp -start $startChar -indices -- $rex $text all guid]} {
1774
set sIdx [lindex $guid 0]
1775
set eIdx [expr [lindex $guid 1] + 1]
1776
$L tag add GUID "$startIndex + $sIdx chars" "$startIndex + $eIdx chars"
1777
set startChar [lindex $all 1]
1783
set rex {\"([0-9]+(,[0-9]+)*)\"}
1784
while {[regexp -start $startChar -indices -- $rex $text all route]} {
1785
set sIdx [lindex $route 0]
1786
set eIdx [expr [lindex $route 1] + 1]
1787
$L tag add ROUTE "$startIndex + $sIdx chars" "$startIndex + $eIdx chars"
1788
set startChar [lindex $all 1]
1792
puts "-I- Found $numNames names $numLids LIDS $numGuids GUIDs $numRoutes Directed-Routes"
1795
proc LogUpdate {log} {
1800
# Filter out any "discovring" message
1802
set discRex "-I- Discovering the subnet ... \[0-9\]+ nodes .\[0-9\]+ Switches & \[0-9\]+ CA-s. discovered.\\s*\n"
1803
regsub -all -- $discRex $log "" nlog
1805
# perform the log area update
1806
$L configure -state normal
1810
# Do some hypertexting
1812
$L configure -state disabled
1815
proc LogAppend {log {scrollToPos 1}} {
1817
set start [$L index end]
1818
$L configure -state normal
1819
$L insert end "$log\n"
1820
$L configure -state disabled
1828
# an object tag was selected
1829
proc LogObjSelect {log type w x y} {
1831
# get the tag text under the x y
1832
set startNEnd [$log tag prevrange $type @$x,$y]
1833
set val [$log get [lindex $startNEnd 0] [lindex $startNEnd 1]]
1836
if {[guiHighLightByName port $val] != ""} {
1837
SetStatus "-I- Found Port $val"
1838
} elseif {[guiHighLightByName node $val] != ""} {
1839
SetStatus "-I- Found Node $val"
1840
} elseif {[guiHighLightByName system $val] != ""} {
1841
SetStatus "-I- Found System $val"
1842
} elseif {[guiHighLightByName sysport $val] != ""} {
1843
SetStatus "-I- Found System Port $val"
1845
SetStatus "-I- Failed to find object with name $val"
1849
set x [guiHighLightByLid sysport $val]
1850
set y [guiHighLightByLid port $val]
1851
if {$x != "" || $y != ""} {
1852
SetStatus "-I- Find by LID succeeded"
1856
guiHighLightByDR "$G(argv:sys.name)/P$G(argv:port.num)" $val
1859
set x [guiHighLightByGuid system $val]
1860
set y [guiHighLightByGuid sysport $val]
1861
if {$x != "" || $y != ""} {
1862
SetStatus "-I- Find by GUID succeeded"
1868
# initialize the props guid such that we have a pannel
1869
# for each object type
1870
proc initPropsGui {p} {
1879
nodes "\#Node" {PropsUpdate node $PROPS(sys,node,id) 1}
1886
dr "Directed Route" ""
1887
sys System {PropsUpdate system $PROPS(node,sys,id) 1}
1888
ports "\#Ports" {PropsUpdate port $PROPS(node,port,id) 1}
1890
rev "Revision ID" ""
1901
node Node {PropsUpdate node $PROPS(port,node,id) 1}
1902
rem Conn {PropsUpdate port $PROPS(port,rem,id) 1}
1903
sysp SysPort {PropsUpdate sysport $PROPS(port,sysp,id) 1}
1906
{sysport "FRONT PANEL PORT"
1909
sys System {PropsUpdate system $PROPS(sysport,sys,id) 1}
1910
port "Node Port" {PropsUpdate port $PROPS(sysport,port,id) 1}
1911
rem "Connected to" {PropsUpdate sysport $PROPS(sysport,rem,id) 1}
1922
{{UP "setNodePortState enable"} {DOWN "setNodePortState disable"}}
1923
{{"PM Get" "nodePortCounters get"} {"PM Clr" "nodePortCounters clr"}}
1926
{{UP "setPortState enable"} {DOWN "setPortState disable"}}
1927
{{"PM Get" "portCounters get"} {"PM Clr" "portCounters clr"}}
1930
{{UP "setSysPortState enable"} {DOWN "setSysPortState disable"}}
1931
{{"PM Get" "sysPortCounters get"} {"PM Clr" "sysPortCounters clr"}}
1935
foreach propSet $props {
1936
set obj [lindex $propSet 0]
1937
frame $p.$obj -background [lindex $O(color:$obj) 2] -padx 2 -pady 2
1940
set header [lindex $propSet 1]
1941
label $f.l -text $header
1943
foreach {attr lbl cmd} [lindex $propSet 2] {
1944
frame $f.$attr -borderwidth 2 -relief ridge
1945
label $f.$attr.l -text "$lbl:"
1947
if {[string range $lbl 0 0] == "\#"} {
1948
label $f.$attr.v -textvariable PROPS($obj,$attr)
1949
set PROPS($obj,$attr,menu) \
1950
[tk_optionMenu $f.$attr.m PROPS($obj,$attr,sel) \
1951
"Select a [string range $lbl 1 end]"]
1952
pack $f.$attr.l -side top -anchor w
1953
pack $f.$attr.m -side right -anchor e -expand yes -fill x
1954
pack $f.$attr.v -side left -anchor w
1955
set PROPS($obj,$attr,cb) $cmd
1958
entry $f.$attr.v -textvariable PROPS($obj,$attr) \
1959
-exportselection 1 -state readonly -relief flat
1960
pack $f.$attr.l $f.$attr.v -side top -anchor nw \
1961
-expand true -fill x
1963
pack $f.$attr -side top -fill x -anchor nw
1965
bind $f.$attr.l <ButtonPress-2> $cmd
1966
bind $f.$attr.v <ButtonPress-2> $cmd
1969
pack $f -side top -expand yes -fill both
1972
foreach cmdSet $cmds {
1974
set obj [lindex $cmdSet 0]
1975
foreach lineDef [lrange $cmdSet 1 end] {
1978
frame $f.cmds$lineIdx
1980
foreach bnc $lineDef {
1981
set b [lindex $bnc 0]
1982
set c [lindex $bnc 1]
1984
button $f.cmds$lineIdx.$bIdx -text $b -command $c
1985
pack $f.cmds$lineIdx.$bIdx -side left -anchor w
1987
pack $f.cmds$lineIdx -side top -anchor w
1992
##############################################################################
1994
# MAIN MENU COMMANDS
1996
##############################################################################
1997
proc getNodeLid {node} {
1999
for {set pn 1} {$pn <= [IBNode_numPorts_get $node]} {incr pn} {
2000
set port [IBNode_getPort $node $pn]
2002
set remPort [IBPort_p_remotePort_get $port]
2003
if {$remPort != ""} {break}
2006
if {$remPort == ""} {return 0}
2007
set lid [IBPort_base_lid_get $port]
2011
# given a key and a list of ley/value pairs get the pair
2012
proc assoc {key key_list} {
2013
foreach kv $key_list {
2014
if {[lindex $kv 0] == $key} {return [lindex $kv 1]}
2020
proc SetVL0Statics {} {
2023
set staticCredits 0x68
2024
foreach nNNode [IBFabric_NodeByName_get $gFabric] {
2025
set node [lindex $nNNode 1]
2026
set sys [IBNode_p_system_get $node]
2027
set name "[IBSystem_name_get $sys]/[lindex $nNNode 0]"
2028
set devId [IBNode_devId_get $node]
2029
set lid [getNodeLid $node]
2031
puts "-W- Ignoring node $name with zero LID"
2035
# differet treatment for switches and HCAs
2041
# port 1 0x100A0.24 (len 7)
2042
set v [crRead $lid 0x100A0]
2043
set d [assoc data $v]
2045
puts "-W- Failed to obtain data from $name lid:$lid"
2049
set nd [format 0x%x [expr $d & 0x8fffffff | ($staticCredits << 24)]]
2051
puts "-I- Updating $name P1 $d -> $nd"
2052
crWrite $lid $nd 0x100A0
2054
if {$devId != 25208} {
2056
set v [crRead $lid 0x108A0]
2057
set d [assoc data $v]
2059
puts "-W- Failed to obtain data from $name lid:$lid"
2063
set nd [format 0x%x [expr $d & 0x8fffffff | ($staticCredits << 24)]]
2065
puts "-I- Updating $name P2 $d -> $nd"
2066
crWrite $lid $nd 0x108A0
2072
for {set i 0} {$i < 24} {incr i} {
2073
# IB port 1 101280.16
2074
# CR 0 101280.16 (len 16)
2077
set v [crRead $lid $addr]
2078
set d [assoc data $v]
2080
puts "-W- Failed to obtain data from $name lid:$lid"
2083
set nd [format 0x%x [expr $d & 0xffff | ($staticCredits << 16)]]
2085
puts "-I- Updating $name P[expr $i + 1] $d -> $nd"
2086
crWrite $lid $nd $addr
2093
puts "-W- Ignoring node $name with devId:$devId"
2103
global IBDIAGNET_FLAGS
2105
# can we just load existing files?
2106
if {$testModeDir != 0} {
2107
set f [open [file join $testModeDir ibdiagnet.stdout.log] r]
2110
set lstFile [file join $testModeDir ibdiagnet.lst]
2112
set lstFile /tmp/ibdiagnet.lst
2114
LogAppend "-I-Invoking ibdiagnet ...."
2115
# puts "-I- Invoking ibdiagnet ...."
2116
if {[catch {set r [eval "exec ibdiagnet $IBDIAGNET_FLAGS"]} e]} {
2117
set res "-E- Error calling ibdiagnet:$e\n"
2126
GraphUpdate $lstFile
2129
# reread the annotations file and enforce DISABLED state
2130
# and UP for the rest
2131
proc EnforceAnnotations {} {
2136
foreach e [array names ANNOTATIONS sysport:*] {
2137
set sysPortName [string range $e [string length sysport:] end]
2138
set anno $ANNOTATIONS($e)
2141
set sysPort [findSysPortByName $sysPortName]
2142
if {$sysPort == ""} {
2143
puts "-W- failed to find sys port:$sysPortName"
2147
set port [IBSysPort_p_nodePort_get $sysPort]
2148
set node [IBPort_p_node_get $port]
2150
if {[regexp DISABLED $anno]} {
2151
SetStatus "-I- Disabling $sysPortName"
2155
SetStatus "-I- Enabling $sysPortName"
2160
set drPath [getDrToNode $node]
2161
if {$drPath == -1} {
2165
set portNum [IBPort_num_get $port]
2166
catch {set res [exec ibportstate -D $drPath $portNum $state]}
2168
SetStatus "-I- Annotation Enforced: Enabled:$numEn Disbled:$numDis"
2172
proc FindByName {} {
2174
if {![winfo exists .find_by_name]} {
2175
set t [toplevel .find_by_name]
2178
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2180
labelframe $f.e -text "Name:" -padx 2 -pady 2 -borderwidth 2
2181
entry $f.e.e -textvariable FindByName(name)
2182
pack $f.e.e -side left -fill x -expand yes
2184
labelframe $f.b -text "Object Type:" -padx 2 -pady 2 -borderwidth 2
2185
foreach {type name} {system System sysport "System Port" node Node port Port} {
2186
radiobutton $f.b.b$type -text "$name" -variable FindByName(type) \
2187
-relief flat -value $type
2188
pack $f.b.b$type -side top -pady 2 -anchor w
2190
pack $f.e $f.b -side top -expand yes -fill both
2192
button $f.x.f -text FIND \
2193
-command {guiHighLightByName $FindByName(type) $FindByName(name)}
2194
button $f.x.c -text CLEAR -command guiClearAllMarking
2195
pack $f.x.f $f.x.c -side left -fill x -expand yes
2196
pack $f.x -side bottom -fill x -expand yes
2198
wm title .find_by_name "IBDiagUI - Find object by name"
2199
set FindByName(type) system
2202
wm deiconify .find_by_name
2205
proc FindByGUID {} {
2207
if {![winfo exists .find_by_guid]} {
2208
set t [toplevel .find_by_guid]
2211
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2213
labelframe $f.e -text "GUID:" -padx 2 -pady 2 -borderwidth 2
2214
entry $f.e.e -textvariable FindByGuid(guid)
2215
pack $f.e.e -side left -fill x -expand yes
2217
labelframe $f.b -text "Object Type:" -padx 2 -pady 2 -borderwidth 2
2218
foreach {type name} {system "System" sysport "System Port" node "Node" port "Port"} {
2219
radiobutton $f.b.b$type -text "$name" -variable FindByGuid(type) \
2220
-relief flat -value $type
2221
pack $f.b.b$type -side top -pady 2 -anchor w
2223
pack $f.e $f.b -side top -expand yes -fill both
2225
button $f.x.f -text FIND \
2226
-command {guiHighLightByGuid $FindByGuid(type) $FindByGuid(guid)}
2227
button $f.x.c -text CLEAR -command guiClearAllMarking
2228
pack $f.x.f $f.x.c -side left -fill x -expand yes
2229
pack $f.x -side bottom -fill x -expand yes
2231
wm title .find_by_guid "IBDiagUI - Find object by GUID"
2232
set FindByGuid(type) system
2235
wm deiconify .find_by_guid
2240
if {![winfo exists .find_by_lid]} {
2241
set t [toplevel .find_by_lid]
2244
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2246
labelframe $f.e -text "LID:" -padx 2 -pady 2 -borderwidth 2
2247
entry $f.e.e -textvariable FindByLid(lid)
2248
pack $f.e.e -side left -fill x -expand yes
2250
labelframe $f.b -text "Object Type:" -padx 2 -pady 2 -borderwidth 2
2251
foreach {type name} {system "System" sysport "System Port" node "Node" port "Port"} {
2252
radiobutton $f.b.b$type -text "$name" -variable FindByLid(type) \
2253
-relief flat -value $type
2254
pack $f.b.b$type -side top -pady 2 -anchor w
2256
pack $f.e $f.b -side top -expand yes -fill both
2258
button $f.x.f -text FIND \
2259
-command {guiHighLightByLid $FindByLid(type) $FindByLid(lid)}
2260
button $f.x.c -text CLEAR -command guiClearAllMarking
2261
pack $f.x.f $f.x.c -side left -fill x -expand yes
2262
pack $f.x -side bottom -fill x -expand yes
2264
wm title .find_by_lid "IBDiagUI - Find object holding a LID"
2265
set FindByLid(type) system
2268
wm deiconify .find_by_lid
2273
if {![winfo exists .find_by_dr]} {
2274
set t [toplevel .find_by_dr]
2277
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2279
labelframe $f.e -text "Directed Route:" -padx 2 -pady 2 -borderwidth 2
2280
entry $f.e.e -textvariable FindByDR(DR)
2281
pack $f.e.e -side left -fill x -expand yes
2283
labelframe $f.p -text "Start Port:" -padx 2 -pady 2 -borderwidth 2
2284
entry $f.p.e -textvariable FindByDR(port)
2285
pack $f.p.e -side left -fill x -expand yes
2286
pack $f.e $f.p -side top -expand yes -fill both
2288
button $f.x.f -text FIND \
2289
-command {guiHighLightByDR $FindByDR(port) $FindByDR(DR)}
2290
button $f.x.c -text CLEAR -command guiClearAllMarking
2291
pack $f.x.f $f.x.c -side left -fill x -expand yes
2292
pack $f.x -side bottom -fill x -expand yes
2294
wm title .find_by_dr "IBDiagUI - Find objects on a Directed Route"
2295
set FindByDR(port) "$G(argv:sys.name)/P$G(argv:port.num)"
2297
wm deiconify .find_by_dr
2301
proc setColor {b opt} {
2303
foreach {w desc val} $O($opt) {break}
2304
set color [tk_chooseColor -title "Choose a $desc color" -initialcolor $val]
2306
set O($opt) [list $w $desc $color]
2307
$b configure -background $color
2311
proc getColor {col} {
2313
if {[info exists O(color:$col)]} {
2314
return [lindex $O(color:$col) 2]
2316
puts "-W- could not find color $col"
2322
# Display a form for setting fabric roots
2325
if {![winfo exists .set_roots_opts]} {
2326
set t [toplevel .set_roots_opts]
2329
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2330
label $f.l -text "Root systems names:"
2331
entry $f.e -textvariable SYSTEM_ORDER
2332
button $f.b -text REDRAW -command "drawFabric $gFabric $C"
2333
pack $f.l $f.e $f.b -side top -expand true -fill x
2335
wm title .set_roots_opts "IBDiagUI - Set Roots Options"
2337
wm deiconify .set_roots_opts
2340
# Display a form for setting colors
2341
proc SetColorOpts {} {
2343
if {![winfo exists .set_color_opts]} {
2344
set t [toplevel .set_color_opts]
2347
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2348
set prevFirstWord ""
2349
foreach opt [lsort [array name O color:*]] {
2350
foreach {w desc val} $O($opt) {break}
2351
set firstWord [lindex $desc 0]
2352
if {$firstWord != $prevFirstWord} {
2353
set wName [string tolower $firstWord]
2354
set wf [labelframe $f.$wName -text "$firstWord:" \
2355
-padx 2 -pady 2 -borderwidth 2]
2356
pack $wf -side top -expand yes -fill x
2357
set prevFirstWord $firstWord
2359
button $wf.$w -text [lrange $desc 1 end] \
2360
-command "setColor $wf.$w $opt" \
2362
pack $wf.$w -side left -pady 2 -anchor w -fill x
2365
wm title .set_color_opts "IBDiagUI - Set Color Options"
2367
wm deiconify .set_color_opts
2370
proc SetAnnotationsFile {} {
2372
if {![winfo exists .load_annos]} {
2373
set t [toplevel .load_annos]
2376
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2377
label $f.l -text "Annotation File Name"
2378
entry $f.e -textvariable ANNOTATION_FILE
2379
button $f.b -text LOAD -command LoadAnnotationsFile
2380
pack $f.l $f.e $f.b -side top -expand yes -fill x
2383
wm title .load_annos "IBDiagUI - Set Color Options"
2385
if {![info exists ANNOTATION_FILE]} {
2386
set ANNOTATION_FILE ""
2389
wm deiconify .load_annos
2392
proc SetIBDiagFlags {} {
2394
if {![winfo exists .ibdiag_flags]} {
2395
set t [toplevel .ibdiag_flags]
2398
set f [frame $t.f -padx 2 -pady 2 -borderwidth 2]
2399
label $f.l -text "IBDiagNet Flags:"
2400
entry $f.e -textvariable IBDIAGNET_FLAGS
2401
pack $f.l $f.e -side top -expand yes -fill x
2404
wm title .ibdiag_flags "IBDiagUI - Set IBDiagNet Flags"
2406
wm deiconify .ibdiag_flags
2411
catch {destroy .help_about}
2412
set tl [toplevel .help_about]
2418
Author: Eitan Zahavi <eitan@mellanox.co.il>
2423
##############################################################################
2425
# GUI INITIALIZATION
2427
##############################################################################
2429
# save as much as possible in .ibdiagui
2432
global ANNOTATION_FILE
2434
if {[catch {set f [open .ibdiagui w]} ]} {
2438
puts $f "wm geometry . [wm geometry .]"
2440
foreach w [array names PANES] {
2441
foreach idx $PANES($w) {
2442
set coords [$w sash coord $idx]
2443
puts $f "$w sash place $idx [lindex $coords 0] [lindex $coords 1]"
2447
foreach opt [array names O] {
2448
puts $f "set O($opt) {$O($opt)}"
2451
puts $f "set ANNOTATION_FILE \"$ANNOTATION_FILE\""
2457
proc initMenuBar {m} {
2458
menubutton $m.file -text File -underline 0 -menu $m.file.menu
2459
menubutton $m.refresh -text Refresh -underline 0 -menu $m.refresh.menu
2460
menubutton $m.find -text Find -underline 0 -menu $m.find.menu
2461
menubutton $m.opts -text Options -underline 0 -menu $m.opts.menu
2463
menu $m.file.menu -tearoff no
2464
$m.file.menu add command -label Quit -command guiQuit
2466
menu $m.refresh.menu -tearoff no
2467
$m.refresh.menu add command -label Network -command DiagNet
2468
$m.refresh.menu add command -label "Enforce Annotations" \
2469
-command EnforceAnnotations
2470
$m.refresh.menu add command -label "Add Statics to VL0" \
2471
-command SetVL0Statics
2473
menu $m.find.menu -tearoff no
2474
$m.find.menu add command -label Name -command FindByName
2475
$m.find.menu add command -label GUID -command FindByGUID
2476
$m.find.menu add command -label LID -command FindByLID
2477
$m.find.menu add command -label Route -command FindByDR
2479
menu $m.opts.menu -tearoff no
2480
$m.opts.menu add command -label Colors -command SetColorOpts
2481
$m.opts.menu add command -label "Set Roots" -command SetRoots
2482
$m.opts.menu add command -label "Set Annotation File" \
2483
-command SetAnnotationsFile
2484
$m.opts.menu add command -label "Set IBDiagNet Options" \
2485
-command SetIBDiagFlags
2487
menubutton $m.help -text Help -underline 0 -menu $m.help.menu
2488
menu $m.help.menu -tearoff no
2489
$m.help.menu add command -label About -command HelpAbout
2491
pack $m.file $m.refresh $m.find $m.opts -side left
2493
pack $m.help -side right
2496
#--------------------------------------------------------
2497
# Init the main windows and provide their ids in globals:
2498
# G - the graphic canvas widget id
2499
# P - the props frame
2500
# L - the LOG text widget
2501
#--------------------------------------------------------
2502
proc initMainFrame {f} {
2505
#--------------------------------------------------------
2506
# The hierarchy of widgets we build is defined below
2508
# pw1 - the main pane split vertically
2509
# tf - the top frame
2510
# pw2 - the second pane - this time horizontal
2511
# gf - graphic frame
2513
# chs - canvas horizonal scroll
2514
# cvs - canvas vertical scroll
2517
# bf - the bottom frame
2519
# ths - text horizonal srcolll
2520
# tvs - text vertical srcolll
2522
#--------------------------------------------------------
2524
# pw1 - the main pane split vertically
2525
set pw1 [panedwindow $f.pw1 -orient vertical -showhandle yes]
2528
# tf - the top frame
2529
set tf [frame $pw1.tf]
2530
# pw2 - the second pane - this time horizontal
2531
set pw2 [panedwindow $tf.pw2 -showhandle yes]
2534
# gf - graphic frame
2535
set gf [frame $tf.gf]
2537
set gg [frame $gf.g]
2538
# chs - canvas horizonal scroll
2539
set chs [scrollbar $gf.chs -orient horiz -command "$gf.c xview"]
2540
# cvs - canvas vertical scroll
2541
set cvs [scrollbar $gf.cvs -orient vertical -command "$gf.c yview"]
2543
set c [canvas $gf.c -relief sunken -borderwidth 2 \
2544
-scrollregion {-11c -11c 11c 11c} \
2545
-xscrollcommand "$chs set" \
2546
-yscrollcommand "$cvs set" ]
2548
set pf [frame $tf.pf]
2549
# bf - the bottom frame
2550
set bf [frame $pw1.bf]
2552
set tg [frame $bf.g]
2553
# ths - text horizonal srcolll
2554
set ths [scrollbar $bf.ths -orient horiz -command "$bf.t xview"]
2555
# tvs - text vertical srcolll
2556
set tvs [scrollbar $bf.tvs -orient vertical -command "$bf.t yview"]
2559
-yscrollcommand "$tvs set" \
2560
-xscrollcommand "$ths set" \
2563
#--------------------------------------------------------
2565
#--------------------------------------------------------
2568
pack $gg -expand yes -fill both -padx 1 -pady 1
2569
grid rowconfig $gg 0 -weight 1 -minsize 0
2570
grid columnconfig $gg 0 -weight 1 -minsize 0
2571
grid $c -padx 1 -in $gg -pady 1 \
2572
-row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
2573
grid $cvs -in $gg -padx 1 -pady 1 \
2574
-row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
2575
grid $chs -in $gg -padx 1 -pady 1 \
2576
-row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
2578
# graphic / prop pane
2582
pack $pw2 -side top -expand yes -fill both -pady 2 -padx 2m
2583
$pw2 paneconfigure $gf -sticky news -width 10c
2584
$pw2 paneconfigure $pf -sticky news -minsize 4c
2586
# the frame holding it
2587
# pack $tf -side top -expand yes -fill both
2588
pack $tf -side top -fill both
2591
pack $tg -expand yes -fill both -padx 1 -pady 1
2592
grid rowconfig $tg 0 -weight 1 -minsize 0
2593
grid columnconfig $tg 0 -weight 1 -minsize 0
2594
grid $t -padx 1 -in $tg -pady 1 \
2595
-row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
2596
grid $tvs -in $tg -padx 1 -pady 1 \
2597
-row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
2598
grid $ths -in $tg -padx 1 -pady 1 \
2599
-row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
2601
# the frame holding it
2602
# pack $bf -side top -expand yes -fill x
2603
pack $bf -side top -fill x
2605
# the main pane window
2607
pack $pw1 -side top -expand yes -fill both -pady 2 -padx 2m
2608
# $pw1 paneconfigure $tf -minsize 15c
2609
# $pw1 paneconfigure $bf
2611
bind $c <3> "zoomMark $c %x %y"
2612
bind $c <B3-Motion> "zoomStroke $c %x %y"
2613
bind $c <ButtonRelease-3> "zoomArea $c %x %y"
2614
bind $c <KeyPress-z> "zoom $c 1.25"
2615
bind $c <KeyPress-Z> "zoom $c 0.8"
2616
bind $c <KeyPress-f> "fit $c"
2617
bind . <3> "zoomMark $c %x %y"
2618
bind . <B3-Motion> "zoomStroke $c %x %y"
2619
bind . <ButtonRelease-3> "zoomArea $c %x %y"
2620
bind . <KeyPress-z> "zoom $c 1.25"
2621
bind . <KeyPress-Z> "zoom $c 0.8"
2622
bind . <KeyPress-f> "fit $c"
2623
bind . <KeyPress-e> "expand $c %x %y"
2624
bind . <KeyPress-d> "deExpand $c %x %y"
2625
bind . <KeyPress-c> "guiClearAllMarking"
2631
$L tag bind NAME <Button-1> "LogObjSelect $L NAME %W %x %y"
2632
$L tag bind LID <Button-1> "LogObjSelect $L LID %W %x %y"
2633
$L tag bind GUID <Button-1> "LogObjSelect $L GUID %W %x %y"
2634
$L tag bind ROUTE <Button-1> "LogObjSelect $L ROUTE %W %x %y"
2637
proc setLogColors {} {
2639
$L tag configure errors -foreground [getColor txtErr]
2640
$L tag configure warnings -foreground [getColor txtWarn]
2641
$L tag configure infos -foreground [getColor txtInfo]
2642
$L tag configure NAME -background [getColor txtName]
2643
$L tag configure LID -background [getColor txtLid]
2644
$L tag configure GUID -background [getColor txtGuid]
2645
$L tag configure ROUTE -background [getColor txtRoute]
2649
global O L S StatusLine P
2650
global ANNOTATION_FILE
2651
# . configure -background white -width 10i -height 10i
2653
# menu is a separate line at the top
2654
frame .m -relief raised -padx 2 -pady 2
2655
pack .m -side top -expand no -fill x -anchor nw
2658
# the pane structure
2659
frame .r -relief ridge -height 10i -width 10i
2660
pack .r -side top -expand yes -fill both
2664
entry .s.e -relief flat -state readonly -textvariable StatusLine
2665
pack .s.e -fill x -expand true -side bottom
2666
pack .s -side bottom -fill x
2672
set O(color:txtDef) {ld "Log Msg Default" black}
2673
set O(color:txtErr) {le "Log Msg Error" red }
2674
set O(color:txtWarn) {lw "Log Msg Warning" "#704000"}
2675
set O(color:txtInfo) {li "Log Msg Info" darkgreen }
2676
set O(color:txtName) {ln "Log Tag Name" "#909000" }
2677
set O(color:txtLid) {ll "Log Tag LID" "#fb9933" }
2678
set O(color:txtGuid) {lg "Log Tag GUID" "#906070" }
2679
set O(color:txtRoute) {lr "Log Tag Route" "#aa40a0"}
2681
set O(color:1x2.5G) {p1x25g "Link 1x 2.5G" "#ff0000"}
2682
set O(color:1x5G) {p1x5g "Link 1x 5G" "#c80000"}
2683
set O(color:1x10G) {p1x10g "Link 1x 10G" "#960000"}
2684
set O(color:4x2.5G) {p4x25g "Link 4x 2.5G" "#00ff00"}
2685
set O(color:4x5G) {p4x5g "Link 4x 5G" "#00c800"}
2686
set O(color:4x10G) {p4x10g "Link 4x 10G" "#009600"}
2687
set O(color:12x2.5G) {p12x25g "Link 12x 2.5G" "#0000ff"}
2688
set O(color:12x5G) {p12x5g "Link 12x 5G" "#00ff40"}
2689
set O(color:12x10G) {p12x10g "Link 12x 10G" "#00ff80"}
2691
set O(color:sys) {sys "Props System" "#ff5e1b"}
2692
set O(color:node) {node "Props Node" "#00beff"}
2693
set O(color:port) {port "Props Port" "#00ff96"}
2694
set O(color:sysport) {sysp "Props System Port" "#f400cc"}
2696
set O(color:mark) {mark "Marking Selected" "#f400f1"}
2697
set O(color:mtxt) {mtxt "Marking Text" "#0000ff"}
2699
if {[file exists .ibdiagui]} {
2703
# actuall set the colors on the text tags
2707
SetStatus "Initializing ... "
2710
##############################################################################
2715
# we provide a way to load the results of ibdiagnet for testing
2716
# to do this provide -D <dir name> that dir needs to have:
2717
# ibdiagnet.stdout.log
2719
# OPTIONAL: ibdiagnet.topo
2720
set testModeDirIdx [lsearch $argv "-D"]
2721
if {$testModeDirIdx >= 0} {
2722
set testModeDir [lindex $argv [expr $testModeDirIdx + 1]]
2723
if {![file exists [file join $testModeDir ibdiagnet.lst]]} {
2724
puts "-E- No [file join $testModeDir ibdiagnet.lst]"
2727
if {![file exists [file join $testModeDir ibdiagnet.stdout.log]]} {
2728
puts "-E- No [file join $testModeDir ibdiagnet.stdout.log]"
2731
set argv [lreplace $argv $testModeDirIdx [expr $testModeDirIdx + 1]]
2736
set IBDIAGNET_FLAGS $argv
2740
if {! [info exists G(argv:sys.name)]} {
2741
set G(argv:sys.name) [lindex [split [info hostname] .] 0]
2744
# We init the Tk only after parsing the command line
2745
# to avoid the interpretation of args by Tk.
2746
if {[catch {package require Tk} e]} {
2747
puts "-E- ibdiagui depends on a Tk installation"
2748
puts " Please download and install tk8.4"
2753
if {[catch {package require Tcldot} e]} {
2754
puts "-E- ibdiagui depends on a Tcldot installation"
2755
puts " Please download and install Graphviz"
2760
if {[catch {initGui} e]} {
2766
if {[catch {DiagNet} e]} {
2771
package provide ibdiagui 1.0