forked from keysightgems/Huawei_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIxia_NetNgpfOspf.tcl
More file actions
2360 lines (1952 loc) · 62.8 KB
/
Ixia_NetNgpfOspf.tcl
File metadata and controls
2360 lines (1952 loc) · 62.8 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 2020-2021, Inc.
# Release Version 1.1
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# 2. Update
# Version 1.1.4.34
# 3. Add reborn in Ospfv2Session.config Ospfv3Session.config
class OspfSession {
inherit RouterEmulationObject
public variable hNetworkRange
public variable OspfVersion
#global topoObj
#global deviceGroupObj
#global ethObj
constructor { port { hOspfSession NULL } } {
global errNumber
set tag "body OspfvSession::ctor [info script]"
Deputs "----- TAG: $tag -----"
set portObj [ GetObject $port ]
set handle ""
set ospfRtHandle ""
}
method reborn {} {
set tag "body OspfSession::reborn [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
Deputs "portObj is: $portObj"
set hPort [ $portObj cget -handle ]
Deputs "hPort is: $hPort"
} ] } {
error "$errNumber(1) Port Object in DhcpHost ctor"
}
set ospfV2Hndle [ixNet getA [ixNet getRoot]/globals/topology/ospfv2Router -enableDrBdr]
set ospfV3Hndle [ixNet getA [ixNet getRoot]/globals/topology/ospfv3Router -enableDrBdr]
set value2Obj [ixNet setA $ospfV2Hndle/singleValue -value True]
set value3Obj [ixNet setA $ospfV3Hndle/singleValue -value True]
ixNet commit
#ixNet setM $hPort/protocols/ospf -enableDrOrBdr True
#ixNet setM $hPort/protocols/ospfV3 -enableDrOrBdr True
#ixNet commit
set rb_interface [ ixNet getL $hPort interface ]
Deputs "rb_interface is: $rb_interface"
array set interface [ list ]
}
method config { args } {}
method set_topo { args } {}
method unset_topo { args } {}
method advertise_topo {} {}
method withdraw_topo {} {}
method flapping_topo { args } {}
method enable {} {
set tag "body OspfSession::enable [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA $handle -enabled "true"
ixNet commit
}
method disable {} {
set tag "body OspfSession::disable [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA $handle -enabled "false"
ixNet commit
}
method get_status {} {}
method get_stats {} {}
method generate_interface { args } {
set tag "body OspfSession::generate_interface [info script]"
Deputs "----- TAG: $tag -----"
Deputs "handle:$handle"
foreach int $rb_interface {
if { [ ixNet getA $int -type ] == "routed" } {
continue
Deputs "inside:$int"
}
set hInt [ ixNet add $handle interface ]
ixNet setM $hInt -interfaces $int -enabled True -connectedToDut True
ixNet commit
set hInt [ ixNet remapIds $hInt ]
set interface($int) $hInt
Deputs "hInt:$hInt"
Deputs "interface($int):$interface($int)"
}
}
}
body OspfSession::config { args } {
global errorInfo
global errNumber
set area_id "0.0.0.0"
set hello_interval 10
set if_cost 1
set network_type "native"
set options "v6bit | rbit | ebit"
set router_dead_interval 40
set intf_num 1
set tag "body OspfSession::config [info script]"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-router_id {
set router_id $value
}
-area_id {
set area_id $value
}
-hello_interval {
set hello_interval $value
}
-if_cost {
set if_cost $value
}
-network_type {
set value [string toupper $value]
set network_type $value
}
-options {
set options $value
}
-router_dead_interval -
-dead_interval {
set dead_interval $value
}
-retransmit_interval {
set retransmit_interval $value
}
-priority {
set priority $value
}
}
}
if { $handle == "" } {
reborn
}
ixNet setM $handle -enabled True
if { [ info exists router_id ] } {
Deputs "router_id:$router_id"
ixNet setA $handle -localRouterID $router_id
ixNet commit
Deputs "router_idpost:$router_id"
}
if { [ info exists area_id ] } {
set id_hex [IP2Hex $area_id]
set area_id [format %i 0x$id_hex]
set valueObj [ ixNet getA $handle -areaId]
set value [ixNet setA $valueObj/singleValue -value $area_id]
ixNet commit
}
if { [ info exists hello_interval ] } {
set valueObj [ ixNet getA $handle -helloInterval]
set value [ixNet setA $valueObj/singleValue -value $hello_interval]
ixNet commit
}
if { [ info exists if_cost ] } {
set version [GetOspfRouterHandle $handle 1]
if {$version == 2} {
set valueObj [ ixNet getA $handle -metric]
set value [ixNet setA $valueObj/singleValue -value $if_cost]
ixNet commit
} elseif {$version == 3} {
Deputs "if_cost for ipv6 is not implemented"
}
}
# v3 -interfaceType pointToPoint, -interfaceType broadcast
# v2 -networkType pointToPoint, -networkType broadcast, -networkType pointToMultipoint
if { [ info exists network_type ] } {
switch $network_type {
NATIVE {
set network_type pointtomultipoint
}
BROADCAST {
set network_type broadcast
}
P2P {
set network_type pointtopoint
}
}
# if {[ixNet getA $hPort/protocols/ospf -enabled]} {
# set attri "-networkType"
# } elseif {[ixNet getA $hPort/protocols/ospfV3 -enabled]} {
# set attri "-interfaceType"
# } else {
# error "network type setting error"
# }
# foreach int $rb_interface {
# ixNet setA $interface($int) $attri $network_type
# }
set valueObj [ ixNet getA $handle -networkType]
set value [ixNet setA $valueObj/singleValue -value $network_type]
ixNet commit
}
# v3 -routerOptions
# v2 -options
if { [ info exists options ] } {
foreach int $rb_interface {
set options [split $options |]
if {[string match *dcbit* $options]} {
set dcbit 1
} else {
set dcbit 0
}
if {[string match *rbit* $options]} {
set rbit 1
} else {
set rbit 0
}
if {[string match *nbit* $options]} {
set nbit 1
} else {
set nbit 0
}
if {[string match *mcbit* $options]} {
set mcbit 1
} else {
set mcbit 0
}
if {[string match *ebit* $options]} {
set ebit 1
} else {
set ebit 0
}
if {[string match *v6bit* $options]} {
set v6bit 1
} else {
set v6bit 0
}
set opt_val "00$dcbit$rbit$nbit$mcbit$ebit$v6bit"
set opt_val [BinToDec $opt_val]
# set opt_val [Int2Hex $opt_val]
ixNet setA $interface($int) -routerOptions $opt_val
ixNet commit
}
}
if { [ info exists dead_interval ] } {
ixNet setA [ixNet getA $handle -deadInterval]/singleValue -value $dead_interval
ixNet commit
}
# v3
# v2 -lsaRetransmitTime
if { [ info exists retransmit_interval ] } {
set ospfRtHandle [GetOspfRouterHandle $handle]
Deputs "ospfRtHandle:$ospfRtHandle"
ixNet setA [ixNet getA $ospfRtHandle -lsaRetransmitTime]/singleValue -value $retransmit_interval
ixNet commit
}
if { [ info exists priority ] } {
Deputs "priority is not implemented"
foreach int $rb_interface {
ixNet setA $interface($int) -priority $priority
}
ixNet commit
}
return [GetStandardReturnHeader]
}
body OspfSession::advertise_topo {} {
set tag "body OspfSession::advertise_topo [info script]"
Deputs "----- TAG: $tag -----"
foreach route [ ixNet getL $handle routeRange ] {
ixNet setA $route -enabled True
}
if {[info exists hNetworkRange ]} {
ixNet setA $hNetworkRange -enabled True
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::withdraw_topo {} {
set tag "body OspfSession::withdraw_topo [info script]"
Deputs "----- TAG: $tag -----"
foreach route [ ixNet getL $handle routeRange ] {
ixNet setA $route -enabled False
}
if {[info exists hNetworkRange ]} {
ixNet setA $hNetworkRange -enabled False
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::flapping_topo { args } {
set tag "body OspfSession::flapping_topo [info script]"
Deputs "----- TAG: $tag -----"
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-times {
set times $value
}
-interval {
set interval $value
}
}
}
for { set index 0 } { $index < $times } { incr index } {
foreach route [ ixNet getL $handle routeRange ] {
ixNet setA $route -enabled True
}
ixNet commit
after [ expr $interval * 1000 ]
foreach route [ ixNet getL $handle routeRange ] {
ixNet setA $route -enabled False
}
ixNet commit
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::set_topo {args} {
set tag "body OspfSession::set_topo [info script]"
Deputs "----- TAG: $tag -----"
set hRouter $handle
debug 1
set hNetworkRange [ixNet add $hRouter networkRange]
ixNet commit
set hNetworkRange [ ixNet remapIds $hNetworkRange ]
ixNet setA $hNetworkRange -enalbed True
ixNet commit
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-topo {
set topo $value
}
}
}
if { [ info exists topo ] } {
if { $topo == "" || [ $topo isa Topology ] == 0 } {
return [GetErrorReturnHeader "No valid object found...-topo $topo"]
}
set type [$topo cget -type]
set sim_rtr_num [$topo cget -sim_rtr_num]
set row_num [$topo cget -row_num]
set column_num [$topo cget -column_num]
set attach_row [$topo cget -attach_row]
set attach_column [$topo cget -attach_column]
ixNet setM $hNetworkRange \
-numRows $row_num \
-numCols $column_num \
-entryRow $attach_row \
-entryColumn $attach_column
} else {
return [GetErrorReturnHeader "Madatory parameter needed...-topo"]
}
ixNet commit
return [GetStandardReturnHeader]
}
body OspfSession::unset_topo {} {
set tag "body OspfSession::unset_topo [info script]"
Deputs "----- TAG: $tag -----"
ixNet remove $hNetworkRange
ixNet commit
}
class Ospfv2Session {
inherit OspfSession
constructor { port { hOspfSession NULL } } { chain $port $hOspfSession } {
set tag "body Ospfv2Session::ctor [info script]"
Deputs "----- TAG: $tag -----"
if { [ catch {
set hPort [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in OspfSession ctor"
}
if { $hOspfSession == "NULL" } {
set hOspfSession [GetObjNameFromString $this "NULL"]
}
Deputs "----- hOspfSession: $hOspfSession, hPort: $hPort, portObj is: $portObj, port is: $port -----"
if { $hOspfSession != "NULL" } {
set handle [GetValidHandleObj "ospfv2" $hOspfSession $hPort]
Deputs "----- ospfhandle: $handle -----"
if { $handle != "" } {
set handleName [ ixNet getA $handle -name ]
Deputs "----- ospfhandle2: $handleName -----"
}
} else {
set handleName $this
set handle ""
reborn
}
}
method reborn {} {
set tag "body Ospfv2Session::reborn [info script]"
Deputs "----- TAG: $tag -----"
chain
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
ixNet commit
set topoObj [ixNet remapIds $topoObj]
set deviceGroupObj [ixNet add $topoObj deviceGroup]
ixNet commit
set deviceGroupObj [ixNet remapIds $deviceGroupObj]
set ethObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
set ethObj [ixNet remapIds $ethObj]
set ipv4Obj [ixNet add $ethObj ipv4]
ixNet commit
set ipv4Obj [ixNet remapIds $ipv4Obj]
set ospfObj [ixNet add $ipv4Obj ospfv2]
ixNet commit
set ospfObj [ixNet remapIds $ospfObj]
ixNet commit
Deputs "----- Topo: $topoObj -----"
Deputs "----- devg: $deviceGroupObj -----"
Deputs "----- etho: $topoObj -----"
Deputs "----- ipv4Obj: $ipv4Obj -----"
Deputs "----- ospfObj: $ospfObj -----"
Deputs "----- hPort: $hPort -----"
set ospfRtHandle [ ixNet getL $deviceGroupObj ospfv2Router ]
set valueObj [ ixNet getA $ospfRtHandle -active]
set value [ixNet setA $valueObj/singleValue -value True]
ixNet commit
set handle [ ixNet remapIds $ospfObj ]
ixNet setA $handle -name $this
set ospfRtHandle [ ixNet remapIds $ospfRtHandle ]
ixNet setA $ospfRtHandle -name $this
Deputs "handleospf:$handle"
set protocol ospf
}
method config { args } {}
method get_status {} {}
method get_stats {} {}
}
body Ospfv2Session::get_status {} {
set tag "body OspfSession::get_status [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
if {[ixNet getA $hPort/protocols/ospf -enabled]} {
set view {::ixNet::OBJ-/statistics/view:"OSPF Aggregated Statistics"}
} elseif {[ixNet getA $hPort/protocols/ospfV3 -enabled]} {
set view {::ixNet::OBJ-/statistics/view:"OSPFv3 Aggregated Statistics"}
} else {
error "No ospf or ospfv3 aggregated statistics"
}
# set view {::ixNet::OBJ-/statistics/view:"OSPF Aggregated Statistics"}
set captionList [ ixNet getA $view/page -columnCaptions ]
set name_index [ lsearch -exact $captionList {Stat Name} ]
set down_index [ lsearch -exact $captionList {Down State Count} ]
set attempt_index [ lsearch -exact $captionList {Attempt State Count} ]
set init_index [ lsearch -exact $captionList {Init State Count} ]
set twoway_index [ lsearch -exact $captionList {TwoWay State Count} ]
set exstart_index [ lsearch -exact $captionList {ExStart State Count} ]
set exchange_index [ lsearch -exact $captionList {Exchange State Count} ]
set loading_index [ lsearch -exact $captionList {Loading State Count} ]
set full_index [ lsearch -exact $captionList {Full State Count} ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set portFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "port index:$name_index"
set rowPortName [ lindex $row $name_index ]
Deputs "row port name:$name_index"
set connectionInfo [ ixNet getA $hPort -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 portName ${chassis}/Card${card}/Port${port}
Deputs "filter name: $portName"
if { [ regexp $portName $rowPortName ] } {
set portFound 1
break
}
}
set status "down"
# down��attempt��init��two_ways��exstart��exchange��loading��full
if { $portFound } {
set down [ lindex $row $down_index ]
set attempt [ lindex $row $attempt_index ]
set init [ lindex $row $init_index ]
set twoway [ lindex $row $twoway_index ]
set exstart [ lindex $row $exstart_index ]
set exchange [ lindex $row $exchange_index ]
set loading [ lindex $row $loading_index ]
set full [ lindex $row $full_index ]
if { $down } {
set status "down"
}
if { $attempt } {
set status "attempt"
}
if { $init } {
set status "init"
}
if { $twoways } {
set status "two_ways"
}
if { $exstart } {
set status "exstart"
}
if { $exchange } {
set status "exchange"
}
if { $loading } {
set status "loading"
}
if { $full } {
set status "full"
}
}
set ret [ GetStandardReturnHeader ]
set ret $ret[ GetStandardReturnBody "status" $status ]
return $ret
}
body Ospfv2Session::get_stats {} {
set tag "body OspfSession::get_status [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
Deputs "root $root"
set view {::ixNet::OBJ-/statistics/view:"OSPF Aggregated Statistics"}
set captionList [ ixNet getA $view/page -columnCaptions ]
# {LSAs Acknowledged}
# {LSA Acknowledges Rx}
# {SummaryASLSA Tx}
# {SummaryASLSA Rx}
# {OpaqueLocalLSA Tx}
# {OpaqueLocalLSA Rx}
# {OpaqueAreaLSA Tx}
# {OpaqueAreaLSA Rx}
# {OpaqueDomainLSA Tx}
# {OpaqueDomainLSA Rx}
# {GraceLSA Rx}
# {HelperMode Attempted}
# {HelperMode Failed}
# {Rate Control Blocked Flood LSUpdate}
# rx_te_lsa
# tx_te_lsa
set name_index [ lsearch -exact $captionList {Stat Name} ]
set rx_ack_index [ lsearch -exact $captionList {LS Ack Rx} ]
set tx_ack_index [ lsearch -exact $captionList {LS Ack Tx} ]
set rx_dd_index [ lsearch -exact $captionList {DBD Rx} ]
set tx_dd_index [ lsearch -exact $captionList {DBD Tx} ]
set rx_hello_index [ lsearch -exact $captionList {Hellos Rx} ]
set tx_hello_index [ lsearch -exact $captionList {Hellos Tx} ]
set rx_network_lsa_index [ lsearch -exact $captionList {NetworkLSA Rx} ]
set tx_network_lsa_index [ lsearch -exact $captionList {NetworkLSA Tx} ]
set rx_nssa_lsa_index [ lsearch -exact $captionList {NSSALSA Rx} ]
set tx_nssa_lsa_index [ lsearch -exact $captionList {NSSALSA Tx} ]
set rx_request_index [ lsearch -exact $captionList {LS Request Rx} ]
set tx_request_index [ lsearch -exact $captionList {LS Request Tx} ]
set rx_router_lsa_index [ lsearch -exact $captionList {RouterLSA Rx} ]
set tx_router_lsa_index [ lsearch -exact $captionList {RouterLSA Tx} ]
set rx_summary_lsa_index [ lsearch -exact $captionList {SummaryIPLSA Rx} ]
set tx_summary_lsa_index [ lsearch -exact $captionList {SummaryIPLSA Tx} ]
set rx_as_external_lsa_index [ lsearch -exact $captionList {ExternalLSA Rx} ]
set tx_as_external_lsa_index [ lsearch -exact $captionList {ExternalLSA Tx} ]
set rx_asbr_summary_lsa_index [ lsearch -exact $captionList {LinkState Advertisement Rx} ]
set tx_asbr_summary_lsa_index [ lsearch -exact $captionList {LinkState Advertisement Tx} ]
set rx_update_index [ lsearch -exact $captionList {LS Update Rx} ]
set tx_update_index [ lsearch -exact $captionList {LS Update Tx} ]
set stats [ ixNet getA $view/page -rowValues ]
Deputs "stats:$stats"
set portFound 0
foreach row $stats {
eval {set row} $row
Deputs "row:$row"
Deputs "port index:$name_index"
set rowPortName [ lindex $row $name_index ]
Deputs "row port name:$name_index"
set connectionInfo [ ixNet getA $hPort -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 portName ${chassis}/Card${card}/Port${port}
Deputs "filter name: $portName"
if { [ regexp $portName $rowPortName ] } {
set portFound 1
break
}
}
set ret "Status : true\nLog : \n"
if { $portFound } {
set statsItem "rx_ack"
set statsVal [ lindex $row $rx_ack_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_ack"
set statsVal [ lindex $row $tx_ack_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_dd"
set statsVal [ lindex $row $rx_dd_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_dd"
set statsVal [ lindex $row $tx_dd_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_hello"
set statsVal [ lindex $row $rx_hello_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_hello"
set statsVal [ lindex $row $tx_hello_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_network_lsa"
set statsVal [ lindex $row $rx_network_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_network_lsa"
set statsVal [ lindex $row $tx_network_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_nssa_lsa"
set statsVal [ lindex $row $rx_nssa_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_nssa_lsa"
set statsVal [ lindex $row $tx_nssa_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_request"
set statsVal [ lindex $row $rx_request_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_request"
set statsVal [ lindex $row $tx_request_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_router_lsa"
set statsVal [ lindex $row $rx_router_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_router_lsa"
set statsVal [ lindex $row $tx_router_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_summary_lsa"
set statsVal [ lindex $row $rx_summary_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_summary_lsa"
set statsVal [ lindex $row $tx_summary_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_as_external_lsa"
set statsVal [ lindex $row $rx_as_external_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_as_external_lsa"
set statsVal [ lindex $row $tx_as_external_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_asbr_summary_lsa"
set statsVal [ lindex $row $rx_asbr_summary_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_asbr_summary_lsa"
set statsVal [ lindex $row $tx_asbr_summary_lsa_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_update"
set statsVal [ lindex $row $rx_update_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_update"
set statsVal [ lindex $row $tx_update_index ]
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "rx_te_lsa"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
set statsItem "tx_te_lsa"
set statsVal "NA"
Deputs "stats val:$statsVal"
set ret $ret[ GetStandardReturnBody $statsItem $statsVal ]
}
Deputs "ret:$ret"
return $ret
}
body Ospfv2Session::config { args } {
global errorInfo
global errNumber
set ipv4_prefix_len 24
set ipv4_gw 1.1.1.1
set loopback_ipv4_gw 1.1.1.1
set ipv4_addr_step 0.0.0.1
set outer_vlan_step 1
set inner_vlan_step 1
set outer_vlan_num 1
set inner_vlan_num 1
set outer_vlan_priority 0
set inner_vlan_priority 0
set count 1
set enabled True
set tag "body Ospfv2Session::config [info script]"
Deputs "----- TAG: $tag -----"
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-ipv4_addr {
set ipv4_addr $value
}
-ipv4_prefix_len {
if { [ string is integer $value ] && $value <= 32 } {
set ipv4_prefix_len $value
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-ipv4_gw {
set ipv4_gw $value
}
-outer_vlan_id {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set outer_vlan_id $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_step {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 4096 ) } {
set outer_vlan_step $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_num {
if { [ string is integer $value ] && ( $value >= 0 ) } {
set outer_vlan_num $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-outer_vlan_priority {
if { [ string is integer $value ] && ( $value >= 0 ) && ( $value < 8 ) } {
set outer_vlan_priority $value
set flagOuterVlan 1
} else {
error "$errNumber(1) key:$key value:$value"
}
}
-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_cfi {
set outer_vlan_cfi $value
}
-inner_vlan_cfi {
set inner_vlan_cfi $value
}
-loopback_ipv4_addr {
set loopback_ipv4_addr $value
}
-loopback_ipv4_gw {
set loopback_ipv4_gw $value
}
}
}
if { $handle == "" } {
Deputs "beforereborn:$handle"
reborn
Deputs "afterreborn:$handle"
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupObj [ixNet getL $topoObj deviceGroup]
set ethernetObj [ixNet getL $deviceGroupObj ethernet]
if { [ info exists ipv4_addr ] } {
#Deputs "rb_interfacewas:$rb_interface"
# foreach rb $rb_interface {
# Deputs "rb:$rb"
# if { [ ixNet getA $rb -type ] == "routed" } {
# continue
# }
# ixNet setM $rb/ipv4 \
# -ip $ipv4_addr \
# -gateway $ipv4_gw \
# -maskWidth $ipv4_prefix_len
# ixNet commit
# }
Deputs "ipv4: [ixNet getL $ethernetObj ipv4]"
set ipv4Obj [ixNet getL $ethernetObj ipv4]
ixNet setA [ixNet getA $ipv4Obj -address]/singleValue -value $ipv4_addr
ixNet setA [ixNet getA $ipv4Obj -gatewayIp]/singleValue -value $ipv4_gw
ixNet setA [ixNet getA $ipv4Obj -prefix]/singleValue -value $ipv4_prefix_len
ixNet commit
generate_interface
}
if {[ info exists outer_vlan_id ]} {
for { set index 0 } { $index < $count } { incr index } {
if { [ info exists outer_vlan_id ] } {
set vlanId $outer_vlan_id
ixNet setA $ethernetObj -vlanCount 1
ixNet setA [ixNet getA $ethernetObj -enableVlans]/singleValue -value True
set oVlanObj [lindex [ixNet getL ::ixNet::OBJ-/topology:1/deviceGroup:1/ethernet:1 vlan] 0]
ixNet setA [ixNet getA $oVlanObj -vlanId]/singleValue -value $vlanId
ixNet setA [ixNet getA $oVlanObj -priority]/singleValue -value $outer_vlan_priority
ixNet commit
incr outer_vlan_id $outer_vlan_step
}
if { [ info exists inner_vlan_id ] } {
set vlanId $inner_vlan_id
set innerPri $inner_vlan_priority
#set vlanId1 [ ixNet getA $int/vlan -vlanId ]
#set vlanId "${vlanId1},${vlanId}"
#set outerPri [ ixNet getA $int/vlan -vlanPriority]
#set Pri "${outerPri},${innerPri}"
ixNet setA $ethernetObj -vlanCount 2
ixNet setA [ixNet getA $ethernetObj -enableVlans]/singleValue -value True
ixNet commit
set iVlanObj [lindex [ixNet getL ::ixNet::OBJ-/topology:1/deviceGroup:1/ethernet:1 vlan] 1]
Deputs "iVlanObj: $iVlanObj"
ixNet setA [ixNet getA $iVlanObj -vlanId]/singleValue -value $vlanId
ixNet setA [ixNet getA $iVlanObj -priority]/singleValue -value $innerPri
ixNet commit
# ixNet setM $int/vlan \
# -count 2 \
# -vlanEnable True \
# -vlanId $vlanId \
# -vlanPriority $Pri
# ixNet commit
incr inner_vlan_id $inner_vlan_step
}
if { [ info exists enabled ] } {
ixNet setA [ixNet getA $ethernetObj -enableVlans]/singleValue -value True