| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | ## |
| 3 | # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. |
| tierno | 9a61c6b | 2016-09-08 10:57:02 +0200 | [diff] [blame] | 4 | # This file is part of openvim |
| tierno | f7aa8c4 | 2016-09-06 16:43:04 +0200 | [diff] [blame] | 5 | # 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 | |
| 30 | echo " Creates 1 flavor, 3 nets, 2 VMs (US) |
| 31 | WITHOUT huge pages, nor NUMA assigment |
| 32 | network attach after creation" |
| 33 | echo |
| 34 | echo "Press enter to continue" |
| 35 | read kk |
| 36 | |
| 37 | #image to load |
| 38 | imagePath=/mnt/powervault/virtualization/vnfs/os/US1404.qcow2 |
| 39 | #image to load as an extra disk, can be any |
| 40 | imagePath_extra=/mnt/powervault/virtualization/vnfs/os/US1404user.qcow2 |
| 41 | #default network to use |
| 42 | network_eth0=default |
| 43 | |
| 44 | |
| 45 | DIRNAME=`dirname $0` |
| 46 | |
| 47 | function 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 | |
| 57 | function 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 | |
| 84 | echo -n "get ${imagePath##*/} image: " |
| 85 | ${DIRNAME}/test_openvim.py -F"path=$imagePath" images > kk.out |
| 86 | proccess_out "get ${imagePath##*/}" |
| 87 | echo $value |
| 88 | image1=$value |
| 89 | |
| 90 | |
| 91 | echo -n "get ${imagePath_extra##*/} image: " |
| 92 | ${DIRNAME}/test_openvim.py -F"path=$imagePath_extra" images > kk.out |
| 93 | proccess_out "get ${imagePath_extra##*/}" |
| 94 | echo $value |
| 95 | image2=$value |
| 96 | |
| 97 | |
| 98 | echo -n "get ${network_eth0} network: " |
| 99 | ${DIRNAME}/test_openvim.py -F"name=$network_eth0" network > kk.out |
| 100 | proccess_out "get ${network_eth0} network" |
| 101 | echo $value |
| 102 | network_eth0=$value |
| 103 | |
| 104 | |
| 105 | echo -n "insert flavor: " |
| 106 | ${DIRNAME}/test_openvim.py new flavor ' |
| 107 | --- |
| 108 | flavor: |
| 109 | name: CloudVM |
| 110 | description: normal cloud image with 1G, 1core |
| 111 | ram: 1024 |
| 112 | vcpus: 1 |
| 113 | ' > kk.out |
| 114 | proccess_out "insert flavor" |
| 115 | echo $value |
| 116 | flavor1=$value |
| 117 | DEL_flavor="$DEL_flavor $flavor1" |
| 118 | |
| 119 | |
| 120 | echo |
| 121 | echo "Press enter to continue" |
| 122 | read kk |
| 123 | |
| 124 | echo -n "insert bridge network net2: " |
| 125 | ${DIRNAME}/test_openvim.py new network ' |
| 126 | --- |
| 127 | network: |
| 128 | name: network-bridge |
| 129 | type: bridge_data |
| 130 | ' > kk.out |
| 131 | proccess_out "insert network 2" |
| 132 | echo $value |
| 133 | network2=$value |
| 134 | DEL_network="$DEL_network $value" |
| 135 | |
| 136 | echo -n "insert test VM 1: " |
| 137 | ${DIRNAME}/test_openvim.py new server " |
| 138 | --- |
| 139 | server: |
| 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 |
| 154 | proccess_out "insert test VM 2" '^ "id"' |
| 155 | echo $value |
| 156 | server1=$value |
| 157 | DEL_server="$DEL_server $value" |
| 158 | |
| 159 | |
| 160 | echo |
| 161 | echo "Press enter to continue" |
| 162 | read kk |
| 163 | |
| 164 | echo -n "insert test VM 2: " |
| 165 | ${DIRNAME}/test_openvim.py new server " |
| 166 | --- |
| 167 | server: |
| 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 |
| 188 | proccess_out "insert test VM 2" '^ "id"' |
| 189 | echo $value |
| 190 | server2=$value |
| 191 | DEL_server="$DEL_server $value" |
| 192 | |
| 193 | echo |
| 194 | echo finsish. Check connections!! |
| 195 | echo |
| 196 | |
| 197 | del_rubbish |
| 198 | exit 0 |
| 199 | |