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