blob: 4667cf34184e4d67fca7d08de6178ab88a2675d2 [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
2
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06003variables=(
4OS_USERNAME
5OS_PASSWORD
6OS_TENANT_NAME
7OS_AUTH_URL
8)
9
10check_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
19rally_configuration () {
Oleksii Zhurba22737902018-02-07 14:09:47 -060020 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 Zhurba1580fc52017-11-14 15:20:44 -060024 sub_name=`date "+%H_%M_%S"`
25 rally deployment create --fromenv --name=tempest_$sub_name
26 rally deployment config
27}
28
29tempest_configuration () {
30 sub_name=`date "+%H_%M_%S"`
31 if [ -n "${PROXY}" ]; then
32 export https_proxy=$PROXY
33 fi
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060034 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_REPO --version $tempest_version
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060035 unset https_proxy
36 rally verify configure-verifier --show
37}
38
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060039quick_configuration () {
40current_path=$(pwd)
41#image
42glance image-list | grep "\bTest2VM\b" 2>&1 >/dev/null || {
43 if [ -n "${PROXY}" ]; then
44 export http_proxy=$PROXY
45 fi
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060046 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 Zhurbab9133f72017-11-15 17:53:02 -060047 unset http_proxy
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060048 echo "MD5 should be ee1eca47dc88f4879d8a229cc70a07c6"
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060049 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}
52IMAGE_REF2=$(glance image-list | grep 'Test2VM' | awk '{print $2}')
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060053#flavor for rally
54nova 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
59shared_count=`neutron net-list -c name -c shared | grep True | wc -l`
60if [ $shared_count -gt 1 ]; then
61 echo "TOO MANY SHARED NETWORKS! Script will choose just 1 random"
62fi
63if [ $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
67fi
68FIXED_NET=$(neutron net-list -c name -c shared | grep True | awk '{print $2}' | tail -n 1)
69echo "Fixed net is: $FIXED_NET"
70#Updating of tempest_full.conf file is skipped/deprecated
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060071sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060072sed -i 's/${FIXED_NET}/'$FIXED_NET'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060073sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
74cat $current_path/cvp-configuration/tempest/tempest_ext.conf
75}
76
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -060077if [ "$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
83fi
84
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060085check_variables
86rally_configuration
Oleksii Zhurba0aa46702018-02-07 16:17:39 -060087if [ -n "${TEMPEST_REPO}" ]; then
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060088 tempest_configuration
Oleksii Zhurbab9133f72017-11-15 17:53:02 -060089 quick_configuration
90 rally verify configure-verifier --extend /home/rally/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060091fi
92set -e
93
94echo "Job is done!"