blob: ed95730f0833fcd673b3ae982823b6d2ce44daae [file] [log] [blame]
tiernof7aa8c42016-09-06 16:43:04 +02001#!/bin/bash
2
3##
4# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
tierno9a61c6b2016-09-08 10:57:02 +02005# This file is part of openvim
tiernof7aa8c42016-09-06 16:43:04 +02006# All Rights Reserved.
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License. You may obtain
10# a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17# License for the specific language governing permissions and limitations
18# under the License.
19#
20# For those usages not covered by the Apache License, Version 2.0 please
21# contact with: nfvlabs@tid.es
22##
23
24#
25#author Alfonso Tierno
26#
27#script to test openvim with the creation of flavors and interfaces
28#using images already inserted
29#
30
31echo " Creates 1 flavor, 3 nets, 2 VMs (US)
32 Interfaces: 2 sriov, 1 passthrough, 1 sriov dedicated
33 Test mac address allocation, 1 VM with direct network attach,
34 another VM with network attach after creation"
35echo
36echo "Press enter to continue"
37read kk
38
39#image to load
40imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
41#image to load as an extra disk, can be any
42imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
43#default network to use
44network_eth0=default
45
46
47DIRNAME=`dirname $0`
48
49function del_rubbish(){
50 echo "Press enter to delete the deployed things"
51 read kk
52 [ -n "$DEL_server" ] && ${DIRNAME}/test_openvim.py -f del server $DEL_server
53 [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
54 [ -n "$DEL_flavor" ] && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
55 [ -n "$DEL_image" ] && ${DIRNAME}/test_openvim.py -f del image $DEL_image
56 rm -f kk.out
57}
58
59function proccess_out(){ # action_text field to retrieve
60 if egrep -q "\"error\"" kk.out
61 then
62 echo "failed to" $1
63 cat kk.out
64 del_rubbish
65 exit -1
66 fi
67 if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
68 value=`egrep "$pattern" kk.out `
69 value=${value##* \"}
70 value=${value%\"*}
71 if [[ -z "$value" ]]
72 then
73 echo "not found the field" $2
74 cat kk.out
75 del_rubbish
76 exit -1
77 fi
78}
79
80#proccess_out "insert server tidgen1" '^ "id"'
81#echo $value
82#exit 0
83
84
85
86echo -n "get ${imagePath##*/} image: "
87${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
88proccess_out "get ${imagePath##*/}"
89echo $value
90image1=$value
91
92
93echo -n "get ${imagePath_extra##*/} image: "
94${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
95proccess_out "get ${imagePath_extra##*/}"
96echo $value
97image2=$value
98
99
100echo -n "get ${network_eth0} network: "
101${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
102proccess_out "get ${network_eth0} network"
103echo $value
104network_eth0=$value
105
106
107echo -n "insert flavor: "
108${DIRNAME}/test_openvim.py new flavor '
109---
110flavor:
111 name: 5PTh_8G_2I
112 description: flavor to test openvim
113 extended:
114 processor_ranking: 205
115 numas:
116 - memory: 8
117 paired-threads: 5
118 interfaces:
119 - name: xe0
120 dedicated: "yes"
121 bandwidth: "10 Gbps"
122 vpci: "0000:00:10.0"
123 #mac_address: "10:10:10:10:10:10"
124 - name: xe1
125 dedicated: "no"
126 bandwidth: "10 Gbps"
127 vpci: "0000:00:11.0"
128 mac_address: "10:10:10:10:10:11"
129' > kk.out
130proccess_out "insert flavor"
131echo $value
132flavor1=$value
133DEL_flavor="$DEL_flavor $flavor1"
134
135
136echo -n "insert ptp net1: "
137${DIRNAME}/test_openvim.py new network '
138---
139network:
140 name: network-xe0
141 type: ptp
142' > kk.out
143proccess_out "insert network 0"
144echo $value
145network0=$value
146DEL_network="$DEL_network $value"
147
148
149echo -n "insert ptp net2: "
150${DIRNAME}/test_openvim.py new network '
151---
152network:
153 name: network-xe1
154 type: ptp
155' > kk.out
156proccess_out "insert network 1"
157echo $value
158network1=$value
159DEL_network="$DEL_network $value"
160
161
162
163echo -n "insert bridge network net2: "
164${DIRNAME}/test_openvim.py new network '
165---
166network:
167 name: network-net2
168 type: bridge_data
169' > kk.out
170proccess_out "insert network 2"
171echo $value
172network2=$value
173DEL_network="$DEL_network $value"
174
175echo -n "insert test VM 1: "
176${DIRNAME}/test_openvim.py new server "
177---
178server:
179 name: test_VM1
180 descrition: US or tidgen with 1 SRIOV 1 PASSTHROUGH
181 imageRef: '$image1'
182 flavorRef: '$flavor1'
183 networks:
184 - name: mgmt0
185 vpci: '0000:00:0a.0'
186 uuid: ${network_eth0}
187 mac_address: '10:10:10:10:10:12'
188 - name: eth0
189 vpci: '0000:00:0b.0'
190 uuid: '$network2'
191 mac_address: '10:10:10:10:10:13'
192" > kk.out
193proccess_out "insert test VM 2" '^ "id"'
194echo $value
195server1=$value
196DEL_server="$DEL_server $value"
197
198
199
200echo -n "insert test VM 2: "
201${DIRNAME}/test_openvim.py new server "
202---
203server:
204 name: test_VM2
205 descrition: US or tidgen with direct network attach
206 imageRef: '$image1'
207 flavorRef: '$flavor1'
208 networks:
209 - name: mgmt0
210 vpci: '0000:00:0a.0'
211 uuid: ${network_eth0}
212 mac_address: '10:10:10:10:aa:12'
213 - name: eth0
214 vpci: '0000:00:0b.0'
215 uuid: '$network2'
216 mac_address: '10:10:10:10:aa:13'
217 extended:
218 processor_ranking: 205
219 numas:
220 - memory: 8
221 threads: 10
222 interfaces:
223 - name: xe0
224 dedicated: 'yes'
225 bandwidth: '10 Gbps'
226 vpci: '0000:00:10.0'
227 #mac_address: '10:10:10:10:aa:10'
228 uuid: '$network0'
229 - name: xe1
230 dedicated: 'no'
231 bandwidth: '7 Gbps'
232 vpci: '0000:00:11.0'
233 mac_address: '10:10:10:10:aa:11'
234 uuid: '$network1'
235 devices:
236 - type: disk
237 imageRef: '$image2'
238" > kk.out
239proccess_out "insert test VM 2" '^ "id"'
240echo $value
241server2=$value
242DEL_server="$DEL_server $value"
243
244echo -n "get xe0 iface uuid from tidgen1: "
245${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0" ports > kk.out
246proccess_out "get xe0 uuid port from tidgen1"
247echo $value
248iface_xe0=$value
249
250
251echo -n "get xe1 iface uuid from tidgen1: "
252${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1" ports > kk.out
253proccess_out "get xe1 uuid port from tidgen1"
254echo $value
255iface_xe1=$value
256
257
258echo -n "attach xe0 from tidgen1 to network "
259${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
260proccess_out "attach xe0 from tidgen1 to network"
261echo "ok"
262
263
264echo -n "attach xe1 from tidgen1 to network "
265${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
266proccess_out "attach xe1 from tidgen1 to network"
267echo "ok"
268
269
270echo
271echo finsish. Check connections!!
272echo
273
274del_rubbish
275exit 0
276