forked from sonic-net/sonic-mgmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbed_integrate_traffic_generator.yml
83 lines (72 loc) · 2.81 KB
/
testbed_integrate_traffic_generator.yml
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
- name: Start Trex traffic generator container
block:
- name: Pull trex image
command: docker pull trexcisco/trex
become: yes
- name: Stop existence trex container
command: "{{ item }}"
with_items:
- docker stop trex
- docker rm trex
become: yes
ignore_errors: true
- name: Start trex traffic generator container
command: docker run --name trex -it -d --privileged --cap-add=ALL trexcisco/trex
become: yes
- name: Untar trex client
command: docker exec trex bash -c "cd /var/trex/v2.41/ ; tar zxf trex_client_v2.41.tar.gz"
become: yes
- name: Prepare trex runtime files
command: "{{ item }}"
with_items:
- docker exec trex bash -c "cd /var/trex/v2.41/ ; tar zxf trex_client_v2.41.tar.gz"
- docker cp {{inventory_dir}}/../tests/wan/trex/imix.py trex:/var/trex/v2.41/trex_client/stl/profiles/
- docker cp {{inventory_dir}}/../tests/wan/trex/trex_cfg.yaml trex:/etc/
- docker cp {{inventory_dir}}/../tests/wan/trex/stl_path.py trex:/var/trex/v2.41/trex_client/stl/examples
- docker cp {{inventory_dir}}/../tests/wan/trex/stl_imix.py trex:/var/trex/v2.41/trex_client/stl/examples
delegate_to: localhost
become: yes
- name: Remove VM interface from ovs bridge
command: "{{ item }}"
with_items:
- ovs-vsctl del-port br-VM0100-3 VM0100-t3
- ovs-vsctl del-port br-VM0101-3 VM0101-t3
ignore_errors: yes
become: yes
- name: Remove trex bridge
command: "{{ item }}"
with_items:
- ifconfig trex-in down
- ifconfig trex-out down
- brctl delbr trex-in
- brctl delbr trex-out
ignore_errors: yes
become: yes
- name: Create trex network
command: "{{ item }}"
with_items:
- brctl addbr trex-in
- ifconfig trex-in up
- brctl addbr trex-out
- ifconfig trex-out up
- ip link add trex-intf-1 type veth peer trex-intf-br-1
- ip link add trex-intf-2 type veth peer trex-intf-br-2
- ifconfig trex-intf-br-1 up
- ifconfig trex-intf-br-2 up
- brctl addif trex-in trex-intf-br-1
- brctl addif trex-in VM0100-t3
- brctl addif trex-out trex-intf-br-2
- brctl addif trex-out VM0101-t3
ignore_errors: yes
become: yes
- name: Add interface to Trex container
shell: |
docker inspect trex|grep -w "Pid"| awk '{print $2}'|rev|cut -c2-|rev|xargs ip link set trex-intf-1 netns
docker inspect trex|grep -w "Pid"| awk '{print $2}'|rev|cut -c2-|rev|xargs ip link set trex-intf-2 netns
docker exec trex bash -c "ifconfig trex-intf-1 202.1.1.2/24 up"
docker exec trex bash -c "ifconfig trex-intf-2 202.2.1.2/24 up"
ignore_errors: yes
become: yes
- name: Start Trex traffic generator server
command: docker exec trex bash -c "cd /var/trex/v2.41/ ; ./t-rex-64 -i >/dev/null &"
become: yes