blob: eb21156c57d1999a592984bf9c5fe26187925998 [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 -n "type network model to test network model (empty to skip)? "
37read model
38echo "Press enter to continue"
39read kk
40if [ -n "$model" ]
41then
42 model="model: '${model}'"
43fi
44#echo _${model}_
45
46#image to load
47imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
48#image to load as an extra disk, can be any
49imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
50#default network to use
51network_eth0=default
52
53
54DIRNAME=`dirname $0`
55
56function del_rubbish(){
57 echo "Press enter to delete the deployed things"
58 read kk
59 [ -n "$DEL_server" ] && ${DIRNAME}/test_openvim.py -f del server $DEL_server
60 [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
61 [ -n "$DEL_flavor" ] && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
62 [ -n "$DEL_image" ] && ${DIRNAME}/test_openvim.py -f del image $DEL_image
63 rm -f kk.out
64}
65
66function proccess_out(){ # action_text field to retrieve
67 if egrep -q "\"error\"" kk.out
68 then
69 echo "failed to" $1
70 cat kk.out
71 del_rubbish
72 exit -1
73 fi
74 if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
75 value=`egrep "$pattern" kk.out `
76 value=${value##* \"}
77 value=${value%\"*}
78 if [[ -z "$value" ]]
79 then
80 echo "not found the field" $2
81 cat kk.out
82 del_rubbish
83 exit -1
84 fi
85}
86
87#proccess_out "insert server tidgen1" '^ "id"'
88#echo $value
89#exit 0
90
91
92
93echo -n "get ${imagePath##*/} image: "
94${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
95proccess_out "get ${imagePath##*/}"
96echo $value
97image1=$value
98
99
100echo -n "get ${imagePath_extra##*/} image: "
101${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
102proccess_out "get ${imagePath_extra##*/}"
103echo $value
104image2=$value
105
106
107echo -n "get ${network_eth0} network: "
108${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
109proccess_out "get ${network_eth0} network"
110echo $value
111network_eth0=$value
112
113
114echo -n "insert flavor: "
115${DIRNAME}/test_openvim.py new flavor '
116---
117flavor:
118 name: 5PTh_8G_2I
119 description: flavor to test openvim
120 extended:
121 processor_ranking: 205
122 numas:
123 - memory: 8
124 paired-threads: 5
125 interfaces:
126 - name: xe0
127 dedicated: "yes"
128 bandwidth: "10 Gbps"
129 vpci: "0000:00:10.0"
130 #mac_address: "10:10:10:10:10:10"
131 - name: xe1
132 dedicated: "yes:sriov"
133 bandwidth: "10 Gbps"
134 vpci: "0000:00:11.0"
135 mac_address: "10:10:10:10:10:11"
136' > kk.out
137proccess_out "insert flavor"
138echo $value
139flavor1=$value
140DEL_flavor="$DEL_flavor $flavor1"
141
142
143echo -n "insert ptp net1: "
144${DIRNAME}/test_openvim.py new network '
145---
146network:
147 name: network-xe0
148 type: ptp
149' > kk.out
150proccess_out "insert network 0"
151echo $value
152network0=$value
153DEL_network="$DEL_network $value"
154
155
156echo -n "insert ptp net2: "
157${DIRNAME}/test_openvim.py new network '
158---
159network:
160 name: network-xe1
161 type: ptp
162' > kk.out
163proccess_out "insert network 1"
164echo $value
165network1=$value
166DEL_network="$DEL_network $value"
167
168
169
170echo -n "insert bridge network net2: "
171${DIRNAME}/test_openvim.py new network '
172---
173network:
174 name: network-net2
175 type: bridge_data
176' > kk.out
177proccess_out "insert network 2"
178echo $value
179network2=$value
180DEL_network="$DEL_network $value"
181
182echo -n "insert test VM 1: "
183${DIRNAME}/test_openvim.py new server "
184---
185server:
186 name: test_VM1
187 descrition: US or tidgen with 1 SRIOV 1 PASSTHROUGH
188 imageRef: '$image1'
189 flavorRef: '$flavor1'
190 networks:
191 - name: mgmt0
192 vpci: '0000:00:0a.0'
193 uuid: ${network_eth0}
194 mac_address: '10:10:10:10:10:12'
195 - name: eth0
196 vpci: '0000:00:0b.0'
197 uuid: '$network2'
198 mac_address: '10:10:10:10:10:13'
199 ${model}
200" > kk.out
201proccess_out "insert test VM 2" '^ "id"'
202echo $value
203server1=$value
204DEL_server="$DEL_server $value"
205
206
207
208echo -n "insert test VM 2: "
209${DIRNAME}/test_openvim.py new server "
210---
211server:
212 name: test_VM2
213 descrition: US or tidgen with direct network attach
214 imageRef: '$image1'
215 flavorRef: '$flavor1'
216 extended:
217 processor_ranking: 205
218 numas:
219 - memory: 8
220 threads: 10
221 interfaces:
222 - name: xe0
223 dedicated: 'yes'
224 bandwidth: '10 Gbps'
225 vpci: '0000:00:10.0'
226 #mac_address: '10:10:10:10:aa:10'
227 uuid: '$network0'
228 - name: xe1
229 dedicated: 'no'
230 bandwidth: '7 Gbps'
231 vpci: '0000:00:11.0'
232 mac_address: '10:10:10:10:aa:11'
233 uuid: '$network1'
234 devices:
235 - type: disk
236 imageRef: '$image2'
237 networks:
238 - name: mgmt0
239 vpci: '0000:00:0a.0'
240 uuid: ${network_eth0}
241 mac_address: '10:10:10:10:aa:12'
242 - name: eth0
243 vpci: '0000:00:0b.0'
244 uuid: '$network2'
245 mac_address: '10:10:10:10:aa:13'
246 ${model}
247" > kk.out
248proccess_out "insert test VM 2" '^ "id"'
249echo $value
250server2=$value
251DEL_server="$DEL_server $value"
252
253echo -n "get xe0 iface uuid from tidgen1: "
254${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0" ports > kk.out
255proccess_out "get xe0 uuid port from tidgen1"
256echo $value
257iface_xe0=$value
258
259
260echo -n "get xe1 iface uuid from tidgen1: "
261${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1" ports > kk.out
262proccess_out "get xe1 uuid port from tidgen1"
263echo $value
264iface_xe1=$value
265
266
267echo -n "attach xe0 from tidgen1 to network "
268${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
269proccess_out "attach xe0 from tidgen1 to network"
270echo "ok"
271
272
273echo -n "attach xe1 from tidgen1 to network "
274${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
275proccess_out "attach xe1 from tidgen1 to network"
276echo "ok"
277
278
279echo
280echo finish. Check connections!!
281echo click return to delete all deployed things
282echo
283
284del_rubbish
285exit 0
286