-
Notifications
You must be signed in to change notification settings - Fork 2
/
do.sh
executable file
·1361 lines (1200 loc) · 46.4 KB
/
do.sh
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
#!/bin/sh
# update for any release using
# curl -kLO https://github.com/open-traffic-generator/ixia-c/releases/download/v1.19.0-5/versions.yaml
VERSIONS_YAML="versions.yaml"
VETH_A="veth-a"
VETH_Z="veth-z"
# additional member ports for LAG
VETH_B="veth-b"
VETH_C="veth-c"
VETH_X="veth-x"
VETH_Y="veth-y"
FORCE_CREATE_VETH=true
GO_VERSION=1.23.0
KIND_VERSION=v0.20.0
METALLB_VERSION=v0.13.11
MESHNET_COMMIT=d7c306c
MESHNET_IMAGE="networkop/meshnet\:v0.3.0"
KENG_OPERATOR_VERSION="0.3.34"
KENG_OPERATOR_YAML="https://github.com/open-traffic-generator/keng-operator/releases/download/v${KENG_OPERATOR_VERSION}/ixiatg-operator.yaml"
NOKIA_SRL_OPERATOR_VERSION="0.4.6"
NOKIA_SRL_OPERATOR_YAML="https://github.com/srl-labs/srl-controller/config/default?ref=v${NOKIA_SRL_OPERATOR_VERSION}"
ARISTA_CEOS_OPERATOR_VERSION="2.0.1"
ARISTA_CEOS_OPERATOR_YAML="https://github.com/aristanetworks/arista-ceoslab-operator/config/default?ref=v${ARISTA_CEOS_OPERATOR_VERSION}"
ARISTA_CEOS_VERSION="4.29.1F-29233963"
ARISTA_CEOS_IMAGE="ghcr.io/open-traffic-generator/ceos"
KNE_VERSION=v0.1.17
OPENCONFIG_MODELS_REPO=https://github.com/openconfig/public.git
OPENCONFIG_MODELS_COMMIT=5ca6a36
TIMEOUT_SECONDS=300
APT_GET_UPDATE=true
IXIA_C_CONFIG_MAP_TEMP="deployments/template-ixia-c-config.yaml"
IXIA_C_CONFIG_MAP="deployments/.ixia-c-config.yaml"
YQ_RELEASE="v4.34.1"
YQ_SOURCE="github.com/mikefarah/yq/v4@${YQ_RELEASE}"
get_yq() {
echo "Getting yq ..."
echo "Installing yq ${YQ_SOURCE} ..."
go install "${YQ_SOURCE}"
echo "Successfully installed yq !"
}
configq() {
# echo is needed to further evaluate the
# contents extracted from configuration
eval echo $(yq "${@}" versions.yaml)
}
eval_config_map() {
get_yq \
&& rm -rf ${IXIA_C_CONFIG_MAP}
# avoid splitting based on whitespace
IFS=''
# mix of cat and echo is used to ensure the input file has
# at least one newline before EOF, otherwise read will not
# provide last line
{ cat ${IXIA_C_CONFIG_MAP_TEMP}; echo; } | while read line; do
# replace all double-quotes with single quotes
line=$(echo "${line}" | sed s#\"#\'#g)
# and revert them back to double-quotes post eval;
# this will result in converting all single-quotes
# to double-quotes regardless of whether they were
# originally double-quotes, but hopefully this won't
# be an issue
# this workaround was put in place because eval gets
# rid of double-quotes
eval echo \"$line\" | sed s#\'#\"#g >> ${IXIA_C_CONFIG_MAP}
done
# restore default IFS
unset IFS
cat ${IXIA_C_CONFIG_MAP}
}
apt_update() {
if [ "${APT_UPDATE}" = "true" ]
then
sudo apt-get update
APT_GET_UPDATE=false
fi
}
apt_install() {
echo "Installing ${1} ..."
apt_update \
&& sudo apt-get install -y --no-install-recommends ${1}
}
apt_install_curl() {
curl --version > /dev/null 2>&1 && return
apt_install curl
}
apt_install_vim() {
dpkg -s vim > /dev/null 2>&1 && return
apt_install vim
}
apt_install_git() {
git version > /dev/null 2>&1 && return
apt_install git
}
apt_install_lsb_release() {
lsb_release -v > /dev/null 2>&1 && return
apt_install lsb_release
}
apt_install_gnupg() {
gpg -k > /dev/null 2>&1 && return
apt_install gnupg
}
apt_install_ca_certs() {
dpkg -s ca-certificates > /dev/null 2>&1 && return
apt_install gnupg ca-certificates
}
apt_install_pkgs() {
uname -a | grep -i linux > /dev/null 2>&1 || return 0
apt_install_curl \
&& apt_install_vim \
&& apt_install_git \
&& apt_install_lsb_release \
&& apt_install_gnupg \
&& apt_install_ca_certs
}
get_go() {
which go > /dev/null 2>&1 && return
echo "Installing Go ${GO_VERSION} ..."
# install golang per https://golang.org/doc/install#tarball
curl -kL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | sudo tar -C /usr/local/ -xzf - \
&& echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.profile \
&& . $HOME/.profile \
&& go version
}
get_docker() {
which docker > /dev/null 2>&1 && return
echo "Installing docker ..."
sudo apt-get remove docker docker-engine docker.io containerd runc 2> /dev/null
curl -kfsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update \
&& sudo apt-get install -y docker-ce docker-ce-cli containerd.io
}
common_install() {
apt_install_pkgs \
&& get_go \
&& get_docker \
&& sudo_docker
}
create_veth_pair() {
if [ -z "${1}" ] || [ -z "${2}" ]
then
echo "usage: ${0} create_veth_pair <name1> <name2>"
exit 1
fi
if [ "${FORCE_CREATE_VETH}" = "true" ]
then
rm_veth_pair ${1} ${2} 2> /dev/null
fi
sudo ip link add ${1} type veth peer name ${2} \
&& sudo ip link set ${1} up \
&& sudo ip link set ${2} up
}
rm_veth_pair() {
if [ -z "${1}" ] || [ -z "${2}" ]
then
echo "usage: ${0} rm_veth_pair <name1> <name2>"
exit 1
fi
sudo ip link delete ${1}
}
ipv6_enable_docker() {
echo "{\"ipv6\": true, \"fixed-cidr-v6\": \"2001:db8:1::/64\"}" | sudo tee /etc/docker/daemon.json
echo "$(sudo systemctl restart docker)"
}
push_ifc_to_container() {
if [ -z "${1}" ] || [ -z "${2}" ]
then
echo "usage: ${0} push_ifc_to_container <ifc-name> <container-name>"
exit 1
fi
cid=$(container_id ${2})
cpid=$(container_pid ${2})
echo "Changing namespace of ifc ${1} to container ID ${cid} pid ${cpid}"
orgPath=/proc/${cpid}/ns/net
newPath=/var/run/netns/${cid}
sudo mkdir -p /var/run/netns
echo "Creating symlink ${orgPath} -> ${newPath}"
sudo ln -s ${orgPath} ${newPath} \
&& sudo ip link set ${1} netns ${cid} \
&& sudo ip netns exec ${cid} ip link set ${1} name ${1} \
&& sudo ip netns exec ${cid} ip -4 addr add 0/0 dev ${1} \
&& sudo ip netns exec ${cid} ip -4 link set ${1} up \
&& echo "Successfully changed namespace of ifc ${1}"
sudo rm -rf ${newPath}
}
container_id() {
docker inspect --format="{{json .Id}}" ${1} | cut -d\" -f 2
}
container_pid() {
docker inspect --format="{{json .State.Pid}}" ${1} | cut -d\" -f 2
}
container_ip() {
docker inspect --format="{{json .NetworkSettings.IPAddress}}" ${1} | cut -d\" -f 2
}
container_ip6() {
docker inspect --format="{{json .NetworkSettings.GlobalIPv6Address}}" ${1} | cut -d\" -f 2
}
ixia_c_img() {
path=$(grep -A 2 ${1} ${VERSIONS_YAML} | grep path | cut -d: -f2 | cut -d\ -f2)
tag=$(grep -A 2 ${1} ${VERSIONS_YAML} | grep tag | cut -d: -f2 | cut -d\ -f2)
echo "${path}:${tag}"
}
ixia_c_traffic_engine_img() {
ixia_c_img traffic-engine
}
ixia_c_protocol_engine_img() {
ixia_c_img protocol-engine
}
keng_controller_img() {
ixia_c_img controller
}
keng_license_server_img() {
ixia_c_img license-server
}
login_ghcr() {
if [ -f "$HOME/.docker/config.json" ]
then
grep ghcr.io "$HOME/.docker/config.json" > /dev/null && return 0
fi
if [ -z "${GITHUB_USER}" ] || [ -z "${GITHUB_PAT}" ]
then
echo "Logging into docker repo ghcr.io (Please provide Github Username and PAT)"
docker login ghcr.io
else
echo "Logging into docker repo ghcr.io"
echo "${GITHUB_PAT}" | docker login -u"${GITHUB_USER}" --password-stdin ghcr.io
fi
}
logout_ghcr() {
docker logout ghcr.io
}
gen_controller_config_b2b_dp() {
configdir=/home/ixia-c/controller/config
wait_for_sock localhost 5555
wait_for_sock localhost 5556
yml="location_map:
- location: ${VETH_A}
endpoint: localhost:5555
- location: ${VETH_Z}
endpoint: localhost:5556
"
echo -n "$yml" | sed "s/^ //g" | tee ./config.yaml > /dev/null \
&& docker exec keng-controller mkdir -p ${configdir} \
&& docker cp ./config.yaml keng-controller:${configdir}/ \
&& rm -rf ./config.yaml
}
gen_controller_config_b2b_cpdp() {
configdir=/home/ixia-c/controller/config
if [ "${1}" = "ipv6" ]
then
OTG_PORTA=$(container_ip6 ixia-c-traffic-engine-${VETH_A})
OTG_PORTZ=$(container_ip6 ixia-c-traffic-engine-${VETH_Z})
else
OTG_PORTA=$(container_ip ixia-c-traffic-engine-${VETH_A})
OTG_PORTZ=$(container_ip ixia-c-traffic-engine-${VETH_Z})
fi
wait_for_sock ${OTG_PORTA} 5555
wait_for_sock ${OTG_PORTA} 50071
wait_for_sock ${OTG_PORTZ} 5555
wait_for_sock ${OTG_PORTZ} 50071
if [ "${1}" = "ipv6" ]
then
OTG_PORTA="[${OTG_PORTA}]"
OTG_PORTZ="[${OTG_PORTZ}]"
fi
yml="location_map:
- location: ${VETH_A}
endpoint: \"${OTG_PORTA}:5555+${OTG_PORTA}:50071\"
- location: ${VETH_Z}
endpoint: \"${OTG_PORTZ}:5555+${OTG_PORTZ}:50071\"
"
echo -n "$yml" | sed "s/^ //g" | tee ./config.yaml > /dev/null \
&& docker exec keng-controller mkdir -p ${configdir} \
&& docker cp ./config.yaml keng-controller:${configdir}/ \
&& rm -rf ./config.yaml
}
gen_controller_config_b2b_lag() {
configdir=/home/ixia-c/controller/config
OTG_PORTA=$(container_ip ixia-c-traffic-engine-${VETH_A})
OTG_PORTZ=$(container_ip ixia-c-traffic-engine-${VETH_Z})
wait_for_sock ${OTG_PORTA} 5555
wait_for_sock ${OTG_PORTA} 50071
wait_for_sock ${OTG_PORTZ} 5555
wait_for_sock ${OTG_PORTZ} 50071
yml="location_map:
- location: ${VETH_A}
endpoint: ${OTG_PORTA}:5555;1+${OTG_PORTA}:50071
- location: ${VETH_B}
endpoint: ${OTG_PORTA}:5555;2+${OTG_PORTA}:50071
- location: ${VETH_C}
endpoint: ${OTG_PORTA}:5555;3+${OTG_PORTA}:50071
- location: ${VETH_Z}
endpoint: ${OTG_PORTZ}:5555;1+${OTG_PORTZ}:50071
- location: ${VETH_Y}
endpoint: ${OTG_PORTZ}:5555;2+${OTG_PORTZ}:50071
- location: ${VETH_X}
endpoint: ${OTG_PORTZ}:5555;3+${OTG_PORTZ}:50071
"
echo -n "$yml" | sed "s/^ //g" | tee ./config.yaml > /dev/null \
&& docker exec keng-controller mkdir -p ${configdir} \
&& docker cp ./config.yaml keng-controller:${configdir}/ \
&& rm -rf ./config.yaml
}
gen_config_common() {
location=localhost
if [ "${1}" = "ipv6" ]
then
location="[$(container_ip6 keng-controller)]"
fi
yml="otg_speed: speed_1_gbps
otg_capture_check: true
otg_iterations: 100
otg_grpc_transport: false
"
echo -n "$yml" | sed "s/^ //g" | tee -a ./test-config.yaml > /dev/null
}
gen_config_b2b_dp() {
yml="otg_host: https://localhost:8443
otg_ports:
- ${VETH_A}
- ${VETH_Z}
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null
gen_config_common
}
gen_config_b2b_cpdp() {
yml="otg_host: https://localhost:8443
otg_ports:
- ${VETH_A}
- ${VETH_Z}
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null
gen_config_common $1
}
gen_config_b2b_lag() {
yml="otg_host: https://localhost:8443
otg_ports:
- ${VETH_A}
- ${VETH_B}
- ${VETH_C}
- ${VETH_Z}
- ${VETH_Y}
- ${VETH_X}
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null
gen_config_common
}
gen_config_kne() {
OTG_ADDR=$(kubectl get service -n ixia-c service-https-otg-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
topo=$(kne_topo_file ${1} ${2})
yml=" otg_ports:\n"
for p in $(grep "_node: otg" ${topo} -A 1 | grep _int | sed s/\\s//g)
do
yml="${yml} - $(echo ${p} | cut -d: -f2)\n"
done
if [ ! -z "${2}" ]
then
yml="${yml} dut_configs:\n"
DUT_ADDR=$(kubectl get service -n ixia-c service-dut -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
yml="${yml} - name: dut\n"
yml="${yml} host: ${DUT_ADDR}\n"
SSH_PORT=$(grep "\- name: dut" -A 30 ${topo} | grep -m 1 services -A 10 | grep 'name: ssh' -B 1 | head -n 1 | tr -d ' :')
yml="${yml} ssh_username: admin\n"
# yml="${yml} ssh_password: admin\n"
yml="${yml} ssh_port: ${SSH_PORT}\n"
GNMI_PORT=$(grep "\- name: dut" -A 30 ${topo} | grep -m 1 services -A 10 | grep 'name: gnmi' -B 1 | head -n 1 | tr -d ' :')
yml="${yml} gnmi_username: admin\n"
yml="${yml} gnmi_password: admin\n"
yml="${yml} gnmi_port: ${GNMI_PORT}\n"
yml="${yml} interfaces:\n"
for i in $(kne topology service ${topo} | grep interfaces -A 8 | grep -E 'peer_name:\s+\"otg' -A 3 -B 5 | grep ' name:'| tr -d ' ')
do
ifc=$(echo $i | cut -d\" -f2)
yml="${yml} - ${ifc}\n"
done
wait_for_sock ${DUT_ADDR} ${GNMI_PORT}
wait_for_sock ${DUT_ADDR} ${SSH_PORT}
fi
yml="otg_host: https://${OTG_ADDR}:8443\n${yml}"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null
gen_config_common
}
gen_config_k8s() {
pwd
ADDR=$(kubectl get service -n ixia-c service-otg-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
ETH1=$(grep "location:" deployments/k8s/manifests/.${1}.yaml -m 2 | head -n1 | cut -d\: -f2 | cut -d\ -f2)
ETH2=$(grep "location:" deployments/k8s/manifests/.${1}.yaml -m 2 | tail -n1 | cut -d\: -f2 | cut -d\ -f2)
yml="otg_host: https://${ADDR}:8443
otg_ports:
- ${ETH1}
- ${ETH2}
"
echo -n "$yml" | sed "s/^ //g" | tee ./test-config.yaml > /dev/null
gen_config_common
gen_config_k8s_test_const ${1}
}
gen_config_k8s_test_const() {
if [ "${1}" = "ixia-c-b2b-eth0" ]
then
rxUdpPort=7000
txIp=$(kubectl get pod -n ixia-c otg-port-eth1 -o 'jsonpath={.status.podIP}')
rxIp=$(kubectl get pod -n ixia-c otg-port-eth2 -o 'jsonpath={.status.podIP}')
# send ping to flood arp table and extract gateway MAC
kubectl exec -n ixia-c otg-port-eth1 -c otg-port-eth1-protocol-engine -- ping -c 1 ${rxIp}
gatewayMac=$(kubectl exec -n ixia-c otg-port-eth1 -c otg-port-eth1-protocol-engine -- arp -a | head -n 1 | cut -d\ -f4)
txMac=$(kubectl exec -n ixia-c otg-port-eth1 -c otg-port-eth1-protocol-engine -- ifconfig eth0 | grep ether | sed 's/ */_/g' | cut -d_ -f3)
rxMac=$(kubectl exec -n ixia-c otg-port-eth2 -c otg-port-eth2-protocol-engine -- ifconfig eth0 | grep ether | sed 's/ */_/g' | cut -d_ -f3)
# drop UDP packets on given dst port
kubectl exec -n ixia-c otg-port-eth2 -c otg-port-eth2-protocol-engine -- lsb_release -sc
kubectl exec -n ixia-c otg-port-eth2 -c otg-port-eth2-protocol-engine -- apt-get -y update
kubectl exec -n ixia-c otg-port-eth2 -c otg-port-eth2-protocol-engine -- apt-get install -y iptables
kubectl exec -n ixia-c otg-port-eth2 -c otg-port-eth2-protocol-engine -- iptables -A INPUT -p udp --destination-port ${rxUdpPort} -j DROP
yml="otg_test_const:
txMac: ${txMac}
rxMac: ${rxMac}
gatewayMac: ${gatewayMac}
txIp: ${txIp}
rxIp: ${rxIp}
rxUdpPort: ${rxUdpPort}
"
echo -n "$yml" | sed "s/^ //g" | tee -a ./test-config.yaml > /dev/null
fi
}
gen_openconfig_models_sdk() {
echo "Fetching openconfig models ..."
rm -rf etc/public \
&& rm -rf helpers/dut/gnmi \
&& mkdir -p etc \
&& cd etc \
&& git clone ${OPENCONFIG_MODELS_REPO} \
&& cd public \
&& git checkout ${OPENCONFIG_MODELS_COMMIT} \
&& cd ..
EXCLUDE_MODULES=ietf-interfaces,openconfig-bfd,openconfig-messages
YANG_FILES="
public/release/models/acl/openconfig-acl.yang
public/release/models/acl/openconfig-packet-match.yang
public/release/models/aft/openconfig-aft.yang
public/release/models/aft/openconfig-aft-network-instance.yang
public/release/models/ate/openconfig-ate-flow.yang
public/release/models/ate/openconfig-ate-intf.yang
public/release/models/bfd/openconfig-bfd.yang
public/release/models/bgp/openconfig-bgp-policy.yang
public/release/models/bgp/openconfig-bgp-types.yang
public/release/models/interfaces/openconfig-if-aggregate.yang
public/release/models/interfaces/openconfig-if-ethernet.yang
public/release/models/interfaces/openconfig-if-ethernet-ext.yang
public/release/models/interfaces/openconfig-if-ip-ext.yang
public/release/models/interfaces/openconfig-if-ip.yang
public/release/models/interfaces/openconfig-if-sdn-ext.yang
public/release/models/interfaces/openconfig-interfaces.yang
public/release/models/isis/openconfig-isis.yang
public/release/models/lacp/openconfig-lacp.yang
public/release/models/lldp/openconfig-lldp-types.yang
public/release/models/lldp/openconfig-lldp.yang
public/release/models/local-routing/openconfig-local-routing.yang
public/release/models/mpls/openconfig-mpls-types.yang
public/release/models/multicast/openconfig-pim.yang
public/release/models/network-instance/openconfig-network-instance.yang
public/release/models/openconfig-extensions.yang
public/release/models/optical-transport/openconfig-terminal-device.yang
public/release/models/optical-transport/openconfig-transport-types.yang
public/release/models/ospf/openconfig-ospfv2.yang
public/release/models/p4rt/openconfig-p4rt.yang
public/release/models/platform/openconfig-platform-cpu.yang
public/release/models/platform/openconfig-platform-ext.yang
public/release/models/platform/openconfig-platform-fan.yang
public/release/models/platform/openconfig-platform-integrated-circuit.yang
public/release/models/platform/openconfig-platform-software.yang
public/release/models/platform/openconfig-platform-transceiver.yang
public/release/models/platform/openconfig-platform.yang
public/release/models/policy-forwarding/openconfig-policy-forwarding.yang
public/release/models/policy/openconfig-policy-types.yang
public/release/models/qos/openconfig-qos-elements.yang
public/release/models/qos/openconfig-qos-interfaces.yang
public/release/models/qos/openconfig-qos-types.yang
public/release/models/qos/openconfig-qos.yang
public/release/models/rib/openconfig-rib-bgp.yang
public/release/models/sampling/openconfig-sampling-sflow.yang
public/release/models/segment-routing/openconfig-segment-routing-types.yang
public/release/models/system/openconfig-system.yang
public/release/models/types/openconfig-inet-types.yang
public/release/models/types/openconfig-types.yang
public/release/models/types/openconfig-yang-types.yang
public/release/models/vlan/openconfig-vlan.yang
public/third_party/ietf/iana-if-type.yang
public/third_party/ietf/ietf-inet-types.yang
public/third_party/ietf/ietf-interfaces.yang
public/third_party/ietf/ietf-yang-types.yang
"
go install github.com/openconfig/ygnmi/app/[email protected] \
&& go install golang.org/x/tools/cmd/[email protected] \
&& ygnmi generator \
--trim_module_prefix=openconfig \
--exclude_modules="${EXCLUDE_MODULES}" \
--base_package_path=github.com/open-traffic-generator/conformance/helpers/dut/gnmi \
--output_dir=../helpers/dut/gnmi \
--paths=public/release/models/...,public/third_party/ietf/... \
--ignore_deviate_notsupported \
${YANG_FILES} \
&& cd .. \
&& find helpers/dut/gnmi -name "*.go" -exec goimports -w {} + \
&& find helpers/dut/gnmi -name "*.go" -exec gofmt -w -s {} +
}
wait_for_sock() {
TIMEOUT_SECONDS=30
if [ ! -z "${3}" ]
then
TIMEOUT_SECONDS=${3}
fi
echo "Waiting for ${1}:${2} to be ready (timeout=${TIMEOUT_SECONDS}s)..."
elapsed=0
TIMEOUT_SECONDS=$(($TIMEOUT_SECONDS * 10))
while true
do
nc -z -v ${1} ${2} && return 0
elapsed=$(($elapsed+1))
# echo "Timeout: $TIMEOUT_SECONDS"
# echo "elapsed time: $elapsed"
if [ $elapsed -gt ${TIMEOUT_SECONDS} ]
then
echo "${1}:${2} to be ready after ${TIMEOUT_SECONDS}"
exit 1
fi
sleep 0.1
done
}
create_ixia_c_b2b_dp() {
echo "Setting up back-to-back with DP-only distribution of ixia-c ..."
docker ps -a
create_veth_pair ${VETH_A} ${VETH_Z} \
&& docker run --net=host -d \
--name=keng-controller \
$(keng_controller_img) \
--accept-eula \
--trace \
--disable-app-usage-reporter \
&& docker run --net=host --privileged -d \
--name=ixia-c-traffic-engine-${VETH_A} \
-e OPT_LISTEN_PORT="5555" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_A}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
$(ixia_c_traffic_engine_img) \
&& docker run --net=host --privileged -d \
--name=ixia-c-traffic-engine-${VETH_Z} \
-e OPT_LISTEN_PORT="5556" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_Z}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
$(ixia_c_traffic_engine_img) \
&& docker ps -a \
&& gen_controller_config_b2b_dp \
&& gen_config_b2b_dp \
&& echo "Successfully deployed !"
}
rm_ixia_c_b2b_dp() {
echo "Tearing down back-to-back with DP-only distribution of ixia-c ..."
docker stop keng-controller && docker rm keng-controller
docker stop ixia-c-traffic-engine-${VETH_A}
docker rm ixia-c-traffic-engine-${VETH_A}
docker stop ixia-c-traffic-engine-${VETH_Z}
docker rm ixia-c-traffic-engine-${VETH_Z}
docker ps -a
rm_veth_pair ${VETH_A} ${VETH_Z}
}
create_ixia_c_b2b_cpdp() {
docker ps -a
if [ "${1}" = "ipv6" ]
then
ipv6_enable_docker
fi
echo "Setting up back-to-back with CP/DP distribution of ixia-c ..."
login_ghcr
if [ "${LICENSING}" = "true" ]
then
docker run -d \
--name=keng-controller \
--publish 0.0.0.0:8443:8443 \
--publish 0.0.0.0:40051:40051 \
$(keng_controller_img) \
--accept-eula \
--trace \
--disable-app-usage-reporter \
--license-servers localhost
else
docker run -d \
--name=keng-controller \
--publish 0.0.0.0:8443:8443 \
--publish 0.0.0.0:40051:40051 \
$(keng_controller_img) \
--accept-eula \
--trace \
--disable-app-usage-reporter
fi
docker run --privileged -d \
--name=ixia-c-traffic-engine-${VETH_A} \
-e OPT_LISTEN_PORT="5555" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_A}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e WAIT_FOR_IFACE="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
$(ixia_c_traffic_engine_img) \
&& docker run --privileged -d \
--net=container:ixia-c-traffic-engine-${VETH_A} \
--name=ixia-c-protocol-engine-${VETH_A} \
-e INTF_LIST="${VETH_A}" \
$(ixia_c_protocol_engine_img) \
&& docker run --privileged -d \
--name=ixia-c-traffic-engine-${VETH_Z} \
-e OPT_LISTEN_PORT="5555" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_Z}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e WAIT_FOR_IFACE="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
$(ixia_c_traffic_engine_img) \
&& docker run --privileged -d \
--net=container:ixia-c-traffic-engine-${VETH_Z} \
--name=ixia-c-protocol-engine-${VETH_Z} \
-e INTF_LIST="${VETH_Z}" \
$(ixia_c_protocol_engine_img) \
&& docker ps -a \
&& create_veth_pair ${VETH_A} ${VETH_Z} \
&& push_ifc_to_container ${VETH_A} ixia-c-traffic-engine-${VETH_A} \
&& push_ifc_to_container ${VETH_Z} ixia-c-traffic-engine-${VETH_Z} \
&& gen_controller_config_b2b_cpdp $1 \
&& gen_config_b2b_cpdp $1 \
&& docker ps -a \
&& echo "Successfully deployed !"
}
rm_ixia_c_b2b_cpdp() {
docker ps -a
echo "Tearing down back-to-back with CP/DP distribution of ixia-c ..."
docker stop keng-controller && docker rm keng-controller
docker stop ixia-c-traffic-engine-${VETH_A}
docker stop ixia-c-protocol-engine-${VETH_A}
docker rm ixia-c-traffic-engine-${VETH_A}
docker rm ixia-c-protocol-engine-${VETH_A}
docker stop ixia-c-traffic-engine-${VETH_Z}
docker stop ixia-c-protocol-engine-${VETH_Z}
docker rm ixia-c-traffic-engine-${VETH_Z}
docker rm ixia-c-protocol-engine-${VETH_Z}
docker ps -a
}
create_ixia_c_b2b_lag() {
docker ps -a
echo "Setting up back-to-back LAG with CP/DP distribution of ixia-c ..."
login_ghcr
if [ "${LICENSING}" = "true" ]
then
docker run -d \
--name=keng-controller \
--publish 0.0.0.0:8443:8443 \
--publish 0.0.0.0:40051:40051 \
$(keng_controller_img) \
--accept-eula \
--trace \
--disable-app-usage-reporter \
--license-servers localhost
else
docker run -d \
--name=keng-controller \
--publish 0.0.0.0:8443:8443 \
--publish 0.0.0.0:40051:40051 \
$(keng_controller_img) \
--accept-eula \
--trace \
--disable-app-usage-reporter
fi
docker run --privileged -d \
--name=ixia-c-traffic-engine-${VETH_A} \
-e OPT_LISTEN_PORT="5555" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_A} virtual@af_packet,${VETH_B} virtual@af_packet,${VETH_C}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e WAIT_FOR_IFACE="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
-e OPT_MEMORY="1024" \
$(ixia_c_traffic_engine_img) \
&& docker run --privileged -d \
--net=container:ixia-c-traffic-engine-${VETH_A} \
--name=ixia-c-protocol-engine-${VETH_A} \
-e INTF_LIST="${VETH_A},${VETH_B},${VETH_C}" \
$(ixia_c_protocol_engine_img) \
&& docker run --privileged -d \
--name=ixia-c-traffic-engine-${VETH_Z} \
-e OPT_LISTEN_PORT="5555" \
-e ARG_IFACE_LIST="virtual@af_packet,${VETH_Z} virtual@af_packet,${VETH_Y} virtual@af_packet,${VETH_X}" \
-e OPT_NO_HUGEPAGES="Yes" \
-e OPT_NO_PINNING="Yes" \
-e WAIT_FOR_IFACE="Yes" \
-e OPT_ADAPTIVE_CPU_USAGE="Yes" \
-e OPT_MEMORY="1024" \
$(ixia_c_traffic_engine_img) \
&& docker run --privileged -d \
--net=container:ixia-c-traffic-engine-${VETH_Z} \
--name=ixia-c-protocol-engine-${VETH_Z} \
-e INTF_LIST="${VETH_Z},${VETH_Y},${VETH_X}" \
$(ixia_c_protocol_engine_img) \
&& docker ps -a \
&& create_veth_pair ${VETH_A} ${VETH_Z} \
&& create_veth_pair ${VETH_B} ${VETH_Y} \
&& create_veth_pair ${VETH_C} ${VETH_X} \
&& push_ifc_to_container ${VETH_A} ixia-c-traffic-engine-${VETH_A} \
&& push_ifc_to_container ${VETH_Z} ixia-c-traffic-engine-${VETH_Z} \
&& push_ifc_to_container ${VETH_B} ixia-c-traffic-engine-${VETH_A} \
&& push_ifc_to_container ${VETH_Y} ixia-c-traffic-engine-${VETH_Z} \
&& push_ifc_to_container ${VETH_C} ixia-c-traffic-engine-${VETH_A} \
&& push_ifc_to_container ${VETH_X} ixia-c-traffic-engine-${VETH_Z} \
&& gen_controller_config_b2b_lag \
&& gen_config_b2b_lag \
&& docker ps -a \
&& echo "Successfully deployed !"
}
sudo_docker() {
groups | grep docker > /dev/null 2>&1 && return
sudo groupadd docker
sudo usermod -aG docker $USER
sudo docker version
echo "Please logout, login again and re-execute previous command"
exit 0
}
get_kind() {
which kind > /dev/null 2>&1 && return
echo "Installing kind ${KIND_VERSION} ..."
go install sigs.k8s.io/kind@${KIND_VERSION}
}
kind_cluster_exists() {
kind get clusters | grep kind > /dev/null 2>&1
}
kind_create_cluster() {
kind_cluster_exists && return
echo "Creating kind cluster ..."
kind create cluster --config=deployments/k8s/kind.yaml --wait ${TIMEOUT_SECONDS}s
}
kind_get_kubectl() {
echo "Copying kubectl from kind cluster to host ..."
rm -rf kubectl
docker cp kind-control-plane:/usr/bin/kubectl ./ \
&& sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl \
&& sudo cp -r $HOME/.kube /root/ \
&& rm -rf kubectl
}
setup_kind_cluster() {
echo "Setting up kind cluster ..."
get_kind \
&& kind_create_cluster \
&& kind_get_kubectl
}
mk_metallb_config() {
prefix=$(docker network inspect -f '{{.IPAM.Config}}' kind | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" | tail -n 1)
yml="apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: kne-pool
namespace: metallb-system
spec:
addresses:
- ${prefix}.100 - ${prefix}.250
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: kne-l2-adv
namespace: metallb-system
spec:
ipAddressPools:
- kne-pool
"
echo "$yml" | sed "s/^ //g" | tee deployments/k8s/metallb.yaml > /dev/null
}
get_metallb() {
echo "Setting up metallb ..."
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/${METALLB_VERSION}/config/manifests/metallb-native.yaml \
&& wait_for_pods metallb-system \
&& mk_metallb_config \
&& echo "Applying metallb config map for exposing internal services via public IP addresses ..." \
&& cat deployments/k8s/metallb.yaml \
&& kubectl apply -f deployments/k8s/metallb.yaml
}
get_meshnet() {
echo "Installing meshnet-cni (${MESHNET_COMMIT}) ..."
rm -rf deployments/k8s/meshnet-cni
oldpwd=${PWD}
cd deployments/k8s
git clone https://github.com/networkop/meshnet-cni && cd meshnet-cni && git checkout ${MESHNET_COMMIT} \
&& cat manifests/base/daemonset.yaml | sed "s#image: networkop/meshnet:latest#image: ${MESHNET_IMAGE}#g" | tee manifests/base/daemonset.yaml.patched > /dev/null \
&& mv manifests/base/daemonset.yaml.patched manifests/base/daemonset.yaml \
&& kubectl apply -k manifests/base \
&& wait_for_pods meshnet \
&& cd ${oldpwd}
}
get_keng_operator() {
echo "Installing keng-operator ${KENG_OPERATOR_YAML} ..."
load_image_to_kind $(keng_operator_image) \
&& kubectl apply -f ${KENG_OPERATOR_YAML} \
&& wait_for_pods ixiatg-op-system
}
rm_keng_operator() {
echo "Removing keng-operator ${KENG_OPERATOR_YAML} ..."
kubectl delete -f ${KENG_OPERATOR_YAML} \
&& wait_for_no_namespace ixiatg-op-system
}
get_nokia_srl_operator() {
echo "Installing nokia srl operator ${NOKIA_SRL_OPERATOR_YAML} ..."
load_image_to_kind $(nokia_srl_operator_image) "local" \
&& kubectl apply -k ${NOKIA_SRL_OPERATOR_YAML} \
&& wait_for_pods srlinux-controller
}
rm_nokia_srl_operator() {
echo "Removing nokia srl operator ${NOKIA_SRL_OPERATOR_YAML} ..."
kubectl delete -k ${NOKIA_SRL_OPERATOR_YAML} \
&& wait_for_no_namespace srlinux-controller
}
get_arista_ceos_operator() {
echo "Installing arista ceos operator ${ARISTA_CEOS_OPERATOR_YAML} ..."
load_image_to_kind $(arista_ceos_operator_image) "local" \
&& kubectl apply -k ${ARISTA_CEOS_OPERATOR_YAML} \
&& wait_for_pods arista-ceoslab-operator-system
}
rm_arista_ceos_operator() {
echo "Removing arista ceos operator ${ARISTA_CEOS_OPERATOR_YAML} ..."
kubectl delete -k ${ARISTA_CEOS_OPERATOR_YAML} \
&& wait_for_no_namespace arista-ceoslab-operator-system
}
get_kne() {
which kne > /dev/null 2>&1 && return
echo "Installing KNE ${KNE_VERSION} ..."
CGO_ENBLED=0 go install github.com/openconfig/kne/kne_cli@${KNE_VERSION} \
&& mv $(which kne_cli) $(dirname $(which kne_cli))/kne
}
get_kubemod() {
return
kubectl label namespace kube-system admission.kubemod.io/ignore=true --overwrite \
&& kubectl apply -f https://raw.githubusercontent.com/kubemod/kubemod/v0.15.3/bundle.yaml \
&& wait_for_pods kubemod-system
}
setup_k8s_plugins() {
echo "Setting up K8S plugins for ${1} ${2} ..."
case $1 in
kne )
get_metallb \
&& get_meshnet \
&& get_keng_operator \
&& get_kne
;;
* )
get_metallb
;;
esac
case $2 in
nokia )
get_nokia_srl_operator
;;
arista )
get_arista_ceos_operator \
&& load_arista_ceos_image
;;
* )
echo "second argument '${2}' ignored"
;;
esac
}
ixia_c_image_path() {
grep "\"${1}\"" -A 1 $IXIA_C_CONFIG_MAP | grep path | cut -d\" -f4
}
ixia_c_image_tag() {
grep "\"${1}\"" -A 2 $IXIA_C_CONFIG_MAP | grep tag | cut -d\" -f4
}
keng_operator_image() {
curl -kLs ${KENG_OPERATOR_YAML} | grep image | grep operator | tr -s ' ' | cut -d\ -f3
}
nokia_srl_operator_image() {
yml="$(curl -kLs https://raw.githubusercontent.com/srl-labs/srl-controller/v${NOKIA_SRL_OPERATOR_VERSION}/config/manager/kustomization.yaml)"