blob: a83612fd78905ca0af0a4234c655cfac9e041161 [file] [log] [blame]
tiernof7aa8c42016-09-06 16:43:04 +02001#!/bin/bash
2##
3# Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U.
tierno9a61c6b2016-09-08 10:57:02 +02004# This file is part of openvim
tiernof7aa8c42016-09-06 16:43:04 +02005# All Rights Reserved.
6#
7# Licensed under the Apache License, Version 2.0 (the "License"); you may
8# not use this file except in compliance with the License. You may obtain
9# a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16# License for the specific language governing permissions and limitations
17# under the License.
18#
19# For those usages not covered by the Apache License, Version 2.0 please
20# contact with: nfvlabs@tid.es
21##
22
23#
24#author Alfonso Tierno
25#
26#script to test openvim with the creation of flavors and interfaces
27#in cloud style
28#
29
30echo " Creates 1 flavor, 3 nets, 2 VMs (US)
31 WITHOUT huge pages, nor NUMA assigment
32 network attach after creation"
33echo
34echo "Press enter to continue"
35read kk
36
37#image to load
38imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2
39#image to load as an extra disk, can be any
40imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2
41#default network to use
42network_eth0=default
43
44
45DIRNAME=`dirname $0`
46
47function del_rubbish(){
48 echo "Press enter to delete the deployed things"
49 read kk
50 [ -n "$DEL_server" ] && ${DIRNAME}/test_openvim.py -f del server $DEL_server
51 [ -n "$DEL_network" ] && ${DIRNAME}/test_openvim.py -f del network $DEL_network
52 [ -n "$DEL_flavor" ] && ${DIRNAME}/test_openvim.py -f del flavor $DEL_flavor
53 [ -n "$DEL_image" ] && ${DIRNAME}/test_openvim.py -f del image $DEL_image
54 rm -f kk.out
55}
56
57function proccess_out(){ # action_text field to retrieve
58 if egrep -q "\"error\"" kk.out
59 then
60 echo "failed to" $1
61 cat kk.out
62 del_rubbish
63 exit -1
64 fi
65 if [ -z "$2" ] ; then pattern='"id"' ; else pattern="$2" ; fi
66 value=`egrep "$pattern" kk.out `
67 value=${value##* \"}
68 value=${value%\"*}
69 if [[ -z "$value" ]]
70 then
71 echo "not found the field" $2
72 cat kk.out
73 del_rubbish
74 exit -1
75 fi
76}
77
78#proccess_out "insert server tidgen1" '^ "id"'
79#echo $value
80#exit 0
81
82
83
84echo -n "get ${imagePath##*/} image: "
85${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out
86proccess_out "get ${imagePath##*/}"
87echo $value
88image1=$value
89
90
91echo -n "get ${imagePath_extra##*/} image: "
92${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out
93proccess_out "get ${imagePath_extra##*/}"
94echo $value
95image2=$value
96
97
98echo -n "get ${network_eth0} network: "
99${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out
100proccess_out "get ${network_eth0} network"
101echo $value
102network_eth0=$value
103
104
105echo -n "insert flavor: "
106${DIRNAME}/test_openvim.py new flavor '
107---
108flavor:
109 name: CloudVM
110 description: normal cloud image with 1G, 1core
111 ram: 1024
112 vcpus: 1
113' > kk.out
114proccess_out "insert flavor"
115echo $value
116flavor1=$value
117DEL_flavor="$DEL_flavor $flavor1"
118
119
120echo
121echo "Press enter to continue"
122read kk
123
124echo -n "insert bridge network net2: "
125${DIRNAME}/test_openvim.py new network '
126---
127network:
128 name: network-bridge
129 type: bridge_data
130' > kk.out
131proccess_out "insert network 2"
132echo $value
133network2=$value
134DEL_network="$DEL_network $value"
135
136echo -n "insert test VM 1: "
137${DIRNAME}/test_openvim.py new server "
138---
139server:
140 name: test_VM1
141 descrition: US 1 core
142 imageRef: '$image1'
143 flavorRef: '$flavor1'
144 networks:
145 - name: mgmt0
146 vpci: '0000:00:0a.0'
147 uuid: ${network_eth0}
148 mac_address: '10:10:10:10:10:12'
149 - name: eth0
150 vpci: '0000:00:0b.0'
151 uuid: '$network2'
152 mac_address: '10:10:10:10:10:13'
153" > kk.out
154proccess_out "insert test VM 2" '^ "id"'
155echo $value
156server1=$value
157DEL_server="$DEL_server $value"
158
159
160echo
161echo "Press enter to continue"
162read kk
163
164echo -n "insert test VM 2: "
165${DIRNAME}/test_openvim.py new server "
166---
167server:
168 name: test_VM2
169 descrition: US 1G 1core
170 imageRef: '$image1'
171 flavorRef: '$flavor1'
172 ram: 1024
173 vcpus: 1
174 networks:
175 - name: mgmt0
176 vpci: '0000:00:0a.0'
177 uuid: ${network_eth0}
178 mac_address: '10:10:10:10:aa:12'
179 - name: eth0
180 vpci: '0000:00:0b.0'
181 uuid: '$network2'
182 mac_address: '10:10:10:10:aa:13'
183 extended:
184 devices:
185 - type: disk
186 imageRef: '$image2'
187" > kk.out
188proccess_out "insert test VM 2" '^ "id"'
189echo $value
190server2=$value
191DEL_server="$DEL_server $value"
192
193echo
194echo finsish. Check connections!!
195echo
196
197del_rubbish
198exit 0
199