Merge "pktgen: speedup unittest, mock time.sleep"
[yardstick.git] / yardstick / vTC / apexlake / heat_templates / vTC_liberty.yaml
1 ##############################################################################
2 # Copyright (c) 2017 user@TRAFCLASS-PACKET1.fuel.local and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 heat_template_version: 2014-10-16
10 description: HOT template to deploy a virtual Traffic Classifier
11
12 parameters:
13   default_net:
14     type: string
15   default_subnet:
16     type: string
17   source_net:
18     type: string
19   source_subnet:
20     type: string
21   destination_net:
22     type: string
23   destination_subnet:
24     type: string
25   timeout:
26     type: number
27     description: Timeout for WaitCondition, depends on your image and environment
28     default: 2000
29
30 resources:
31   wait_condition:
32     type: OS::Heat::WaitCondition
33     properties:
34       handle: {get_resource: wait_handle}
35       count: 1
36       timeout: {get_param: timeout}
37
38   wait_handle:
39     type: OS::Heat::WaitConditionHandle
40
41   ### DEFAULT NETWORK FOR MNGM
42   port_1:
43     type: OS::Neutron::Port
44     properties:
45       network: { get_param: default_net }
46       binding:vnic_type: normal
47       port_security_enabled: true
48       fixed_ips:
49         - subnet: { get_param: default_subnet }
50
51   ### NETWORK FOR RECEIVING TRAFFIC
52   port_2:
53     type: OS::Neutron::Port
54     properties:
55       network: { get_param: source_net }
56       binding:vnic_type: #vnic_type
57       port_security_enabled: false
58       fixed_ips:
59         - subnet: { get_param: source_subnet }
60
61   ### NETWORK FOR SENDING TRAFFIC
62   port_3:
63     type: OS::Neutron::Port
64     properties:
65       network: { get_param: destination_net }
66       binding:vnic_type: #vnic_type
67       port_security_enabled: false
68       fixed_ips:
69         - subnet: { get_param: destination_subnet }
70
71   server:
72     type: OS::Nova::Server
73     properties:
74       name: vTC
75       #key_name: { get_param: key_name }
76       image: ubuntu1404
77       user_data:
78         str_replace:
79           template: |
80             #!/bin/sh
81             # Creation of a user
82             echo "Creating custom user..."
83             useradd clouduser -g admin -s /bin/bash -m
84             echo clouduser:yardstick | chpasswd
85             echo "Enabling ssh password login..."
86             sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
87             service ssh restart
88             sleep 1
89
90             # wake up interfaces
91             ifconfig eth1 up
92             ifconfig eth2 up
93             dhclient eth1
94             dhclient eth2
95             ifconfig 10.254.254.253 up netmask 255.255.255.248
96
97             # Fix Network Confiuration
98             sed -i 's/localhost/localhost vtc/g' /etc/hosts
99             touch /etc/resolvconf/resolv.conf.d/tail
100             #echo 'nameserver 192.168.10.1' > /etc/resolvconf/resolv.conf.d/tail
101             #echo 'nameserver 10.20.0.2' > /etc/resolvconf/resolv.conf.d/tail
102             echo 'nameserver 10.118.32.193' > /etc/resolvconf/resolv.conf.d/tail
103             resolvconf -u
104
105
106             echo 'nameserver 10.118.32.193' > /etc/resolv.conf
107
108
109             # Install vTC Dependencies
110             apt-get update
111             apt-get install -y git build-essential gcc libnuma-dev bison flex byacc libjson0-dev libcurl4-gnutls-dev jq dh-autoreconf libpcap-dev libpulse-dev libtool pkg-config
112             apt-get install -y byacc libtool libcurl4-openssl-dev
113
114             cd /home/clouduser
115
116             # Setup multicast
117             echo mgroup from eth1 group 224.192.16.1 > /etc/smcroute.conf
118             git clone https://github.com/troglobit/smcroute.git
119             cd smcroute
120             git reset --hard c3f5c56
121             sed -i 's/aclocal-1.11/aclocal/g' ./autogen.sh
122             sed -i 's/automake-1.11/automake/g' ./autogen.sh
123             ./autogen.sh
124             ./configure
125             make
126             make install
127             cd ..
128             touch multicast.sh
129             echo "#!/bin/bash" > multicast.sh
130             echo "while [ true ]" >> multicast.sh
131             echo "do" >> multicast.sh
132             echo "  smcroute -k" >> multicast.sh
133             echo "  smcroute -d" >> multicast.sh
134             echo "  sleep 50" >> multicast.sh
135             echo "done" >> multicast.sh
136             chmod +x multicast.sh
137             ./multicast.sh &
138
139             rm resp.json
140             curl -X POST -u "mPkgwvJPsTFS8hYmHk:SDczcrK4cvnkMRWSEchB3ANcWbqFXqPx" https://bitbucket.org/site/oauth2/access_token -d grant_type=refresh_token -d refresh_token=38uFQuhEdPvCTbhc7k >> resp.json
141             access_token=`jq -r '.access_token' resp.json`
142             git clone https://x-token-auth:${access_token}@bitbucket.org/akiskourtis/vtc.git
143             cd vtc
144             git checkout -b stable
145             #Build nDPI library
146             cd nDPI
147             NDPI_DIR=$(pwd)
148             echo $NDPI_DIR
149             NDPI_INCLUDE=$(pwd)/src/include
150             echo $NDPI_INCLUDE
151             ./autogen.sh
152             ./configure
153             make
154             make install
155
156             #Build PF_RING library
157             cd ..
158             cd PF_RING
159             make
160             #Build PF_RING examples, including the modified pfbridge, with nDPI integrated.
161             cd userland/examples/
162             sed -i 's#EXTRA_LIBS =#EXTRA_LIBS='"${NDPI_DIR}"'/src/lib/.libs/libndpi.a -ljson-c#' ./Makefile
163             sed -i 's# -Ithird-party# -Ithird-party/ -I'"$NDPI_INCLUDE"' -I'"$NDPI_DIR"'#' ./Makefile
164             echo $NDPI_DIR
165             make
166             cd ../..
167             cd ..
168             cd ..
169
170             # To use PF_RING driver use the following
171             #sudo rmmod pf_ring
172             #insmod ./vtc/PF_RING/kernel/pf_ring.ko min_num_slots=16384 enable_debug=1 quick_mode=1 enable_tx_capture=0
173             #./vtc/PF_RING/userland/examples/pfbridge -a eth1 -b eth2 &
174             sleep 5
175
176             # To use the Linux kernel driver use the following
177             cd /home/clouduser/
178             sudo nohup ./vtc/nDPI/example/ndpiReader -i eth1 -a eth2 &
179             sleep 5
180
181             curl --data-ascii "{\"classification_rules\":[{\"RuleId\":\"1\",\"ToS\":\"16\"}]}" http://localhost:9999/classifier/classification_rules/224.192.16.1 &
182             wc_notify --data-binary '{"status": "SUCCESS"}'
183           params:
184             wc_notify: { get_attr: ['wait_handle', 'curl_cli'] }
185             #$IP_FAMILY: { get_param: ip_family }
186       flavor: #vtc_flavor
187       networks:
188         - port: { get_resource: port_1 }
189         - port: { get_resource: port_2 }
190         - port: { get_resource: port_3 }
191 outputs: