blob: 859d02c1840923e26b925cb7068401992f061551 [file] [log] [blame]
Oleksii Zhurba1580fc52017-11-14 15:20:44 -06001#!/bin/bash
2
3# TODO
4#personality option
5#security_compliance option
6#port_security option
7
8variables=(
9OS_USERNAME
10OS_PASSWORD
11OS_TENANT_NAME
12OS_AUTH_URL
13)
14
15check_variables () {
16 for i in $(seq 0 $(( ${#variables[@]} - 1 )) ); do
17 if [ -z "${!variables[$i]}" ]; then
18 echo "Variable \"${variables[$i]}\" is not defined"
19 exit 1
20 fi
21 done
22}
23
24rally_configuration () {
Oleksii Zhurba22737902018-02-07 14:09:47 -060025 rally_version=$(rally version 2>&1)
26 if [ "$rally_version" == "0.9.0" ] || [ "$rally_version" == "0.9.1" ]; then
27 pip install ansible==2.3.2.0
28 fi
Oleksii Zhurba1580fc52017-11-14 15:20:44 -060029 sub_name=`date "+%H_%M_%S"`
30 rally deployment create --fromenv --name=tempest_$sub_name
31 rally deployment config
32}
33
34tempest_configuration () {
35 sub_name=`date "+%H_%M_%S"`
36 if [ -n "${PROXY}" ]; then
37 export https_proxy=$PROXY
38 fi
39 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_ENDPOINT --version $tempest_version
40 unset https_proxy
41 rally verify configure-verifier --show
42}
43
44collecting_openstack_data () {
45current_path=$(pwd)
46
47PUBLIC_NETWORK_ID=$(neutron net-list --router:external=True -f csv -c id --quote none | tail -1)
48PUBLIC_NETWORK_NAME="`neutron --insecure net-list --router:external=True -f csv -c name --quote none | tail -1`"
49NEUTRON_EXT_LIST=$(neutron ext-list | grep -v "+" | grep -v "alias" | awk '{print $2}' | tr '\n ' ', ' | head -c -1)
50neutron net-list | grep fixed 2>&1 >/dev/null || {
51 neutron net-create --shared fixed
52 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
53}
54SHARED_NETWORK_NAME=fixed
55SHARED_NETWORK_ID=$(neutron net-list | grep "\b${SHARED_NETWORK_NAME}\b" | cut -c3-38)
56neutron net-update ${SHARED_NETWORK_ID} --shared true
57
58#flavor
59nova flavor-list | grep tiny 2>&1 >/dev/null || {
60 nova flavor-create --is-public true m1.tiny auto 128 1 1
61}
62FLAVOR_REF=$(nova flavor-list | grep '\bm1.tiny\b' | awk '{print $2}')
63nova flavor-list | grep m1.micro 2>&1 >/dev/null || {
64 nova flavor-create --is-public true m1.micro auto 1024 2 2
65}
66FLAVOR_REF2=$(nova flavor-list | grep '\bm1.micro\b' | awk '{print $2}')
67
68#image
69glance image-list | grep "\bTestVM\b" 2>&1 >/dev/null || {
70 if [ -n "${PROXY}" ]; then
71 export http_proxy=$PROXY
72 fi
73 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
74 unset http_proxy
75 echo "TODO: add md5check here"
76 echo "should be ee1eca47dc88f4879d8a229cc70a07c6"
77 md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
78 glance image-create --name=TestVM --visibility=public --container-format=bare --disk-format=qcow2 < $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
79 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
80}
81IMAGE_REF=$(glance image-list | grep 'TestVM' | awk '{print $2}')
82IMAGE_REF2=$(glance image-list | grep 'Test2VM' | awk '{print $2}')
83
84url_base=$(echo ${OS_AUTH_URL} | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')
85
86#neutron net-create --shared fixed
87#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
88
89check_service_availability() {
90 SVC=$(openstack service list | grep $1 | wc -l)
91 if [ "${SVC}" -eq "0" ]; then
92 echo "false"
93 else
94 echo "true"
95 fi
96}
97
98NEUTRON_AVAILABLE=$(check_service_availability "neutron")
99NOVA_AVAILABLE=$(check_service_availability "nova")
100CINDER_AVAILABLE=$(check_service_availability "cinder")
101GLANCE_AVAILABLE=$(check_service_availability "glance")
102SWIFT_AVAILABLE=$(check_service_availability "swift")
103HEAT_AVAILABLE=$(check_service_availability "heat")
104CEILOMETER_AVAILABLE=$(check_service_availability "ceilometer")
105SAHARA_AVAILABLE=$(check_service_availability "sahara")
106IRONIC_AVAILABLE=$(check_service_availability "ironic")
107TROVE_AVAILABLE=$(check_service_availability "trove")
108ZAQAR_AVAILABLE=$(check_service_availability "zaqar")
109}
110
111create_tempest_config () {
112sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest_full.conf
113sed -i 's/${OS_PASSWORD}/'$OS_PASSWORD'/g' $current_path/cvp-configuration/tempest_full.conf
114sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
115sed -i 's/${OS_DEFAULT_DOMAIN}/'$OS_DEFAULT_DOMAIN'/g' $current_path/cvp-configuration/tempest_full.conf
116sed -i 's/${IMAGE_REF}/'$IMAGE_REF'/g' $current_path/cvp-configuration/tempest_full.conf
117sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest_full.conf
118sed -i 's/${FLAVOR_REF}/'$FLAVOR_REF'/g' $current_path/cvp-configuration/tempest_full.conf
119sed -i 's/${FLAVOR_REF2}/'$FLAVOR_REF2'/g' $current_path/cvp-configuration/tempest_full.conf
120sed -i 's/${SHARED_NETWORK_NAME}/'$SHARED_NETWORK_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
121sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
122sed -i 's/${url_base}/'$url_base'/g' $current_path/cvp-configuration/tempest_full.conf
123sed -i 's/${PUBLIC_NETWORK_ID}/'$PUBLIC_NETWORK_ID'/g' $current_path/cvp-configuration/tempest_full.conf
124sed -i 's/${PUBLIC_NETWORK_NAME}/'$PUBLIC_NETWORK_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
125sed -i 's/${NEUTRON_EXT_LIST}/'$NEUTRON_EXT_LIST'/g' $current_path/cvp-configuration/tempest_full.conf
126sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest_full.conf
127cat $current_path/cvp-configuration/tempest_full.conf
128}
129
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600130quick_configuration () {
131current_path=$(pwd)
132#image
133glance image-list | grep "\bTest2VM\b" 2>&1 >/dev/null || {
134 if [ -n "${PROXY}" ]; then
135 export http_proxy=$PROXY
136 fi
137 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
138 unset http_proxy
139 echo "TODO: add md5check here"
140 echo "should be ee1eca47dc88f4879d8a229cc70a07c6"
141 md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
142 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
143}
144IMAGE_REF2=$(glance image-list | grep 'Test2VM' | awk '{print $2}')
Oleksii Zhurba425335a2017-12-12 15:31:50 -0600145#IMAGE_NAME=$(glance image-list | grep 'Test2VM' | awk '{print $4}')
146
147#nova flavor-list | grep tiny 2>&1 >/dev/null || {
148# nova flavor-create --is-public true m1.tiny auto 128 1 1
149#}
150#FLAVOR_REF=$(nova flavor-list | grep '\bm1.tiny\b' | awk '{print $2}')
151#FLAVOR_NAME=$(nova flavor-list | grep '\bm1.tiny\b' | awk '{print $4}')
152
153#sed -i 's/${IMAGE_REF2}/'$IMAGE_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios.json
154#sed -i 's/${FLAVOR_REF}/'$FLAVOR_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios.json
155#sed -i 's/${IMAGE_REF2}/'$IMAGE_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios_full.json
156#sed -i 's/${FLAVOR_REF}/'$FLAVOR_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios_full.json
157#sed -i 's/${IMAGE_REF2}/'$IMAGE_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios_many_VM.json
158#sed -i 's/${FLAVOR_REF}/'$FLAVOR_NAME'/g' $current_path/testing-stuff/rally/rally_scenarios_many_VM.json
159
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600160sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
161sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest/tempest_ext.conf
162cat $current_path/cvp-configuration/tempest/tempest_ext.conf
163}
164
Oleksii Zhurbaba5883f2018-01-18 09:52:08 -0600165if [ "$1" == "reconfigure" ]; then
166 echo "This is reconfiguration"
167 rally verify configure-verifier --reconfigure
168 rally verify configure-verifier --extend /home/rally/cvp-configuration/tempest/tempest_ext.conf
169 rally verify configure-verifier --show
170 exit 0
171fi
172
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600173check_variables
174rally_configuration
175if [ -n "${TEMPEST_ENDPOINT}" ]; then
176 tempest_configuration
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600177 #collecting_openstack_data
178 #create_tempest_config
Oleksii Zhurba425335a2017-12-12 15:31:50 -0600179 #rally verify configure-verifier --override /home/rally/cvp-configuration/tempest_full.conf
Oleksii Zhurbab9133f72017-11-15 17:53:02 -0600180 quick_configuration
181 rally verify configure-verifier --extend /home/rally/cvp-configuration/tempest/tempest_ext.conf
Oleksii Zhurba1580fc52017-11-14 15:20:44 -0600182fi
183set -e
184
185echo "Job is done!"