-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIxia_NetNgpfDeviceGroup.tcl
More file actions
911 lines (842 loc) · 20.5 KB
/
Ixia_NetNgpfDeviceGroup.tcl
File metadata and controls
911 lines (842 loc) · 20.5 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
# Copyright (c) Ixia technologies 2010-2011, Inc.
# Release Version 1.5
#===============================================================================
# Change made
# Version 1.0
# 1. Create
# Version 1.1.4.8
# 2. add Scenario DeviceGroup class for NGPF
# Version 1.2.5.14
# 3. add enum IPV4 & IPV6
# 4. add config_ethernet
# 5. add config_vlan
# Version 1.3.4.66
# 6. add config_ip
# 7. add config_bgp
# 8. add config_bgp_route
# 9. add set_route
# Version 1.4.6.9
# 10. add -type in config
# Version 1.5.6.10
# 11. add alias in config_ethernet config_ip
class DeviceGroup {
#inherit EmulationObject
public variable portObj
public variable topology
public variable handle
public variable type
public variable count
public variable ethernet
public variable vlan
public variable ipv4
public variable ipv6
public variable bgpIpv4Peer
public variable bgpIpv6Peer
public variable bgpIpv4NetworkGroup
public variable bgpIpv6NetworkGroup
public variable ipv4PrefixPools
public variable ipv6PrefixPools
public variable bgpIPRouteProperty
public variable bgpV6IPRouteProperty
# -- port can be a list, but one port recommended
# -- template
# -- -enum: BGP4_DUAL L3VPN_PE
constructor { port { template null } {topo null} } {
set topology $topo
set portObj $port
set type [ string toupper $template ]
reborn $topology
}
method reborn { {topo null} } {}
method init {} {}
method config { args }
proc SetMultipleValue { obj key value { step 0 } { type "" } } {
global errorInfo
global errNumber
set tag "body DeviceGroup::SetMultipleValue [info script]"
Deputs "----- TAG: $tag -----"
Deputs "obj:$obj key:$key val:$value step:$step type: $type"
if { [llength $value] >= 3 } {
set type "custom"
}
set mv [ ixNet getA $obj $key ]
Deputs "mv:$mv"
if { $step != 0 } {
Deputs Step5
ixNet setA $mv -pattern counter
ixNet commit
}
Deputs Step10
if { [ catch {
set isMvObj [ixNet exists $mv]
} ] } {
return
} else {
if { $isMvObj == "false" } {
return
}
}
if { $type == "custom" } {
if { [llength [ixNet getL $mv custom]] == 0 } {
set custom [ixNet add $mv "custom"]
ixNet commit
} else {
set custom [lindex [ixNet getL $mv custom] 0]
}
Deputs "start: [lindex $value 0]"
ixNet setM $custom -step 0 -start [lindex $value 0]
ixNet commit
if { [llength [ixNet getL $custom increment]] == 0 } {
set increment1 [ixNet add $custom "increment"]
ixNet commit
} else {
set increment1 [lindex [ixNet getL $custom increment] 0]
}
Deputs "count: [lindex $value 3], value: [lindex $value 1]"
ixNet setM $increment1 -count [lindex $value 3] -value [lindex $value 1]
ixNet commit
if { [llength [ixNet getL $increment1 increment]] == 0 } {
set increment2 [ixNet add $increment1 "increment"]
ixNet commit
} else {
set increment2 [lindex [ixNet getL $increment1 increment] 0]
}
Deputs "count: [lindex $value 2], value: 0"
ixNet setM $increment2 -count [lindex $value 2] -value 0
ixNet commit
} else {
Deputs "mv: $mv, value: $value, step: $step"
ixNet setM $mv/counter \
-start $value \
-step $step
if { [ catch {
Deputs Step20
ixNet commit
} ] } {
Deputs Step30
ixNet setA $mv/singleValue -value $value
catch {
Deputs Step40
ixNet commit
}
}
}
}
method config_ethernet { args } {}
method config_vlan { args } {}
method config_ip { args } {}
method config_ipv4 { args } {}
method config_ipv6 { args } {}
method config_bgp { args } {}
method config_bgp4 { args } {}
method config_bgp4plus { args } {}
method config_bgp_route { args } {}
method config_bgp4_route { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp4_route [info script]"
Deputs "----- TAG: $tag -----"
if { [ info exists bgpIPRouteProperty ] } {
eval config_bgp_route $args -obj $bgpIPRouteProperty
} else {
eval config_bgp_route $args -family ipv4
}
return [GetStandardReturnHeader]
}
method config_bgp4plus_route { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp4plus_route [info script]"
Deputs "----- TAG: $tag -----"
eval config_bgp_route $args -obj $bgpV6IPRouteProperty
return [GetStandardReturnHeader]
}
method import_bgp_route { obj filename } {
global errorInfo
global errNumber
set tag "body DeviceGroup::import_bgp_route [info script]"
Deputs "----- TAG: $tag -----"
Deputs "filename:$filename"
ixNet setM $obj/importBgpRoutesParams \
-fileType csv \
-dataFile [ixNet readFrom $filename]
ixNet commit
ixNet exec importBgpRoutes $obj/importBgpRoutesParams
}
method import_bgp4_route { filename } {
global errorInfo
global errNumber
set tag "body DeviceGroup::import_bgp4_route [info script]"
Deputs "----- TAG: $tag -----"
import_bgp_route $bgpIPRouteProperty $filename
}
method import_bgp4plus_route { filename } {
global errorInfo
global errNumber
set tag "body DeviceGroup::import_bgp4plus_route [info script]"
Deputs "----- TAG: $tag -----"
import_bgp_route $bgpV6IPRouteProperty $filename
}
method start_bgp4_route {} {
ixNet exec start $bgpIpv4NetworkGroup
}
method start_bgp4plus_route {} {
ixNet exec start $bgpIpv6NetworkGroup
}
method set_route { args } {}
proc enable_prefix { obj } {
global errorInfo
global errNumber
set tag "body DeviceGroup::enable_prefix [info script]"
Deputs "----- TAG: $tag -----"
SetMultipleValue [ixNet getP $obj] -enabled true
}
proc disable_prefix { obj } {
global errorInfo
global errNumber
set tag "body DeviceGroup::disable_prefix [info script]"
Deputs "----- TAG: $tag -----"
SetMultipleValue [ixNet getP $obj] -enabled false
}
proc start_prefix { obj } {
global errorInfo
global errNumber
set tag "body DeviceGroup::advertise_prefix [info script]"
Deputs "----- TAG: $tag -----"
ixNet exec start [ixNet getP $obj]
}
proc stop_prefix { obj } {
global errorInfo
global errNumber
set tag "body DeviceGroup::stop_prefix [info script]"
Deputs "----- TAG: $tag -----"
ixNet exec stop [ixNet getP $obj]
}
}
body DeviceGroup::reborn { {topo null} } {
global errorInfo
global errNumber
set tag "body DeviceGroup::reborn [info script]"
Deputs "----- TAG: $tag -----"
set root [ixNet getRoot]
set vPortList [ list ]
foreach vport $portObj {
set vport [ $vport cget -handle ]
lappend vPortList $vport
}
if { $topo == "null" } {
set topology [ixNet add $root topology]
ixNet setM $topology \
-vports $vPortList
ixNet commit
set topology [ixNet remapIds $topology]
} else {
set topology $topo
}
Deputs "topology: $topology"
#ixNet setA $topology -name ${type}_$this
set hPort $vPortList
set handle [ixNet add $topology deviceGroup]
ixNet setA $handle -name $this
ixNet commit
set handle [ixNet remapIds $handle]
Deputs "handle: $handle"
if { $type != "NULL" } {
init
}
return [GetStandardReturnHeader]
}
body DeviceGroup::init {} {
set tag "body DeviceGroup::init [info script]"
Deputs "----- TAG: $tag -----"
switch $type {
BGP4_DUAL {
set ethernet [ixNet add $handle ethernet]
ixNet commit
set ethernet [ixNet remapIds $ethernet]
set vlan [lindex [ixNet getL $ethernet vlan] 0]
set ipv4 [ixNet add $ethernet ipv4]
ixNet commit
set ipv4 [ixNet remapIds $ipv4]
set ipv6 [ixNet add $ethernet ipv6]
ixNet commit
set ipv6 [ixNet remapIds $ipv6]
set bgpIpv4Peer [ixNet add $ipv4 bgpIpv4Peer]
ixNet commit
set bgpIpv4Peer [ixNet remapIds $bgpIpv4Peer]
set bgpIpv6Peer [ixNet add $ipv6 bgpIpv6Peer]
ixNet commit
set bgpIpv6Peer [ixNet remapIds $bgpIpv6Peer ]
set bgpIpv4NetworkGroup [ixNet add $handle networkGroup]
set bgpIpv6NetworkGroup [ixNet add $handle networkGroup]
ixNet commit
set bgpIpv4NetworkGroup [ixNet remapIds $bgpIpv4NetworkGroup]
set bgpIpv6NetworkGroup [ixNet remapIds $bgpIpv6NetworkGroup]
set ipv4PrefixPools [ ixNet add $bgpIpv4NetworkGroup ipv4PrefixPools ]
set ipv6PrefixPools [ ixNet add $bgpIpv6NetworkGroup ipv6PrefixPools ]
ixNet commit
set ipv4PrefixPools [ixNet remapIds $ipv4PrefixPools]
set ipv6PrefixPools [ixNet remapIds $ipv6PrefixPools]
set bgpIPRouteProperty [ ixNet getL $ipv4PrefixPools bgpIPRouteProperty ]
set bgpV6IPRouteProperty [ ixNet getL $ipv6PrefixPools bgpV6IPRouteProperty ]
SetMultipleValue [ ixNet getL $ipv4PrefixPools bgpV6IPRouteProperty ] -active false
SetMultipleValue [ ixNet getL $ipv6PrefixPools bgpIPRouteProperty ] -active false
}
BGP4 {
set ethernet [ixNet add $handle ethernet]
ixNet commit
set vlan [lindex [ixNet getL $ethernet vlan] 0]
set ipv4 [ixNet add $ethernet ipv4]
ixNet commit
set bgpIpv4Peer [ixNet add $ipv4 bgpIpv4Peer]
ixNet commit
set bgpIpv4NetworkGroup [ixNet add $handle networkGroup]
ixNet commit
set ipv4PrefixPools [ ixNet add $bgpIpv4NetworkGroup ipv4PrefixPools ]
ixNet commit
}
IPV4 {
set ethernet [ixNet add $handle ethernet]
ixNet commit
set vlan [lindex [ixNet getL $ethernet vlan] 0]
set ipv4 [ixNet add $ethernet ipv4]
ixNet commit
}
IPV6 {
set ethernet [ixNet add $handle ethernet]
ixNet commit
set vlan [lindex [ixNet getL $ethernet vlan] 0]
set ipv6 [ixNet add $ethernet ipv6]
ixNet commit
}
BGP4PLUS {
set ethernet [ixNet add $handle ethernet]
ixNet commit
set vlan [lindex [ixNet getL $ethernet vlan] 0]
set ipv6 [ixNet add $ethernet ipv6]
ixNet commit
set bgpIpv6Peer [ixNet add $ipv4 bgpIpv6Peer]
ixNet commit
set bgpIpv6NetworkGroup [ixNet add $handle networkGroup]
ixNet commit
set ipv6PrefixPools [ ixNet add $bgpIpv4NetworkGroup ipv6PrefixPools ]
ixNet commit
}
L3VPN_PE {
}
}
ixNet commit
}
# ---------------------------------
# -- count
# -- -INT
# -- router_id
# -- -IP
body DeviceGroup::config { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
reborn
}
set count 1
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-count {
set count $value
}
-router_id {
set router_id $value
}
-type {
set type [string toupper $value]
init
}
}
}
ixNet setM $handle \
-multiplier $count \
-name $this
ixNet commit
if { [ info exists router_id ] } {
SetMultipleValue [ ixNet getL $handle routerData ] -routerId $router_id
}
return [GetStandardReturnHeader]
}
# ---------------------------------
# -- mac/src_mac
# -- -MAC addr
# -- src_mac_step
# -- -MAC addr
# -- mtu
# -- -INT
# -- enable_vlan
# -- -BOOL
body DeviceGroup::config_ethernet { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_ethernet [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
config -count $count
}
#param collection
Deputs "Args:$args "
array set kvList [list]
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-mac -
-mtu {
}
-vlan_count {
ixNet setA $ethernet -vlanCount $value
ixNet commit
}
-enable_vlan {
set key -enableVlans
}
-src_mac {
set key -mac
}
-src_mac_step {
set src_mac_step $value
}
default {
continue
}
}
set kvList($key) $value
}
foreach key [array names kvList] {
switch -exact -- $key {
-mac {
if { [ info exists src_mac_step ] } {
SetMultipleValue $ethernet $key $kvList($key) $src_mac_step
} else {
SetMultipleValue $ethernet $key $kvList($key)
}
}
default {
SetMultipleValue $ethernet $key $kvList($key)
}
}
}
return [GetStandardReturnHeader]
}
# ---------------------------------
# -- tpid
# -- -HEX
# -- priority
# -- -INT
# -- vlan_id
# -- -INT
body DeviceGroup::config_vlan { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_vlan [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
config -count $count
}
#param collection
Deputs "Args:$args "
config_ethernet -enable_vlan 1
array set kvList [list]
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-tpid {
if { [ IsHex $value ] } {
set value [string replace $value 0 1 ethertype]
# set value [ format %i $value ]
}
}
-priority {
set priority $value
continue
}
-priority_type {
set priorityMode $value
continue
}
-vlan_id -
-vlan_id1 -
-outer_vlan_id {
set key -vlanId
}
-vlan_id1_step -
-outer_vlan_step {
set vlan_step $value
}
-vlan_id2 -
-inner_vlan_id {
set key -vlanId2
}
-vlan_id2_step -
-inner_vlan_step {
set vlan_step2 $value
}
default {
continue
}
}
set kvList($key) $value
}
if { [info exists priorityMode] } {
SetMultipleValue $vlan -priority $priority 0 $priorityMode
} else {
SetMultipleValue $vlan -priority $priority
}
foreach key [array names kvList] {
switch -exact -- $key {
-vlanId {
if { [ info exists vlan_step ] } {
SetMultipleValue $vlan $key $kvList($key) $vlan_step
} else {
SetMultipleValue $vlan $key $kvList($key)
}
}
-vlanId2 {
config_ethernet -vlan_count 2
set vlan [lindex [ixNet getL $ethernet vlan] 1]
if { [ info exists vlan_step2 ] } {
SetMultipleValue $vlan -vlanId $kvList($key) $vlan_step2
} else {
SetMultipleValue $vlan -vlanId $kvList($key)
}
set vlan [lindex [ixNet getL $ethernet vlan] 0]
}
-tpid {
SetMultipleValue $vlan $key $kvList($key)
}
default {
SetMultipleValue $ethernet $key $kvList($key)
}
}
}
return [GetStandardReturnHeader]
}
# ---------------------------------
# -- address
# -- -IP
# -- prefix
# -- -INT
# -- gateway
# -- -IP
# -- family
# -- -enum: ipv4 ipv6
body DeviceGroup::config_ip { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_ip [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
config -count $count
}
#param collection
Deputs "Args:$args "
array set kvList [list]
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-address -
-prefix {
}
-gateway -
-ipv4_gw -
-ipv6_gw {
set key -gatewayIp
}
-ipv4_gw_step -
-ipv6_gw_step {
set gw_step $value
}
-family {
set obj $value
continue
}
-ipv4_addr -
-ipv6_addr {
set key -address
}
-ipv4_addr_step -
-ipv6_addr_step {
set addr_step $value
}
-ipv4_prefix_len -
-ipv4_prefix_length -
-ipv6_prefix_len -
-ipv6_prefix_length {
set key -prefix
}
default {
continue
}
}
set kvList($key) $value
}
if { [ info exists obj ] } {
foreach key [array names kvList] {
switch -exact -- $key {
-address {
if { [ info exists addr_step ] } {
SetMultipleValue $obj $key $kvList($key) $addr_step
} else {
SetMultipleValue $obj $key $kvList($key)
}
}
-gatewayIp {
if { [ info exists gw_step ] } {
SetMultipleValue $obj $key $kvList($key) $gw_step
} else {
SetMultipleValue $obj $key $kvList($key)
}
}
default {
SetMultipleValue $obj $key $kvList($key)
}
}
}
}
return [GetStandardReturnHeader]
}
body DeviceGroup::config_ipv4 { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_ipv4 [info script]"
Deputs "----- TAG: $tag -----"
return [eval config_ip -family $ipv4 $args]
}
body DeviceGroup::config_ipv6 { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_ipv6 [info script]"
Deputs "----- TAG: $tag -----"
return [eval config_ip -family $ipv6 $args]
}
# ---------------------------------
# -- authentication
# -- -enum: null md5
# -- type
# -- -enum: internal external
# -- as
# -- -INT
# -- hold_time_interval
# -- -INT
# -- update_interval
# -- -INT
# -- md5
# -- -STRING
# -- family
# -- -enum: bgpIpv4Peer bgpIpv6Peer
body DeviceGroup::config_bgp { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
config -count $count
}
#param collection
Deputs "Args:$args "
array set kvList [list]
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-authentication -
-type -
-ttl {
}
-md5 {
set key -md5Key
}
-dut_ip {
set key -dutIp
}
-hold_time_interval {
set key -holdTimer
}
-update_interval {
set key -updateInterval
}
-as {
set key -localAs2Bytes
}
-as_step {
set as_step $value
}
-family {
set obj $value
continue
}
default {
continue
}
}
set kvList($key) $value
}
if { [ info exists obj ] } {
foreach key [array names kvList] {
switch -- $key {
-localAs2Bytes {
if { [info exists as_step] } {
SetMultipleValue $obj $key $kvList($key) $as_step
} else {
SetMultipleValue $obj $key $kvList($key)
}
}
default {
SetMultipleValue $obj $key $kvList($key)
}
}
}
}
return [GetStandardReturnHeader]
}
body DeviceGroup::config_bgp4 { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp4 [info script]"
Deputs "----- TAG: $tag -----"
return [eval config_bgp -family $bgpIpv4Peer $args]
}
body DeviceGroup::config_bgp4plus { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp4plus [info script]"
Deputs "----- TAG: $tag -----"
return [eval config_bgp -family $bgpIpv6Peer $args]
}
# ---------------------------------
# -- start
# -- -IP
# -- step
# -- -IP
# -- prefix_len
# -- -INT
# -- prefix_step
# -- -INT
# -- num
# -- -INT
# -- family
# -- -ipv4/ipv6
# -- obj
body DeviceGroup::config_bgp_route { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::config_bgp [info script]"
Deputs "----- TAG: $tag -----"
if { $handle == "" } {
config -count $count
}
set num 1
#param collection
Deputs "Args:$args "
foreach { key value } $args {
set key [string tolower $key]
switch -exact -- $key {
-start {
set address_start $value
}
-step {
set address_step $value
}
-prefix_len {
set prefix_length_start $value
}
-prefix_step {
set prefix_length_step $value
}
-num {
set num $value
}
-obj {
set obj $value
}
-family {
set family $value
}
}
}
if { [ info exists obj ] == 0 } {
set networkGroup [ixNet add $handle networkGroup]
ixNet commit
if { $family == "ipv6" } {
set obj [ ixNet add $networkGroup ipv6PrefixPools ]
} else {
set obj [ ixNet add $networkGroup ipv4PrefixPools ]
}
ixNet commit
}
ixNet setA $networkGroup -multiplier $num
set mvAddr [ ixNet getA $obj -networkAddress ]
set mvPfx [ ixNet getA $obj -prefixLength ]
if { [ info exists address_start ] } {
ixNet setA $mvAddr/counter -start $address_start
}
if { [ info exists address_step ] } {
ixNet setA $mvAddr/counter -step $address_step
}
if { [ info exists prefix_length_start ] } {
ixNet setA $mvPfx/counter -start $prefix_length_start
}
if { [ info exists prefix_length_step ] } {
ixNet setA $mvPfx/counter -step $prefix_length_step
}
ixNet commit
if { [ info exists family ] } {
if { $family == "ipv4" } {
catch {
SetMultipleValue [ ixNet getL $obj bgpV6IPRouteProperty ] -active false
}
}
if { $family == "ipv6" } {
catch {
SetMultipleValue [ ixNet getL $obj bgpIPRouteProperty ] -active false
}
}
}
return $obj
}
# ---------------------------------
# -- route_block
# -- -RouteBlock obj
body DeviceGroup::set_route { args } {
global errorInfo
global errNumber
set tag "body DeviceGroup::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
}
}
}
if { [ info exists route_block ] } {
set num [ $route_block cget -num ]
set step [ $route_block cget -step ]
set prefix_len [ $route_block cget -prefix_len ]
set start [ $route_block cget -start ]
set type [ $route_block cget -type ]
set handle [ \
config_bgp_route \
-num $num \
-start $start \
-family $type \
-step [ IncrementIPAddr 0.0.0.0 $prefix_len $step ] \
-prefix_len $prefix_len
]
set handle [ixNet remapIds $handle]
$route_block configure -handle $handle
}
return [GetStandardReturnHeader]
}