Fixed some typos
[osm/openvim.git] / test / 2VM_2I.sh
1 #!/bin/bash
2
3 ##
4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openvim
6 # 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
31 echo " 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"
35 echo
36 echo -n "type network model to test network model (empty to skip)? "
37 read model
38 echo "Press enter to continue"
39 read kk
40 if [ -n "$model" ]
41 then
42 model="model: '${model}'"
43 fi
44 #echo _${model}_
45
46 #image to load
47 imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
48 #image to load as an extra disk, can be any
49 imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
50 #default network to use
51 network_eth0=default
52
53
54 DIRNAME=`dirname $0`
55
56 function 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
66 function 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
93 echo -n "get ${imagePath##*/} image: "
94 ${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
95 proccess_out "get ${imagePath##*/}"
96 echo $value
97 image1=$value
98
99
100 echo -n "get ${imagePath_extra##*/} image: "
101 ${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
102 proccess_out "get ${imagePath_extra##*/}"
103 echo $value
104 image2=$value
105
106
107 echo -n "get ${network_eth0} network: "
108 ${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
109 proccess_out "get ${network_eth0} network"
110 echo $value
111 network_eth0=$value
112
113
114 echo -n "insert flavor: "
115 ${DIRNAME}/test_openvim.py new flavor '
116 ---
117 flavor:
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
137 proccess_out "insert flavor"
138 echo $value
139 flavor1=$value
140 DEL_flavor="$DEL_flavor $flavor1"
141
142
143 echo -n "insert ptp net1: "
144 ${DIRNAME}/test_openvim.py new network '
145 ---
146 network:
147 name: network-xe0
148 type: ptp
149 ' > kk.out
150 proccess_out "insert network 0"
151 echo $value
152 network0=$value
153 DEL_network="$DEL_network $value"
154
155
156 echo -n "insert ptp net2: "
157 ${DIRNAME}/test_openvim.py new network '
158 ---
159 network:
160 name: network-xe1
161 type: ptp
162 ' > kk.out
163 proccess_out "insert network 1"
164 echo $value
165 network1=$value
166 DEL_network="$DEL_network $value"
167
168
169
170 echo -n "insert bridge network net2: "
171 ${DIRNAME}/test_openvim.py new network '
172 ---
173 network:
174 name: network-net2
175 type: bridge_data
176 ' > kk.out
177 proccess_out "insert network 2"
178 echo $value
179 network2=$value
180 DEL_network="$DEL_network $value"
181
182 echo -n "insert test VM 1: "
183 ${DIRNAME}/test_openvim.py new server "
184 ---
185 server:
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
201 proccess_out "insert test VM 2" '^ "id"'
202 echo $value
203 server1=$value
204 DEL_server="$DEL_server $value"
205
206
207
208 echo -n "insert test VM 2: "
209 ${DIRNAME}/test_openvim.py new server "
210 ---
211 server:
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
248 proccess_out "insert test VM 2" '^ "id"'
249 echo $value
250 server2=$value
251 DEL_server="$DEL_server $value"
252
253 echo -n "get xe0 iface uuid from tidgen1: "
254 ${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0" ports > kk.out
255 proccess_out "get xe0 uuid port from tidgen1"
256 echo $value
257 iface_xe0=$value
258
259
260 echo -n "get xe1 iface uuid from tidgen1: "
261 ${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1" ports > kk.out
262 proccess_out "get xe1 uuid port from tidgen1"
263 echo $value
264 iface_xe1=$value
265
266
267 echo -n "attach xe0 from tidgen1 to network "
268 ${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
269 proccess_out "attach xe0 from tidgen1 to network"
270 echo "ok"
271
272
273 echo -n "attach xe1 from tidgen1 to network "
274 ${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
275 proccess_out "attach xe1 from tidgen1 to network"
276 echo "ok"
277
278
279 echo
280 echo finish. Check connections!!
281 echo click return to delete all deployed things
282 echo
283
284 del_rubbish
285 exit 0
286