Initial openvim v0.4.6 upload
[osm/openvim.git] / test / 2VM_2I_2VLAN.sh
1 #!/bin/bash
2
3 ##
4 # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
5 # This file is part of openmano
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 "Press enter to continue"
37 read kk
38
39 #image to load
40 imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
41 #image to load as an extra disk, can be any
42 imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
43 #default network to use
44 network_eth0=default
45
46
47 DIRNAME=`dirname $0`
48
49 function 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
59 function 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
86 echo -n "get ${imagePath##*/} image: "
87 ${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
88 proccess_out "get ${imagePath##*/}"
89 echo $value
90 image1=$value
91
92
93 echo -n "get ${imagePath_extra##*/} image: "
94 ${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
95 proccess_out "get ${imagePath_extra##*/}"
96 echo $value
97 image2=$value
98
99
100 echo -n "get ${network_eth0} network: "
101 ${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
102 proccess_out "get ${network_eth0} network"
103 echo $value
104 network_eth0=$value
105
106
107 echo -n "insert flavor: "
108 ${DIRNAME}/test_openvim.py new flavor '
109 ---
110 flavor:
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
130 proccess_out "insert flavor"
131 echo $value
132 flavor1=$value
133 DEL_flavor="$DEL_flavor $flavor1"
134
135
136 echo -n "insert ptp net1: "
137 ${DIRNAME}/test_openvim.py new network '
138 ---
139 network:
140 name: network-xe0
141 type: ptp
142 ' > kk.out
143 proccess_out "insert network 0"
144 echo $value
145 network0=$value
146 DEL_network="$DEL_network $value"
147
148
149 echo -n "insert ptp net2: "
150 ${DIRNAME}/test_openvim.py new network '
151 ---
152 network:
153 name: network-xe1
154 type: ptp
155 ' > kk.out
156 proccess_out "insert network 1"
157 echo $value
158 network1=$value
159 DEL_network="$DEL_network $value"
160
161
162
163 echo -n "insert bridge network net2: "
164 ${DIRNAME}/test_openvim.py new network '
165 ---
166 network:
167 name: network-net2
168 type: bridge_data
169 ' > kk.out
170 proccess_out "insert network 2"
171 echo $value
172 network2=$value
173 DEL_network="$DEL_network $value"
174
175 echo -n "insert test VM 1: "
176 ${DIRNAME}/test_openvim.py new server "
177 ---
178 server:
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
193 proccess_out "insert test VM 2" '^ "id"'
194 echo $value
195 server1=$value
196 DEL_server="$DEL_server $value"
197
198
199
200 echo -n "insert test VM 2: "
201 ${DIRNAME}/test_openvim.py new server "
202 ---
203 server:
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
239 proccess_out "insert test VM 2" '^ "id"'
240 echo $value
241 server2=$value
242 DEL_server="$DEL_server $value"
243
244 echo -n "get xe0 iface uuid from tidgen1: "
245 ${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe0" ports > kk.out
246 proccess_out "get xe0 uuid port from tidgen1"
247 echo $value
248 iface_xe0=$value
249
250
251 echo -n "get xe1 iface uuid from tidgen1: "
252 ${DIRNAME}/test_openvim.py -F "device_id=${server1}&name=xe1" ports > kk.out
253 proccess_out "get xe1 uuid port from tidgen1"
254 echo $value
255 iface_xe1=$value
256
257
258 echo -n "attach xe0 from tidgen1 to network "
259 ${DIRNAME}/test_openvim.py -f edit ports $iface_xe0 "network_id: $network0" > kk.out
260 proccess_out "attach xe0 from tidgen1 to network"
261 echo "ok"
262
263
264 echo -n "attach xe1 from tidgen1 to network "
265 ${DIRNAME}/test_openvim.py -f edit ports $iface_xe1 "network_id: $network1" > kk.out
266 proccess_out "attach xe1 from tidgen1 to network"
267 echo "ok"
268
269
270 echo
271 echo finsish. Check connections!!
272 echo
273
274 del_rubbish
275 exit 0
276