forked from keysightgems/Huawei_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIxia_NetNgpfPort.tcl
More file actions
3406 lines (3098 loc) · 104 KB
/
Ixia_NetNgpfPort.tcl
File metadata and controls
3406 lines (3098 loc) · 104 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (c) Ixia technologies 2010-2011, Inc.
# Release Version 2.20
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# Version 1.1.1.1
# 1. Add get_status method to achieve status of port
# 2. Add sub-interface configuration in config method
# Version 1.2.1.2
# 3. Add ping method
# Version 1.3.1.8
# 4. Add reset method
# Version 1.4.1.16
# 5. Add multi-interface in Port::config
# Version 1.5.2.1
# 6. Clear ownership in GetRealPort
# Version 1.6.2.4
# 7. Add get_stats method
# 8. Add Host class to emulate a host
# Version 1.7.2.6
# 9. Add Connect method to connect to hardware port
# Version 1.8.2.7
# 10. Add check strange port in ctor
# Version 1.9.2.9
# 11. Enable Ping defaultly
# Version 1.10.2.10
# 12. Add port_mac_addr param in Port.get_status
# Version 1.11.2.11
# 13. Port reborn
# Version 1.12.2.12
# 14. Add default mac and ip in properties
# Version 1.13.2.17
# 15. Replace connectedTo to AssignPorts to fix no license problem
# Version 1.14.3.0
# 16. Replace autoInstrumentation to floating to adapt with 10GE
# 17. Add data integrity stats when rx equals 0
# Version 1.15.3.5
# 18. Add ipv6 int addr in config
# Version 1.16.3.10
# 19. Add Host.ping
# Version 1.17.4.18
# 20. Add set_port_stream_load to set load of all stream under certain port
# Version 1.18.4.19
# 21. configure "transmit ignore link" after assign port
# 22. use assign ports when ctor and usual connectedTo ports when reborn and cleanup reserve port
# Version 1.19.4.20
# 23. add oversize stat in rx_frame_count
# Version 1.20.4.23
# 24. add total_frame_count in Port::get_stats
# 25. add Port::break_link and Port::restore_link
# Version 1.20.4.26
# 26. Create Port obj by existing port handle in Port.ctor
# 26. modify Port::set_port_stream_load
# Version 1.21.4.27
# 27. modify Host::config src_mac format
# Version 1.22.4.28
# 28. Add catch for Data Plane Port Statistics command
# 29. modify Port::set_port_stream_load , change stream_load into L1 speed
# Version 1.23.4.29
# 30. modify port.set_dhcpv4,add lease_time
# Version 1.24.4.30
# 31. modify port.set_dhcpv4,add max_request_rate,request_rate_step,
# add max_release_rate,release_rate_step
# 32. add port.start_traffic,port.stop_traffic
# Version 1.25.4.31
# 33. add resume method to resume all streams under port
# Version 1.26.4.32
# 34. remove vlan configure in Port.config
# 35. add method set_dot1x
# Version 2.08.4.33
# 36. remove vlan configure in Port.config
# Version 2.10.4.34
# 37. add ipv4_gw_step/ipv6_gw_step in Host.config
# Version 2.11.4.44
# 38. use dynamic port type for flow-control in port.config
# Version 2.12.4.46
# 39. don't check link on port in ctor
# 40. set auto_instrumentation default to endOfFrame
# Version 2.13.4.49
# 41. modify port.start_traffic to fix bug of apply traffic
# Version 2.14.4.53
# 42. fix bug in Host.config
# Version 2.15.4.54
# 43. add Port.set_port_dynamic_rate
# Version 2.16.4.59
# 44. remove param validation in port.config
# Version 2.17.4.60
# 45. add port.Reconnect
# Version 2.17.4.60
# 46. modify Host.enable|disable, add hostInfo for 3918
# Version 2.18.4.70
# 47. modify for loadconfigmode
# Version 2.19.4.71
# 48. add start_router, stop_router
# Version 2.20 4.78
# 49. add reset_handle, when custom use Tester::cleanup -new_config 1 , connect port, handle should be empty
# Version 2.21 4.78
# 50. add modify_handle
class Port {
inherit NetObject
public variable topoHandle
public variable dgHandle
public variable ipv4Handle
public variable ipv6Handle
public variable ethHandle
variable PortHandle
public variable ipVersion
set ipVersion ""
constructor { { hw_id NULL } { medium NULL } { hPort NULL } {force 0} } {}
method config { args } {}
method get_status {} {}
method get_stats {} {}
method ping { args } {}
method send_arp { } {}
method reset {} {}
method reset_handle {} {
set tag "body Port::reset_handle [info script]"
Deputs "----- TAG: $tag -----"
set handle ""
}
method modify_handle { value } {
set tag "body Port::modify_handle [info script]"
Deputs "----- TAG: $tag -----"
set handle $value
}
method start_traffic {} {}
method stop_traffic {} {}
method start_router { args } {}
method stop_router { args } {}
method break_link {} {}
method restore_link {} {}
method set_port_stream_load { args } {}
method set_port_dynamic_rate { args } {}
method resovle_mac { args } {
set tag "body Port::resovle_mac [info script]"
Deputs "----- TAG: $tag -----"
global errorInfo
global errNumber
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-neighbor_ip {
if { $value != "" } {
if { [ IsIPv4Address $value ] } {
set neighbor_ip $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
}
default {
error "$errNumber(3) key:$key value:$value"
}
}
}
if { [ info exists neighbor_ip ] } {
Deputs "get neighbor"
set neighbor [ ixNet getF $handle discoveredNeighbor -neighborIp $neighbor_ip ]
if { $neighbor == "" } {
return "00:00:00:00:00:00"
}
Deputs "neighbor:$neighbor"
Deputs "get neighbor mac"
set neighbor_mac [ ixNet getA $neighbor -neighborMac ]
Deputs "neighbor mac:$neighbor_mac"
}
if { [ IsMacAddress $neighbor_mac ] } {
return $neighbor_mac
} else {
return "00:00:00:00:00:00"
}
}
method set_dhcpv4 { args } {}
method set_dhcpv6 { args } {}
method set_dot1x {args } {}
method resume {} {
set tag "body Traffic::resume [info script]"
Deputs "----- TAG: $tag -----"
set info [ ixNet getA $handle -connectionInfo ]
regexp {chassis="(\d+.\d+.\d+.\d+)"} $info chas chasAddr
regexp {card="(\d+)"} $info card cardId
regexp {port="(\d+)"} $info port portId
if { [ ixConnectToChassis ] == 0 } {
set tclServer [ lindex [ split $loginInfo "/" ] 0 ]
ixConnectToTclServer $tclServer
ixConnectToChassis $chasAddr
}
chassis get $chasAddr
set chasId [ chassis cget -id ]
port get $chasId $cardId $portId
set owner [ port cget -owner ]
ixLogin $owner
set pl [ list [ list $chasId $cardId $portId ] ]
ixTakeOwnership $pl
set streamCount [ port getStreamCount $chasId $cardId $portId ]
set sl [ list ]
for { set id 1 } { $id <= $streamCount } { incr id } {
lappend sl $id
}
return stream resume $chasId $cardId $portId $sl
}
method GetRealPort { chas card port force } {}
method Connect { location { medium NULL } { checkLink 0 } {force 0}} {}
method Reconnect { location { medium NULL } { checkLink 0 } {force 0} } {}
method CheckStrangePort {} {}
method GetProtocolsHandleList {} {
set tag "body Port::GetProtocolsHandleList [info script]"
Deputs "----- TAG: $tag -----"
array set deviceList ""
array set bgpList ""
array set isisList ""
array set ldpList ""
array set ospfList ""
array set ospfv3List ""
array set dhcpList ""
array set pppoxList ""
array set igmpList ""
array set mldList ""
array set ripList ""
array set ripngList ""
array set l2tpList ""
set vport_protocols [ixNet getL $handle protocols]
set vport_protocolStack [ixNet getL $handle protocolStack]
#bgp
set bgpH [ixNet getL $vport_protocols bgp]
if {[ixNet getA $bgpH -enabled] == "true" } {
#only can start bgpH, can disable bgpNR
set deviceList(bgp) $bgpH
foreach bgpNR [ixNet getL $bgpH neighborRange] {
if { [catch {
set bgpNR_name [ixNet getA [ixNet getA $bgpNR -interfaces] -description]
set bgpList($bgpNR_name) $bgpNR
} ] } {
Deputs " No interface bind to bgp"
}
}
}
#isis
set isisH [ixNet getL $vport_protocols isis]
if {[ixNet getA $isisH -enabled] == "true" } {
#only can start isisH, can disable isisR
set deviceList(isis) $isisH
foreach isisR [ixNet getL $isisH router] {
# set isisIntface [lindex [ixNet getL $isisR interface] 0]
# set isisR_name [ixNet getA [ixNet getA $isisIntface -interfaceId] -description]
# set isisList($isisR_name) $isisR
if { [catch {
set isisIntface [lindex [ixNet getL $isisR interface] 0]
set isisR_name [ixNet getA [ixNet getA $isisIntface -interfaceId] -description]
set isisList($isisR_name) $isisR
} ] } {
Deputs " No interface bind to isis"
}
}
}
#ldp
set ldpH [ixNet getL $vport_protocols ldp]
if {[ixNet getA $ldpH -enabled] == "true" } {
set deviceList(ldp) $ldpH
foreach ldpR [ixNet getL $ldpH router] {
# set ldpIntface [lindex [ixNet getL $ldpR interface] 0]
# set ldpR_name [ixNet getA [ixNet getA $ldpIntface -protocolInterface] -description]
# set ldpList($ldpR_name) $ldpR
if { [catch {
set ldpIntface [lindex [ixNet getL $ldpR interface] 0]
set ldpR_name [ixNet getA [ixNet getA $ldpIntface -protocolInterface] -description]
set ldpList($ldpR_name) $ldpR
} ] } {
Deputs " No interface bind to ldp"
}
}
}
#igmp
set igmpH [ixNet getL $vport_protocols igmp]
if {[ixNet getA $igmpH -enabled] == "true" } {
#only can start isisH, can disable isisR
set deviceList(igmp) $igmpH
foreach igmpR [ixNet getL $igmpH host] {
if { [catch {
set igmpR_name [ixNet getA [ixNet getA $igmpR -interfaces] -description]
set igmpList($igmpR_name) $igmpR
} ] } {
Deputs " No interface bind to igmp"
}
}
}
#mld
set mldH [ixNet getL $vport_protocols mld]
if {[ixNet getA $mldH -enabled] == "true" } {
#only can start mldH, can disable mldR
set deviceList(mld) $mldH
foreach mldR [ixNet getL $mldH host] {
# set mldR_name [ixNet getA [ixNet getA $mldR -interfaces] -description]
# set mldList($mldR_name) $mldR
if { [catch {
set mldR_name [ixNet getA [ixNet getA $mldR -interfaces] -description]
set mldList($mldR_name) $mldR
} ] } {
Deputs " No interface bind to mld"
}
}
}
#rip
set ripH [ixNet getL $vport_protocols rip]
if {[ixNet getA $ripH -enabled] == "true" } {
#only can start ripH, can disable ripR
set deviceList(rip) $ripH
foreach ripR [ixNet getL $ripH router] {
# set ripR_name [ixNet getA [ixNet getA $ripR -interfaceId] -description]
# set ripList($ripR_name) $ripR
if { [catch {
set ripR_name [ixNet getA [ixNet getA $ripR -interfaceId] -description]
set ripList($ripR_name) $ripR
} ] } {
Deputs " No interface bind to rip"
}
}
}
#ripng
set ripngH [ixNet getL $vport_protocols ripng]
if {[ixNet getA $ripngH -enabled] == "true" } {
#only can start ripngH, can disable ripngR
set deviceList(ripng) $ripngH
foreach ripngR [ixNet getL $ripngH router] {
# set ripngIntface [lindex [ixNet getL $ripngR interface] 0]
# set ripngR_name [ixNet getA [ixNet getA $ripngIntface -interfaceId] -description]
# set ripngList($ripngR_name) $ripngR
if { [catch {
set ripngIntface [lindex [ixNet getL $ripngR interface] 0]
set ripngR_name [ixNet getA [ixNet getA $ripngIntface -interfaceId] -description]
set ripngList($ripngR_name) $ripngR
} ] } {
Deputs " No interface bind to ripng"
}
}
}
#ospfv2
set ospfH [ixNet getL $vport_protocols ospf]
if {[ixNet getA $ospfH -enabled] == "true" } {
set deviceList(ospf) $ospfH
foreach ospfR [ixNet getL $ospfH router] {
# set ospfIntface [lindex [ixNet getL $ospfR interface] 0]
# set ospfR_name [ixNet getA [ixNet getA $ospfIntface -interfaces] -description]
# set ospfList($ospfR_name) $ospfR
if { [catch {
set ospfIntface [lindex [ixNet getL $ospfR interface] 0]
set ospfR_name [ixNet getA [ixNet getA $ospfIntface -interfaces] -description]
set ospfList($ospfR_name) $ospfR
} ] } {
Deputs " No interface bind to ospf"
}
}
}
#ospfv3
set ospfV3H [ixNet getL $vport_protocols ospfV3]
if {[ixNet getA $ospfV3H -enabled] == "true" } {
set deviceList(ospfv3) $ospfV3H
foreach ospfV3R [ixNet getL $ospfV3H router] {
# set ospfV3Intface [lindex [ixNet getL $ospfV3R interface] 0]
# set ospfV3R_name [ixNet getA [ixNet getA $ospfV3Intface -interfaces] -description]
# set ospfv3List($ospfV3R_name) $ospfV3R
if { [catch {
set ospfV3Intface [lindex [ixNet getL $ospfV3R interface] 0]
set ospfV3R_name [ixNet getA [ixNet getA $ospfV3Intface -interfaces] -description]
set ospfv3List($ospfV3R_name) $ospfV3R
} ] } {
Deputs " No interface bind to ospfv3"
}
}
}
#bfd
set bfdH [ixNet getL $vport_protocols bfd]
if {[ixNet getA $bfdH -enabled] == "true" } {
set deviceList(bfd) $bfdH
}
#rsvp
set rsvpH [ixNet getL $vport_protocols rsvp]
if {[ixNet getA $rsvpH -enabled] == "true" } {
set deviceList(rsvp) $rsvpH
}
#eth
set ethernetH_list [ixNet getL $vport_protocolStack ethernet ]
#dhcp/pppox/l2tp
if {$ethernetH_list != "" } {
foreach ethernetH $ethernetH_list {
set dhcpH [ixNet getL $ethernetH dhcpEndpoint]
if { $dhcpH != "" } {
set deviceList(dhcp) $dhcpH
foreach dhcpR [ixNet getL $dhcpH range] {
set dhcpR_name [ixNet getA [ixNet getL $dhcpR dhcpRange] -name]
set dhcpList($dhcpR_name) $dhcpR
}
}
set pppoxH [ixNet getL $ethernetH pppoxEndpoint]
if { $pppoxH != "" } {
set deviceList(pppox) $pppoxH
foreach pppoxR [ixNet getL $pppoxH range] {
set pppoxR_name [ixNet getA [ixNet getL $pppoxR pppoxRange] -name]
set pppoxList($pppoxR_name) $pppoxR
}
}
set ipH [ixNet getL $ethernetH ip]
if { $ipH != "" } {
set l2tpH [ixNet getL $ipH l2tpEndpoint]
if { $l2tpH != "" } {
set deviceList(l2tp) $l2tpH
foreach l2tpR [ixNet getL $l2tpH range] {
set l2tpR_name [ ixNet getA $l2tpH/l2tpRange -name ]
set l2tpList($l2tpR_name) $l2tpR
}
}
}
}
}
}
public variable location
public variable intf_mac
public variable intf_ipv4
public variable inter_burst_gap
public variable PortNo
public variable port_name
#loadconfig device list
public variable deviceList
public variable bgpList
public variable isisList
public variable ldpList
public variable ospfList
public variable ospfv3List
public variable dhcpList
public variable pppoxList
public variable igmpList
public variable mldList
public variable ripList
public variable ripngList
}
body Port::constructor { { hw_id NULL } { medium NULL } { hPort NULL } {force 0} } {
set tag "body Port::ctor [info script]"
Deputs "----- TAG: $tag -----"
global LoadConfigMode
set topoHandle " "
set dgHandle " "
set ipv4Handle " "
set ipv6Handle " "
set ethHandle " "
set port_name $this
# -- Check for Multiuser Login
set portObjList [ GetAllPortObj ]
if { [ llength $portObjList ] == 0 } {
Deputs "All port obj:[GetAllPortObj]"
set strangePort [ CheckStrangePort ]
Deputs "Strange port:$strangePort"
if { $strangePort == 0 } {
global loginInfo
Login $loginInfo
}
}
set handle ""
Deputs Step10
if { $hw_id != "NULL" } {
Deputs "hw_id:$hw_id"
# -- check hardware
set locationInfo [ split $hw_id "/" ]
set chassis [ lindex $locationInfo 0 ]
set ModuleNo [ lindex $locationInfo 1 ]
set PortNo [ lindex $locationInfo 2 ]
if { $LoadConfigMode } {
set handle [GetValidHandleObj "port" $hw_id]
if {$handle != ""} {
# ixNet setA $handle -name $this
# ixNet commit
set port_name [ixNet getA $handle -name]
}
}
if {$handle == "" } {
if { [ GetRealPort $chassis $ModuleNo $PortNo 0 ] == [ ixNet getNull ] } {
error "Port hardware not found: $hw_id"
}
Deputs Step20
catch {
if { $medium != "NULL" } {
set handle [ Connect $hw_id $medium 1 $force]
} else {
set handle [ Connect $hw_id NULL 0 $force]
}
}
}
set location $hw_id
Deputs "location:$location"
} else {
if { $hPort != "NULL" } {
set chassis ""
set card ""
set port ""
set handle $hPort
set connectionInfo [ ixNet getA $handle -connectionInfo ]
Deputs "connectionInfo :$connectionInfo"
regexp -nocase {chassis=\"([0-9\.]+)\" card=\"([0-9\.]+)\" port=\"([0-9\.]+)\"} $connectionInfo match chassis card port
Deputs "chas:$chassis card:$card port$port"
set location ${chassis}/${card}/${port}
ixNet setA $handle -name $this
ixNet commit
} else {
if { $LoadConfigMode } {
set handle [GetValidHandleObj "port" $this]
}
if { $handle== "" } {
Deputs "offline create"
set root [ixNet getRoot]
set handle [ixNet add $root vport]
# ixNet setA $handle -name $this
# ixNet commit
# set handle [ixNet remapIds $handle]
}
ixNet setA $handle -name $this
ixNet commit
set handle [ixNet remapIds $handle]
}
}
set PortHandle $handle
if { $LoadConfigMode } {
GetProtocolsHandleList
}
set intf_mac ""
set intf_ipv4 ""
set inter_burst_gap 12
}
body Port::CheckStrangePort {} {
set tag "body Port::CheckStrangePort [info script]"
Deputs "----- TAG: $tag -----"
set root [ ixNet getRoot]
for { set index 0 } { $index < 6 } { incr index } {
if { [ llength [ ixNet getL $root vport ] ] > 0 } {
Deputs "The connecting optional port $port is ocuppied, try next port..."
return 0
}
after 500
}
return 1
}
body Port::Connect { location { medium NULL } { checkLink 0 } { force 0 } } {
set tag "body Port::Connect [info script]"
Deputs "----- TAG: $tag -----"
# -- add vport
set root [ ixNet getRoot ]
if { $handle == "" } {
set vport [ ixNet add $root vport ]
ixNet setA $vport -name $this
ixNet commit
set vport [ixNet remapIds $vport]
set handle $vport
}
if { $medium != "NULL" } {
Deputs "connect medium:$medium"
# if {[ixNet getA $vport -type] == "ethernet" } {
# ixNet setA $vport/l1Config/ethernet -media $medium
# }
ixNet setA $handle/l1Config/[ixNet getA $handle -type] -media $medium
}
# -- connect to hardware
set locationInfo [ split $location "/" ]
set chassis [ lindex $locationInfo 0 ]
set ModuleNo [ lindex $locationInfo 1 ]
set PortNo [ lindex $locationInfo 2 ]
if { [ string tolower [ ixNet getA $root/statistics -guardrailEnabled ] ] != "true" } {
Deputs "guardrail: false"
catch {
ixNet setA $root/statistics -guardrailEnabled True
ixNet commit
}
Deputs "guardrail:[ ixNet getA $root/statistics -guardrailEnabled ]"
}
if { $checkLink } {
#fix license issue
ixTclNet::AssignPorts [ list [ list $chassis $ModuleNo $PortNo ] ] {} $handle true
} else {
ixNet setA $handle -connectedTo [ GetRealPort $chassis $ModuleNo $PortNo $force ]
ixNet commit
}
set handle [ixNet remapIds $handle]
Deputs "handle:$handle"
ixNet setA $handle -transmitIgnoreLinkStatus True
ixNet commit
return $handle
}
body Port::Reconnect { location { medium NULL } { checkLink 0 } { force 0 } } {
set tag "body Port::Reconnect [info script]"
Deputs "----- TAG: $tag -----"
# -- add vport
set root [ ixNet getRoot ]
# -- connect to hardware
set locationInfo [ split $location "/" ]
set chassis [ lindex $locationInfo 0 ]
set ModuleNo [ lindex $locationInfo 1 ]
set PortNo [ lindex $locationInfo 2 ]
if { [ string tolower [ ixNet getA $root/statistics -guardrailEnabled ] ] != "true" } {
Deputs "guardrail: false"
catch {
ixNet setA $root/statistics -guardrailEnabled True
ixNet commit
}
Deputs "guardrail:[ ixNet getA $root/statistics -guardrailEnabled ]"
}
if { $checkLink } {
#fix license issue
ixTclNet::AssignPorts [ list [ list $chassis $ModuleNo $PortNo ] ] {} $handle true
} else {
ixNet setA $handle -connectedTo [ GetRealPort $chassis $ModuleNo $PortNo $force ]
ixNet commit
}
set handle [ixNet remapIds $handle]
Deputs "handle:$handle"
ixNet setA $handle -transmitIgnoreLinkStatus True
ixNet commit
return $handle
}
body Port::GetRealPort { chassis card port force } {
set tag "body Port::GetRealPort [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "chassis:$chassis"
set root [ixNet getRoot]
if { [ llength [ixNet getList $root/availableHardware chassis] ] == 0 } {
Deputs Step20
set chas [ixNet add $root/availableHardware chassis]
ixNet setA $chas -hostname $chassis
ixNet commit
set chas [ixNet remapIds $chas]
} else {
Deputs Step30
set chas_list [ixNet getList $root/availableHardware chassis]
foreach chas $chas_list {
set hostname [ixNet getA $chas -hostname]
if { $hostname != $chassis } {
#ixNet remove $chas
#ixNet commit
set chas [ixNet add $root/availableHardware chassis]
ixNet setA $chas -hostname $chassis
ixNet commit
set chas [ixNet remapIds $chas]
break
} else {
break
}
}
}
set chassis $chas
set realCard $chassis/card:$card
Deputs "card:$realCard"
set cardList [ixNet getList $chassis card]
Deputs "cardList:$cardList"
set findCard 0
foreach ca $cardList {
eval set ca $ca
eval set realCard $realCard
Deputs "realCard:$realCard"
Deputs "ca:$ca"
if { $ca == $realCard } {
set findCard 1
break
}
}
Deputs Step10
Deputs "findCard:$findCard"
if { $findCard == 0} {
return [ixNet getNull]
}
set realPort $chassis/card:$card/port:$port
Deputs "port:$realPort"
set portList [ ixNet getList $chassis/card:$card port ]
Deputs "portList:$portList"
set findPort 0
foreach po $portList {
eval set po $po
eval set realPort $realPort
if { $po == $realPort } {
set findPort 1
break
}
}
Deputs "findPort:$findPort"
if { $findPort } {
Deputs "real port: $chassis/card:$card/port:$port"
if { $force } {
ixNet exec clearOwnership $chassis/card:$card/port:$port
}
return $chassis/card:$card/port:$port
} else {
return [ixNet getNull]
}
}
body Port::config { args } {
# object reborn
if { $handle == "" } {
if { $location != "NULL" } {
catch {
set handle [ Connect $location ]
}
set inter_burst_gap 12
} else {
return [ GetErrorReturnHeader "No port information or wrong port information." ]
}
}
puts "At config port::Config, handle value is ::$handle"
global errorInfo
global errNumber
# set EType [ list eth pos atm 10g_lan 10g_wan 40g_lan 100g_lan 40gpos ]
set EType [ list eth ethernetFcoe pos atm 10g_lan 10g_wan 40g_lan 100g_lan 40gpos ]
set EMedia [ list copper fiber ]
# set ESpeed [ list 10M 100M 1G 10G 40G 100G 155M 622M 2.5G 40GPOS ]
set EDuplex [ list full half ]
set flagInnerVlan 0
set flagOuterVlan 0
set inner_vlan_id 100
set inner_vlan_step 1
set inner_vlan_num 1
set inner_vlan_priority 0
set outer_vlan_id 100
set outer_vlan_step 1
set outer_vlan_num 1
set outer_vlan_priority 0
set enable_arp 1
set intf_ip_num 1
set intf_ip_mod 32
set dut_ip_num 1
set dut_ip_mod 32
set mask 24
set ipv6_mask 64
# set ipv6_addr_step ::1
set ipv6_addr_step 1
set intf_num 1
set ip_version "ipv4"
set flow_control 0
set sig_end 1
set tag "body Port::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-location {
set location $value
}
-intf_ip {
if { $value != "" } {
if { [ IsIPv4Address $value ] } {
set intf_ip $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
}
-intf_ip_num -
-intf_num -
-ipv6_addr_num -
-dut_ip_num {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set intf_num $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-intf_ip_step {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set intf_ip_step $value
# set intf_ip_step "0.0.$intf_ip_step.0"
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-intf_ip_mod {
set trans [ UnitTrans $value ]
if { [ string is integer $trans ] && $trans <= 32 && $trans >= 1 } {
set intf_ip_mod $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-dut_ip {
if { [ IsIPv4Address $value ] } {
set dut_ip $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-dut_ip_step {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set dut_ip_step $value
# set dut_ip_step "0.0.$dut_ip_step.0"
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-dut_ip_mod {
set trans [ UnitTrans $value ]
if { [ string is integer $trans ] && $trans <= 32 && $trans >= 1 } {
set dut_ip_mod $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-mask {
if { [ string is integer $value ] && $value <= 30 } {
set mask $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-type {
set value [ string tolower $value ]
if { [ lsearch -exact $EType $value ] >= 0 } {
set type $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-fec_enable {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set fec_enable $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-media {
set value [ string tolower $value ]
if { [ lsearch -exact $EMedia $value ] >= 0 } {
set media $value
Deputs "media:$media"
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-speed {
switch $value {
10M {
set speed 10
}
100M {
Deputs "speed:$speed"
set speed 100
}
1G {
set speed 1000
}
10G {
set speed "speed10g"
}
2.5G {
set speed "speed2.5g"
}
5G {
set speed "speed5g"
}
40G {
set speed "speed40g"
}
100G {
set speed "speed100g"
}
}
}
-auto_neg {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set auto_neg $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-duplex {
set value [ string tolower $value ]
if { [ lsearch -exact $EDuplex $value ] >= 0 } {
set duplex $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-enable_arp -
-enable_arp_reply {
set trans [ BoolTrans $value ]
if { $trans == "1" || $trans == "0" } {
set enable_arp $trans
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_enable {
set flagInnerVlan 1
}
-inner_vlan_id {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set inner_vlan_id $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_step {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set inner_vlan_step $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_num {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set inner_vlan_num $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-inner_vlan_priority {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 8 ) } {
set inner_vlan_priority $value
set flagInnerVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_enable {
set flagOuterVlan 1
}
-outer_vlan_id {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set outer_vlan_id $value
set flagOuterVlan 1