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