blob: cb7277cfe000dd3c21e6a10ae6a3663d3f023a0f [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 () {
25 sub_name=`date "+%H_%M_%S"`
26 rally deployment create --fromenv --name=tempest_$sub_name
27 rally deployment config
28}
29
30tempest_configuration () {
31 sub_name=`date "+%H_%M_%S"`
32 if [ -n "${PROXY}" ]; then
33 export https_proxy=$PROXY
34 fi
35 rally verify create-verifier --name tempest_verifier_$sub_name --type tempest --source $TEMPEST_ENDPOINT --version $tempest_version
36 unset https_proxy
37 rally verify configure-verifier --show
38}
39
40collecting_openstack_data () {
41current_path=$(pwd)
42
43PUBLIC_NETWORK_ID=$(neutron net-list --router:external=True -f csv -c id --quote none | tail -1)
44PUBLIC_NETWORK_NAME="`neutron --insecure net-list --router:external=True -f csv -c name --quote none | tail -1`"
45NEUTRON_EXT_LIST=$(neutron ext-list | grep -v "+" | grep -v "alias" | awk '{print $2}' | tr '\n ' ', ' | head -c -1)
46neutron net-list | grep fixed 2>&1 >/dev/null || {
47 neutron net-create --shared fixed
48 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
49}
50SHARED_NETWORK_NAME=fixed
51SHARED_NETWORK_ID=$(neutron net-list | grep "\b${SHARED_NETWORK_NAME}\b" | cut -c3-38)
52neutron net-update ${SHARED_NETWORK_ID} --shared true
53
54#flavor
55nova flavor-list | grep tiny 2>&1 >/dev/null || {
56 nova flavor-create --is-public true m1.tiny auto 128 1 1
57}
58FLAVOR_REF=$(nova flavor-list | grep '\bm1.tiny\b' | awk '{print $2}')
59nova flavor-list | grep m1.micro 2>&1 >/dev/null || {
60 nova flavor-create --is-public true m1.micro auto 1024 2 2
61}
62FLAVOR_REF2=$(nova flavor-list | grep '\bm1.micro\b' | awk '{print $2}')
63
64#image
65glance image-list | grep "\bTestVM\b" 2>&1 >/dev/null || {
66 if [ -n "${PROXY}" ]; then
67 export http_proxy=$PROXY
68 fi
69 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
70 unset http_proxy
71 echo "TODO: add md5check here"
72 echo "should be ee1eca47dc88f4879d8a229cc70a07c6"
73 md5sum $current_path/cvp-configuration/cirros-0.3.4-x86_64-disk.img
74 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
75 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
76}
77IMAGE_REF=$(glance image-list | grep 'TestVM' | awk '{print $2}')
78IMAGE_REF2=$(glance image-list | grep 'Test2VM' | awk '{print $2}')
79
80url_base=$(echo ${OS_AUTH_URL} | sed -e 's/[^/]*\/\/\([^@]*@\)\?\([^:/]*\).*/\2/')
81
82#neutron net-create --shared fixed
83#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
84
85check_service_availability() {
86 SVC=$(openstack service list | grep $1 | wc -l)
87 if [ "${SVC}" -eq "0" ]; then
88 echo "false"
89 else
90 echo "true"
91 fi
92}
93
94NEUTRON_AVAILABLE=$(check_service_availability "neutron")
95NOVA_AVAILABLE=$(check_service_availability "nova")
96CINDER_AVAILABLE=$(check_service_availability "cinder")
97GLANCE_AVAILABLE=$(check_service_availability "glance")
98SWIFT_AVAILABLE=$(check_service_availability "swift")
99HEAT_AVAILABLE=$(check_service_availability "heat")
100CEILOMETER_AVAILABLE=$(check_service_availability "ceilometer")
101SAHARA_AVAILABLE=$(check_service_availability "sahara")
102IRONIC_AVAILABLE=$(check_service_availability "ironic")
103TROVE_AVAILABLE=$(check_service_availability "trove")
104ZAQAR_AVAILABLE=$(check_service_availability "zaqar")
105}
106
107create_tempest_config () {
108sed -i 's/${OS_USERNAME}/'$OS_USERNAME'/g' $current_path/cvp-configuration/tempest_full.conf
109sed -i 's/${OS_PASSWORD}/'$OS_PASSWORD'/g' $current_path/cvp-configuration/tempest_full.conf
110sed -i 's/${OS_TENANT_NAME}/'$OS_TENANT_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
111sed -i 's/${OS_DEFAULT_DOMAIN}/'$OS_DEFAULT_DOMAIN'/g' $current_path/cvp-configuration/tempest_full.conf
112sed -i 's/${IMAGE_REF}/'$IMAGE_REF'/g' $current_path/cvp-configuration/tempest_full.conf
113sed -i 's/${IMAGE_REF2}/'$IMAGE_REF2'/g' $current_path/cvp-configuration/tempest_full.conf
114sed -i 's/${FLAVOR_REF}/'$FLAVOR_REF'/g' $current_path/cvp-configuration/tempest_full.conf
115sed -i 's/${FLAVOR_REF2}/'$FLAVOR_REF2'/g' $current_path/cvp-configuration/tempest_full.conf
116sed -i 's/${SHARED_NETWORK_NAME}/'$SHARED_NETWORK_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
117sed -i 's/${OS_REGION_NAME}/'$OS_REGION_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
118sed -i 's/${url_base}/'$url_base'/g' $current_path/cvp-configuration/tempest_full.conf
119sed -i 's/${PUBLIC_NETWORK_ID}/'$PUBLIC_NETWORK_ID'/g' $current_path/cvp-configuration/tempest_full.conf
120sed -i 's/${PUBLIC_NETWORK_NAME}/'$PUBLIC_NETWORK_NAME'/g' $current_path/cvp-configuration/tempest_full.conf
121sed -i 's/${NEUTRON_EXT_LIST}/'$NEUTRON_EXT_LIST'/g' $current_path/cvp-configuration/tempest_full.conf
122sed -i 's/publicURL/'$TEMPEST_ENDPOINT_TYPE'/g' $current_path/cvp-configuration/tempest_full.conf
123cat $current_path/cvp-configuration/tempest_full.conf
124}
125
126check_variables
127rally_configuration
128if [ -n "${TEMPEST_ENDPOINT}" ]; then
129 tempest_configuration
130 collecting_openstack_data
131 create_tempest_config
132 rally verify configure-verifier --override /home/rally/cvp-configuration/tempest_full.conf
133fi
134set -e
135
136echo "Job is done!"