forked from keysightgems/Huawei_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIxia_NetNgpfBgp.tcl
More file actions
1955 lines (1805 loc) · 77.8 KB
/
Ixia_NetNgpfBgp.tcl
File metadata and controls
1955 lines (1805 loc) · 77.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 2010-2011, Inc.
# Release Version 1.3
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# Version 1.1.4.34
# 2. Add Vpn for BGP Vpn
# Version 1.2.4.53
# 3. Add capability in reborn
# Version 1.3.4.54
# 4. Add learned filter in reborn
class BgpSession {
inherit RouterEmulationObject
public variable ip_version
public variable ipv4_addr
public variable bgpHandle
public variable deviceHandle
public variable ethHandle
public variable ipv4Handle
public variable ipv6Handle
public variable version
#public variable networkhandle
constructor { port { hBgpSession NULL } } {
set tag "body BgpSession::ctor [info script]"
Deputs "----- TAG: $tag -----"
set portObj [ GetObject $port ]
set handle ""
set bgphandle ""
set devicehandle ""
set ethhandle ""
set ipv4handle ""
set ipv6handle ""
#set networkhandle ""
#set ip_version $version
set routeBlock(obj) [list]
set portObj [ GetObject $port ]
if { [ catch {
set hPort [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in BgpSession ctor"
}
if { $hBgpSession == "NULL" } {
set hBgpSession [GetObjNameFromString $this "NULL"]
}
Deputs "----- hBgpSession: $hBgpSession, hPort: $hPort -----"
if { $hBgpSession != "NULL" } {
set handle [GetValidNgpfHandleObj "bgp" $hBgpSession $hPort]
Deputs "----- handle: $handle -----"
if { $handle != "" } {
set handleName [ ixNet getA $handle -name ]
}
}
if { $handle == "" } {
set handleName $this
reborn
}
}
method reborn { {version ipv4} } { }
method config { args } {}
method enable {} {}
method disable {} {}
method get_status {} {}
method get_stats {} {}
method set_route { args } {}
method advertise_route { args } {}
method withdraw_route { args } {}
method wait_session_up { args } {}
}
class SimRoute {
inherit RouterEmulationObject
public variable bgpObj
public variable hBgp
public variable ipv4_addr
public variable hRouteBlock
public variable networkGroupObj
# public variable bgpIpRouteObj
public variable bgpSimRouteObj
public variable bgpV6SimRouteObj
constructor { bgpobj { hRouteBlock NULL } } {
set tag "body SimRoute::ctor [info script]"
Deputs "----- TAG: $tag -----"
set bgpObj [ GetObject $bgpobj ]
set hBgp [ $bgpObj cget -bgpHandle ]
set portObj [ $bgpObj cget -portObj]
set hPort [ $bgpObj cget -hPort ]
set handle ""
#set ip_version $version
set routeBlock(obj) [list]
if { $hRouteBlock == "NULL" } {
set hRouteBlock [GetObjNameFromString $this "NULL"]
}
Deputs "----- hRouteBlock: $hRouteBlock, $bgpobj: $hBgp -----"
set deviceGroupObj [$bgpObj cget -deviceHandle]
if { $hRouteBlock != "NULL" } {
set handle [GetValidNgpfHandleObj "simroute" $hRouteBlock $deviceGroupObj]
Deputs "----- handle: $handle -----"
if { $handle != "" } {
set handleName [ ixNet getA $handle -name ]
}
}
}
method config { args } {}
method enable {} {}
method advertise_route { } {
set tag "body SimRoute::advertise_route [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA [ixNet getA $networkGroupObj -enabled]/singleValue -value True
ixNet commit
}
method withdraw_route { } {
set tag "body SimRoute::withdraw_route [info script]"
Deputs "----- TAG: $tag -----"
ixNet setA [ixNet getA $networkGroupObj -enabled]/singleValue -value False
ixNet commit
}
method flapping_route { args } {
set tag "body SimRoute::flapping_route [info script]"
Deputs "----- TAG: $tag -----"
set interval 5
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-times {
set times $value
}
-interval {
set interval $value
}
}
}
if {$bgpSimRouteObj != ""} {
ixNet setA [ixNet getA $bgpSimRouteObj -enableFlapping]/singleValue -value True
}
if {$bgpV6SimRouteObj != ""} {
ixNet setA [ixNet getA $bgpV6SimRouteObj -enableFlapping]/singleValue -value True
}
if {[info exists interval]} {
if {$bgpSimRouteObj != ""} {
ixNet setA [ixNet getA $bgpSimRouteObj -downtime]/singleValue -value $interval
ixNet setA [ixNet getA $bgpSimRouteObj -uptime]/singleValue -value $interval
}
if {$bgpV6SimRouteObj != ""} {
ixNet setA [ixNet getA $bgpV6SimRouteObj -downtime]/singleValue -value $interval
ixNet setA [ixNet getA $bgpV6SimRouteObj -uptime]/singleValue -value $interval
}
}
ixNet commit
}
}
body BgpSession::reborn { {version ipv4} } {
global errNumber
global bgpObj
set tag "body BgpSession::reborn [info script]"
Deputs "----- TAG: $tag -----"
set ip_version $version
if { [ catch {
set hPort [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in BgpSession ctor"
}
#-- add interface and bgp protocol
set bgpObj ""
set topoObjList [ixNet getL [ixNet getRoot] topology]
Deputs "topoObjList: $topoObjList"
set vportList [ixNet getL [ixNet getRoot] vport]
set vport [ lindex $vportList end ]
if {[llength $topoObjList] != [llength $vportList]} {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj != $vport && $vport == $hPort} {
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
set deviceGroupObj [ixNet add $topoObj deviceGroup]
set ethernetObj [ixNet add $deviceGroupObj ethernet]
ixNet commit
if { $ip_version == "ipv4" } {
set ipv4Obj [ixNet add $ethernetObj ipv4]
ixNet commit
}
if { $ip_version == "ipv6" } {
set ipv6Obj [ixNet add $ethernetObj ipv6]
ixNet commit
}
}
break
}
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
if { [ llength $topoObjList ] == 0 } {
set topoObj [ixNet add [ixNet getRoot] topology -vports $hPort]
set deviceGroupObj [ixNet add $topoObj deviceGroup]
set ethernetObj [ixNet add $deviceGroupObj ethernet]
if { $ip_version == "ipv4" } {
set ipv4Obj [ixNet add $ethernetObj ipv4]
set bgpObj [ixNet add $ipv4Obj bgpIpv4Peer]
ixNet commit
}
if { $ip_version == "ipv6" } {
set ipv6Obj [ixNet add $ethernetObj ipv6]
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
ixNet setA [ixNet getA $bgpObj -dutIp]/singleValue -value "0:0:0:0:0:0:0:0"
ixNet commit
}
set bgpObj [ ixNet remapIds $bgpObj ]
ixNet setA $bgpObj -name $this
ixNet commit
array set routeBlock [ list ]
} else {
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupList [ixNet getL $topoObj deviceGroup]
foreach deviceGroupObj $deviceGroupList {
set ethernetList [ixNet getL $deviceGroupObj ethernet]
foreach ethernetObj $ethernetList {
set ipv4Obj [ixNet getL $ethernetObj ipv4]
if { $ip_version == "ipv4" } {
if {[ info exists ipv4_addr ]} {
set ipaddr [ixNet getA [ixNet getA $ipv4Obj -address]/singleValue -value]
if {$ipaddr == $ipv4_addr} {
set ethernetObj $ethernetObj
set bgpObj [ixNet getL $ipv4Obj bgpIpv4Peer]
if {[llength $bgpObj] != 0} {
set bgpObj [ ixNet remapIds $bgpObj ]
} else {
set bgpObj [ixNet add $ipv4Obj bgpIpv4Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
break
}
} else {
if { [llength $ipv4Obj] == 0 } {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if { [llength $ipv6Obj] != 0 } {
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
}
} else {
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv4Obj bgpIpv4Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
}
}
} elseif { $ip_version == "ipv6" } {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if { [llength $ipv6Obj] == 0 } {
set ipv6Obj [ixNet add $ethernetObj ipv6]
ixNet commit
set bgpObj [ixNet getL $ipv6Obj bgpIpv6Peer]
if {[llength $bgpObj] != 0} {
set bgpObj [ ixNet remapIds $bgpObj ]
} else {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
} else {
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
}
}
}
}
}
}
}
#-- set capability
foreach bgp $bgpObj {
set filterList { -filterIpV4Mpls -filterIpV4MplsVpn -filterIpV4Multicast -filterIpV4Unicast -filterIpV6Mpls -filterIpV6MplsVpn -filterIpV6Multicast -filterIpV6Unicast \
-capabilityIpV4Mpls -capabilityIpV4MplsVpn -capabilityIpV4Multicast -capabilityIpV4Unicast -capabilityIpV6Mpls -capabilityIpV6MplsVpn -capabilityIpV6Multicast \
-capabilityIpV6Unicast }
foreach filter $filterList {
ixNet setAttr [ixNet getAttr $bgp $filter]/singleValue -value True
}
ixNet commit
}
$this configure -bgpHandle $bgpObj
$this configure -deviceHandle $deviceGroupObj
$this configure -ethHandle $ethernetObj
$this configure -version $ip_version
if { $ip_version == "ipv4" } {
$this configure -ipv4Handle $ipv4Obj
} else {
$this configure -ipv6Handle $ipv6Obj
}
set protocol bgp
}
body BgpSession::config { args } {
global errorInfo
global errNumber
if { [ catch {
set handle [ $portObj cget -handle ]
} ] } {
error "$errNumber(1) Port Object in BgpSession ctor"
}
set tag "body BgpSession::config [info script]"
Deputs "----- TAG: $tag -----"
set loopback_ipv4_gw 1.1.1.1
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-afi {
set afi $value
}
-sub_afi {
set sub_afi $value
}
-as {
set as $value
}
-dut_ip {
set dut_ip $value
}
-dut_as {
set dut_as $value
}
-enable_pack_routes {
set enable_pack_routes $value
}
-max_routes_per_update {
set max_routes_per_update $value
}
-enable_refresh_routes {
set enable_refresh_routes $value
}
-hold_time_interval {
set hold_time_interval $value
}
-ip_version {
set ip_version $value
}
-ipv6_addr {
set ipv6_addr $value
}
-address -
-ip -
-ipv4_addr {
set ipv4_addr $value
set ip $value
}
-gateway -
-ipv4_gw {
set ipv4_gw $value
set gateway $value
}
-mac {
set mac $value
}
-type {
set type $value
}
-bgp_id -
-router_id {
set bgp_id $value
}
-loopback_ipv4_addr {
set loopback_ipv4_addr $value
}
-loopback_ipv4_gw {
set loopback_ipv4_gw $value
}
-enable_flap {
set enable_flap $value
}
-flap_down_time {
set flap_down_time $value
}
-flap_up_time {
set flap_up_time $value
}
}
}
if { $handle == "" } {
reborn $ip_version
}
set topoObjList [ixNet getL [ixNet getRoot] topology]
foreach topoObj $topoObjList {
set vportObj [ixNet getA $topoObj -vports]
if {$vportObj == $hPort} {
set deviceGroupObjList [ixNet getL $topoObj deviceGroup]
foreach deviceGroupObj $deviceGroupObjList {
set ethernetObj [ixNet getL $deviceGroupObj ethernet]
if { [ info exists ipv4_addr ] } {
if { $ip_version == "ipv4" } {
Deputs "ipv4: [ixNet getL $ethernetObj ipv4]"
set ipv4Obj [ixNet getL $ethernetObj ipv4]
ixNet setA [ixNet getA $ipv4Obj -address]/singleValue -value $ipv4_addr
ixNet commit
}
}
if { [ info exists ipv6_addr ] } {
if { $ip_version == "ipv6" } {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if { [llength $ipv6Obj] != 0 } {
ixNet setA [ixNet getA $ipv6Obj -address]/singleValue -value $ipv6_addr
ixNet commit
} else {
set ipv6Obj [ixNet add $ethernetObj ipv6]
ixNet commit
ixNet setA [ixNet getA $ipv6Obj -address]/singleValue -value $ipv6_addr
ixNet commit
}
}
}
if { [ info exists ipv4_gw ] } {
if { $ip_version == "ipv4" } {
set ipv4Obj [ixNet getL $ethernetObj ipv4]
ixNet setA [ixNet getA $ipv4Obj -gatewayIp]/singleValue -value $ipv4_gw
ixNet commit
}
}
if { [ info exists gateway ] } {
if { $ip_version == "ipv6" } {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
ixNet setA [ixNet getA $ipv6Obj -gatewayIp]/singleValue -value $gateway
ixNet commit
}
}
if { [ info exists mac ] } {
ixNet setA [ixNet getA $ethernetObj -mac]/singleValue -value $mac
ixNet commit
}
if { [ info exists loopback_ipv4_addr ] } {
Deputs "not implemented parameter: loopback_ipv4_addr"
}
if { $ip_version == "ipv4" } {
set ipv4Obj [ixNet getL $ethernetObj ipv4]
if {[llength $ipv4Obj] == 0} {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if {[llength $ipv6Obj] != 0} {
set bgpObj [ixNet getList $ipv6Obj bgpIpv6Peer]
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
} else {
set bgpObj [ixNet getL $ipv6Obj bgpIpv6Peer]
}
}
} else {
set bgpObj [ixNet getList $ipv4Obj bgpIpv4Peer]
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv4Obj bgpIpv4Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
} else {
set bgpObj [ixNet getL $ipv4Obj bgpIpv4Peer]
}
}
} else {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
if { [llength $ipv6Obj] != 0 } {
set bgpObj [ixNet getList $ipv6Obj bgpIpv6Peer]
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
} else {
set bgpObj [ixNet getL $ipv6Obj bgpIpv6Peer]
}
} else {
set ipv6Obj [ixNet add $ethernetObj ipv6]
ixNet commit
set bgpObj [ixNet getList $ipv6Obj bgpIpv6Peer]
if { [llength $bgpObj] == 0 } {
set bgpObj [ixNet add $ipv6Obj bgpIpv6Peer]
ixNet commit
set bgpObj [ ixNet remapIds $bgpObj ]
}
}
}
if { [ info exists type ] } {
ixNet setA [ixNet getA $bgpObj -type]/singleValue -value $type
}
if { [ info exists afi ] } {
Deputs "not implemented parameter: afi"
}
if { [ info exists sub_afi ] } {
Deputs "not implemented parameter: safi"
}
if { [ info exists as ] } {
ixNet setA [ixNet getA $bgpObj -localAs2Bytes]/singleValue -value $as
ixNet commit
}
if { [ info exists dut_ip ] } {
Deputs "dut_ip:$dut_ip"
ixNet setA [ixNet getA $bgpObj -dutIp]/singleValue -value $dut_ip
ixNet commit
}
if { [ info exists dut_as ] } {
Deputs "not implemented parameter: dut_as"
}
if { [ info exists enable_pack_routes ] } {
Deputs "not implemented parameter: enable_pack_routes"
}
if { [ info exists Max_routes_per_update ] } {
Deputs "not implemented parameter: Max_routes_per_update"
}
if { [ info exists enable_refresh_routes ] } {
Deputs "not implemented parameter: enable_refresh_routes"
}
if { [ info exists hold_time_interval ] } {
Deputs "not implemented parameter: hold_time_interval"
}
if { [ info exists bgp_id ] } {
set routeDataObj [ixNet getL $deviceGroupObj routerData]
ixNet setA [ixNet getA $routeDataObj -routerId]/singleValue -value $bgp_id
ixNet setA [ixNet getA $bgpObj -bgpId]/singleValue -value $bgp_id
ixNet commit
}
if { [ info exists ipv6_addr ] } {
set ipv6Obj [ixNet getL $ethernetObj ipv6]
ixNet setA [ixNet getA $ipv6Obj -address]/singleValue -value $ipv6_addr
ixNet commit
}
if { [ info exists enable_flap ] } {
ixNet setA [ixNet getA $bgpObj -flap]/singleValue -value $enable_flap
}
if { [ info exists flap_down_time ] } {
ixNet setA [ixNet getA $bgpObj -downtimeInSec]/singleValue -value $flap_down_time
}
if { [ info exists flap_up_time ] } {
ixNet setA [ixNet getA $bgpObj -uptimeInSec]/singleValue -value $flap_up_time
}
ixNet commit
}
}
}
return [GetStandardReturnHeader]
}
body BgpSession::set_route { args } {
global errorInfo
global errNumber
set tag "body BgpSession::set_route [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-route_block {
set route_block $value
}
}
}
set deviceGroup [$this cget -deviceHandle]
puts "******************************** deviceGroup obj is :: $deviceGroup"
if { [ info exists route_block ] } {
foreach rb $route_block {
set num [ $rb cget -num ]
set step [ $rb cget -step ]
set prefix_len [ $rb cget -prefix_len ]
set start [ $rb cget -start ]
set type [ $rb cget -type ]
set origin [ $rb cget -origin ]
set nexthop [ $rb cget -nexthop ]
set med [ $rb cget -med ]
set local_pref [ $rb cget -local_pref ]
set cluster_list [ $rb cget -cluster_list ]
set flag_atomic_agg [ $rb cget -flag_atomic_agg ]
set agg_as [ $rb cget -agg_as ]
set agg_ip [ $rb cget -agg_ip ]
set originator_id [ $rb cget -originator_id ]
set communities [ $rb cget -communities ]
set flag_label [ $rb cget -flag_label ]
set label_mode [ $rb cget -label_mode ]
set user_label [ $rb cget -user_label ]
set enable_as_path [ $rb cget -enable_as_path ]
set as_path_type [ $rb cget -as_path_type ]
set as_path [ $rb cget -as_path ]
Deputs "num:$num, step:$step, prefix_len:$prefix_len, start:$start, type:$type"
Deputs "deviceGroup:$deviceGroup"
set networkGroupObj [ixNet add $deviceGroup "networkGroup"]
ixNet commit
set networkGroupObj [ ixNet remapIds $networkGroupObj ]
Deputs "networkGroupObj:$networkGroupObj"
set routeBlock($rb) $networkGroupObj
lappend routeBlock(obj) $rb
Deputs "routeBlock(obj):$routeBlock(obj)"
if { $num != "" } {
ixNet setA $networkGroupObj -multiplier $num
ixNet commit
}
if { $start != "" } {
if {$type == "ipv4"} {
set ipPoolObj [ixNet add $networkGroupObj "ipv4PrefixPools"]
ixNet setM $ipPoolObj -addrStepSupported true -name "Basic\ IPv4\ Addresses\ 1"
ixNet commit
}
if {$type == "ipv6"} {
set ipPoolObj [ixNet add $networkGroupObj "ipv6PrefixPools"]
ixNet setM $ipPoolObj -addrStepSupported true -name "Basic\ IPv6\ Addresses\ 1"
ixNet commit
}
ixNet setM [ixNet getA $ipPoolObj -networkAddress]/counter -start $start -direction increment
ixNet commit
}
if { $prefix_len != "" } {
if {$type == "ipv4"} {
set pLen 24
if {$prefix_len == "255.0.0.0"} {
set pLen 8
} elseif {$prefix_len == "255.255.0.0"} {
set pLen 16
} elseif {$prefix_len == "255.255.255.0"} {
set pLen 24
} else {
set pLen 32
}
} else {
set pLen $prefix_len
}
ixNet setA [ixNet getA $ipPoolObj -prefixLength]/singleValue -value $pLen
ixNet commit
}
if { $step != "" } {
if {$type == "ipv4"} {
if {$pLen == 8} {
set stepvalue [string replace "0.0.0.0" 0 0 $step]
} elseif {$pLen == 16} {
set stepvalue [string replace "0.0.0.0" 2 2 $step]
} elseif {$pLen == 24} {
set stepvalue [string replace "0.0.0.0" 4 4 $step]
} else {
set stepvalue [string replace "0.0.0.0" 6 6 $step]
}
} else {
if {$pLen == 16} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 0 0 $step]
} elseif {$pLen == 32} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 2 2 $step]
} elseif {$pLen == 48} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 4 4 $step]
} elseif {$pLen == 64} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 6 6 $step]
} elseif {$pLen == 80} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 8 8 $step]
} elseif {$pLen == 96} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 10 10 $step]
} elseif {$pLen == 112} {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 12 12 $step]
} else {
set stepvalue [string replace "0:0:0:0:0:0:0:0" 14 14 $step]
}
}
ixNet setM [ixNet getA $ipPoolObj -networkAddress]/counter -step $stepvalue
ixNet commit
}
set bgpIpRouteObj ""
set bgpV6IpRouteObj ""
if {[llength [ixNet getL $ipPoolObj bgpV6IPRouteProperty]] != 0} {
set bgpV6IpRouteObj [ixNet getL $ipPoolObj bgpV6IPRouteProperty]
}
if {[llength [ixNet getL $ipPoolObj bgpIPRouteProperty]] != 0} {
set bgpIpRouteObj [ixNet getL $ipPoolObj bgpIPRouteProperty]
}
if { $origin != "" } {
#origin are igp/egp/incomplete
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableOrigin]/singleValue -value True
ixNet setA [ixNet getA $bgpIpRouteObj -origin]/singleValue -value $origin
}
if { $bgpV6IpRouteObj != ""} {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableOrigin]/singleValue -value True
ixNet setA [ixNet getA $bgpV6IpRouteObj -origin]/singleValue -value $origin
}
ixNet commit
}
if { $nexthop != "" } {
#nexthop is ipv4/ipv6 ip
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableNextHop]/singleValue -value True
ixNet setA [ixNet getA $bgpIpRouteObj -nextHopType]/singleValue -value manual
ixNet setA [ixNet getA $bgpIpRouteObj -nextHopIPType]/singleValue -value $type
if { $type == "ipv4" } {
ixNet setA [ixNet getA $bgpIpRouteObj -ipv4NextHop]/singleValue -value $nexthop
} else {
ixNet setA [ixNet getA $bgpIpRouteObj -ipv6NextHop]/singleValue -value $nexthop
}
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableNextHop]/singleValue -value True
ixNet setA [ixNet getA $bgpV6IpRouteObj -nextHopType]/singleValue -value manual
ixNet setA [ixNet getA $bgpV6IpRouteObj -nextHopIPType]/singleValue -value $type
if { $type == "ipv4" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -ipv4NextHop]/singleValue -value $nexthop
} else {
ixNet setA [ixNet getA $bgpV6IpRouteObj -ipv6NextHop]/singleValue -value $nexthop
}
}
ixNet commit
}
if { $med != "" } {
#med is integer value 10
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableMultiExitDiscriminator]/singleValue -value True
ixNet setA [ixNet getA $bgpIpRouteObj -multiExitDiscriminator]/singleValue -value $med
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableMultiExitDiscriminator]/singleValue -value True
ixNet setA [ixNet getA $bgpV6IpRouteObj -multiExitDiscriminator]/singleValue -value $med
}
ixNet commit
}
if {[info exists enable_as_path ]} {
#Valid enum values are 0=dontincludelocalas 1=includelocalasasasseq 2=includelocalasasasset 3=includelocalasasasseqconfederation 4=includelocalasasassetconfederation 5=prependlocalastofirstsegment
if {$bgpIpRouteObj != ""} {
if { $enable_as_path == "true" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableAsPathSegments]/singleValue -value true
ixNet setA [ixNet getA $bgpIpRouteObj -asSetMode]/singleValue -value "dontincludelocalas"
}
}
if {$bgpV6IpRouteObj != ""} {
if { $enable_as_path == "true" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableAsPathSegments]/singleValue -value true
ixNet setA [ixNet getA $bgpV6IpRouteObj -asSetMode]/singleValue -value "dontincludelocalas"
}
}
ixNet commit
}
if { $as_path != "" } {
#values 1=asset 2=asseq 4=assetconfederation 3=asseqconfederation
#set aspathCmd ""
#set astype [string tolower $as_path_type ]
#switch $astype {
# asset { set as_type "asSet"}
# assequence { set as_type "asSequence"}
# asconfedsequence { set as_type "asConfedSequence"}
# asconfedset { set as_type "asConfedSet"}
#}
#lappend aspathCmd [list true $as_type $as_path]
if { $bgpIpRouteObj != "" } {
set bgpAsPathObj [ixNet getL $bgpIpRouteObj bgpAsPathSegmentList]
ixNet setA [ixNet getA $bgpAsPathObj -segmentType]/singleValue -value $as_path
}
if { $bgpV6IpRouteObj != "" } {
set bgpAsPathObj [ixNet getL $bgpV6IpRouteObj bgpAsPathSegmentList]
ixNet setA [ixNet getA $bgpAsPathObj -segmentType]/singleValue -value $as_path
}
}
if { $local_pref != "" } {
#local_pref int value
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableLocalPreference]/singleValue -value True
ixNet setA [ixNet getA $bgpIpRouteObj -localPreference]/singleValue -value $local_pref
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableLocalPreference]/singleValue -value True
ixNet setA [ixNet getA $bgpV6IpRouteObj -localPreference]/singleValue -value $local_pref
}
ixNet commit
}
if { $cluster_list != "" } {
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableCluster]/singleValue -value True
set clusterNum 1
foreach clusterElement $cluster_list {
if { [IsIPv4Address $clusterElement] } {
set clusterNum [llength $cluster_list]
break
}
}
ixNet setA $bgpIpRouteObj -noOfClusters $clusterNum
ixNet commit
set clusterObjList [ixNet getL $bgpIpRouteObj bgpClusterIdList]
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableCluster]/singleValue -value True
set clusterNum 1
foreach clusterElement $cluster_list {
if { [IsIPv4Address $clusterElement] } {
set clusterNum [llength $cluster_list]
break
}
}
ixNet setA $bgpV6IpRouteObj -noOfClusters $clusterNum
ixNet commit
set clusterObjList [ixNet getL $bgpV6IpRouteObj bgpClusterIdList]
}
foreach cluster $cluster_list clusterObj $clusterObjList {
ixNet setA [ixNet getA $clusterObj -clusterId]/singleValue -value $cluster
}
}
if { $flag_atomic_agg != "" } {
# agg_as int value/agg_ip ipv4 ip
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableAggregatorId]/singleValue -value True
if { $agg_as != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -aggregatorAs]/singleValue -value $agg_as
}
if { $agg_ip != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -aggregatorId]/singleValue -value $agg_ip
}
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableAggregatorId]/singleValue -value True
if { $agg_as != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -aggregatorAs]/singleValue -value $agg_as
}
if { $agg_ip != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -aggregatorId]/singleValue -value $agg_ip
}
}
}
if { $originator_id != "" } {
#$originator_id ipv4 ip
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableOriginatorId]/singleValue -value True
ixNet setA [ixNet getA $bgpIpRouteObj -originatorId]/singleValue -value $originator_id
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableOriginatorId]/singleValue -value True
ixNet setA [ixNet getA $bgpV6IpRouteObj -originatorId]/singleValue -value $originator_id
}
ixNet commit
}
if { $communities != "" } {
#$communities hex value
if { $bgpIpRouteObj != "" } {
ixNet setA [ixNet getA $bgpIpRouteObj -enableCommunity]/singleValue -value True
set hexcommunity ""
foreach element [split $communities : ] {
set hexcommunity $hexcommunity[Int2Hex $element 4]
}
#set communities [Hex2Int $hexcommunity]
ixNet setA $bgpIpRouteObj -noOfCommunities $communities
}
if { $bgpV6IpRouteObj != "" } {
ixNet setA [ixNet getA $bgpV6IpRouteObj -enableCommunity]/singleValue -value True
set hexcommunity ""
foreach element [split $communities : ] {
set hexcommunity $hexcommunity[Int2Hex $element 4]
}
#set communities [Hex2Int $hexcommunity]
ixNet setA $bgpV6IpRouteObj -noOfCommunities $communities
}
}
ixNet commit
$rb configure -handle $networkGroupObj
$rb configure -portObj $portObj
$rb configure -hPort $hPort
$rb configure -protocol "bgp"
#$rb configure -networkhandle $networkGroupObj
$rb enable
}
}
return [GetStandardReturnHeader]
}
body BgpSession::advertise_route { args } {
global errorInfo
global errNumber
global LoadConfigMode
set tag "body BgpSession::advertise_route [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-route_block {
set route_block $value
}
}
}
#Deputs "advertise_route values of route_block is ::$route_block"
if { [ info exists route_block ] } {
set networkGroupObj $routeBlock($route_block)
ixNet setA [ixNet getA $networkGroupObj -enabled]/singleValue -value True
ixNet commit
} else {
if { $LoadConfigMode } {
set devicehandle [$this cget -deviceHandle]
set routeRangeList [ixNet getL $devicehandle networkGroup]
if { $routeRangeList != "" } {
foreach rRangeObj $routeRangeList {
ixNet setA [ixNet getA $rRangeObj -enabled]/singleValue -value True
}
ixNet commit
}
## Checking for Ipv4 pool
set vpnRouteRangeList ""
if {$routeRangeList != "" } {
foreach routeRangeObj $routeRangeList {
set ipv4PoolList [ixNet getL $routeRangeObj "ipv4PrefixPools"]
foreach ipv4PoolObj $ipv4PoolList {
set bgpL3VpnObj [ixNet getL $ipv4PoolObj "bgpL3VpnRouteProperty"]
set bgpV6L3VpnObj [ixNet getL $ipv4PoolObj "bgpV6L3VpnRouteProperty"]
if {$bgpL3VpnObj != "" || $bgpV6L3VpnObj != ""} {
lappend vpnRouteRangeList $routeRangeObj
}
}
set ipv6PoolList [ixNet getL $routeRangeObj "ipv6PrefixPools"]
foreach ipv6PoolObj $ipv6PoolList {
set bgpV6L3VpnObj [ixNet getL $ipv6PoolObj "bgpV6L3VpnRouteProperty"]
set bgpL3VpnObj [ixNet getL $ipv6PoolObj "bgpL3VpnRouteProperty"]
if {$bgpV6L3VpnObj != "" || $bgpL3VpnObj != ""} {
lappend vpnRouteRangeList $routeRangeObj
}
}
}
}
if { $vpnRouteRangeList != "" } {
foreach vpnRRange $vpnRouteRangeList {
ixNet setA $vpnRRange -enabled True
}
}
ixNet commit
} else {
foreach hRouteBlock $routeBlock(obj) {
Deputs "hRouteBlock : $hRouteBlock"
ixNet setA [ixNet getA $hRouteBlock -enabled]/singleValue -value True
}
}
}
ixNet commit
return [GetStandardReturnHeader]
}
body BgpSession::withdraw_route { args } {
global errorInfo
global errNumber
global LoadConfigMode
set tag "body BgpSession::config [info script]"
Deputs "----- TAG: $tag -----"
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {