Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 3 | variables=( |
| 4 | OS_USERNAME |
| 5 | OS_PASSWORD |
| 6 | OS_TENANT_NAME |
| 7 | OS_AUTH_URL |
| 8 | ) |
| 9 | |
| 10 | check_variables () { |
| 11 | for i in $(seq 0 $(( ${#variables[@]} - 1 )) ); do |
| 12 | if [ -z "${!variables[$i]}" ]; then |
| 13 | echo "Variable \"${variables[$i]}\" is not defined" |
| 14 | exit 1 |
| 15 | fi |
| 16 | done |
| 17 | } |
| 18 | |
| 19 | rally_configuration () { |
Oleksii Zhurba | 2273790 | 2018-02-07 14:09:47 -0600 | [diff] [blame] | 20 | rally_version=$(rally version 2>&1) |
| 21 | if [ "$rally_version" == "0.9.0" ] || [ "$rally_version" == "0.9.1" ]; then |
| 22 | pip install ansible==2.3.2.0 |
| 23 | fi |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 24 | sub_name=`date "+%H_%M_%S"` |
| 25 | rally deployment create --fromenv --name=tempest_$sub_name |
| 26 | rally deployment config |
| 27 | } |
| 28 | |
| 29 | tempest_configuration () { |
| 30 | sub_name=`date "+%H_%M_%S"` |
| 31 | if [ -n "${PROXY}" ]; then |
| 32 | export https_proxy=$PROXY |
| 33 | fi |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 34 | rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 35 | unset https_proxy |
| 36 | rally verify configure-verifier --show |
| 37 | } |
| 38 | |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 39 | quick_configuration () { |
| 40 | current_path=$(pwd) |
| 41 | #image |
| 42 | glance image-list | grep "\bTest2VM\b" 2>&1 >/dev/null || { |
| 43 | if [ -n "${PROXY}" ]; then |
| 44 | export http_proxy=$PROXY |
| 45 | fi |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 46 | ls $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img || wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img -O $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 47 | unset http_proxy |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 48 | echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6" |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 49 | md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img |
| 50 | glance image-create --name=Test2VM --visibility=public --container-format=bare --disk-format=qcow2 < $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img |
| 51 | } |
| 52 | IMAGE_REF2=$(glance image-list | grep 'Test2VM' | awk '{print $2}') |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 53 | #flavor for rally |
| 54 | nova flavor-list | grep tiny 2>&1 >/dev/null || { |
| 55 | echo "Let's create m1.tiny flavor" |
| 56 | nova flavor-create --is-public true m1.tiny auto 128 1 1 |
| 57 | } |
| 58 | #shared fixed network |
| 59 | shared_count=`neutron net-list -c name -c shared | grep True | wc -l` |
| 60 | if [ $shared_count -gt 1 ]; then |
| 61 | echo "TOO MANY SHARED NETWORKS! Script will choose just 1 random" |
| 62 | fi |
| 63 | if [ $shared_count -eq 0 ]; then |
| 64 | echo "Let's create shared fixed net" |
| 65 | neutron net-create --shared fixed |
| 66 | neutron subnet-create --name fixed-subnet --gateway 192.168.0.1 --allocation-pool start=192.168.0.2,end=192.168.0.254 --ip-version 4 fixed 192.168.0.0/24 |
| 67 | fi |
| 68 | FIXED_NET=$(neutron net-list -c name -c shared | grep True | awk '{print $2}' | tail -n 1) |
| 69 | echo "Fixed net is: $FIXED_NET" |
| 70 | #Updating of tempest_full.conf file is skipped/deprecated |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 71 | sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 72 | sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 73 | sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 74 | cat $current_path/cvp-configuration/tempest/tempest_ext.conf |
| 75 | } |
| 76 | |
Oleksii Zhurba | ba5883f | 2018-01-18 09:52:08 -0600 | [diff] [blame] | 77 | if [ "$1" == "reconfigure" ]; then |
| 78 | echo "This is reconfiguration" |
| 79 | rally verify configure-verifier --reconfigure |
| 80 | rally verify configure-verifier --extend /home/rally/cvp-configuration/tempest/tempest_ext.conf |
| 81 | rally verify configure-verifier --show |
| 82 | exit 0 |
| 83 | fi |
| 84 | |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 85 | check_variables |
| 86 | rally_configuration |
Oleksii Zhurba | 0aa4670 | 2018-02-07 16:17:39 -0600 | [diff] [blame] | 87 | if [ -n "${TEMPEST_REPO}" ]; then |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 88 | tempest_configuration |
Oleksii Zhurba | b9133f7 | 2017-11-15 17:53:02 -0600 | [diff] [blame] | 89 | quick_configuration |
| 90 | rally verify configure-verifier --extend /home/rally/cvp-configuration/tempest/tempest_ext.conf |
Oleksii Zhurba | 1580fc5 | 2017-11-14 15:20:44 -0600 | [diff] [blame] | 91 | fi |
| 92 | set -e |
| 93 | |
| 94 | echo "Job is done!" |