2 ##############################################################################
3 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # This file is to prepare the openstack certs and pod description that required
11 # for Bottlenecks tests.
12 usage="Script to prepare the configurations before testing.
15 bash $(basename "$0") [-h|--help] [-i <installer>] [--debug]
18 -h|--help show the help text
19 -i|--installer input the name of the installer
20 <installer> one of the following:
21 (apex, compass, fuel, joid)
25 $(basename "$0") -i compass"
30 # Process input variables
45 redirect="/dev/stdout"
49 echo "unkown option $1 $2"
56 # Define alias for log printing
58 logger -s -t "BOTTLENECKS INFO" "$*"
62 logger -s -t "BOTTLENECKS ERROR" "$*"
67 RELENG_REPO="/home/releng"
68 BOTTLENECKS_CONFIG=/tmp
69 OPENRC=${BOTTLENECKS_CONFIG}/admin_rc.sh
70 OS_CACERT=${BOTTLENECKS_CONFIG}/os_cacert
73 ##############################################################################
74 # Preparing scripts for openstack and pod configs for OPNFV Installers
75 ##############################################################################
77 info "Downloading Releng fetch_os_creds script for openstack/pod configs of OPNFV installers"
79 [ -d ${RELENG_REPO} ] && rm -rf ${RELENG_REPO}
80 git clone https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO} >${redirect}
82 info "Downloading Yardstick for pod configs of OPNFV installers"
83 YARDSTICK_REPO="/home/yardstick"
84 [ -d ${YARDSTICK_REPO} ] && rm -rf ${YARDSTICK_REPO}
85 git clone https://gerrit.opnfv.org/gerrit/yardstick ${YARDSTICK_REPO} >${redirect}
87 # Preparing configuration files for testing
88 if [[ ${INSTALLER_TYPE} != "" ]]; then
89 # Preparing OpenStack RC and Cacert files
90 info "fetching os credentials from $INSTALLER_TYPE"
91 if [[ $INSTALLER_TYPE == 'compass' ]]; then
92 export BRANCH="master"
93 INSTALLER_IP=192.168.200.2
94 if [[ ${BRANCH} == 'master' ]]; then
95 ${RELENG_REPO}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} -o ${OS_CACERT} >${redirect}
97 ${RELENG_REPO}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} >${redirect}
99 elif [[ $INSTALLER_TYPE == 'apex' ]]; then
100 INSTALLER_IP=$(sudo virsh domifaddr undercloud | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
101 ${RELENG_REPO}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} -o ${OS_CACERT} >${redirect}
105 error "The installer is not specified"
109 # Finding and crearting POD description files from different deployments
110 if [[ ${INSTALLER_TYPE} == 'compass' ]]; then
111 cmd="sudo cp ${YARDSTICK_REPO}/etc/yardstick/nodes/compass_sclab_virtual/pod.yaml \
112 ${BOTTLENECKS_CONFIG}"
115 elif [[ ${INSTALLER_TYPE} == 'apex' ]]; then
116 sudo pip install virtualenv
119 source venv/bin/activate
120 sudo pip install -e ${RELENG_REPO}/modules/ >/dev/null
121 sudo pip install netaddr
123 options="-u stack -k /root/.ssh/id_rsa"
124 cmd="sudo python ${RELENG_REPO}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
125 -i ${INSTALLER_IP} ${options} -f ${BOTTLENECKS_CONFIG}/pod.yaml"
129 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
130 cmd="sudo scp $ssh_options stack@${INSTALLER_IP}:~/.ssh/id_rsa ${BOTTLENECKS_CONFIG}/id_rsa"
138 ##############################################################################
139 # Check the existence of the output configs for OPNFV Installers
140 ##############################################################################
141 # Checking the pod decription file
142 if [ -f ${BOTTLENECKS_CONFIG}/pod.yaml ]; then
143 info "FILE - ${BOTTLENECKS_CONFIG}/pod.yaml:"
144 cat ${BOTTLENECKS_CONFIG}/pod.yaml
146 error "Cannot find file ${BOTTLENECKS_CONFIG}/pod.yaml. Please check if it is existing."
147 sudo ls -al ${BOTTLENECKS_CONFIG}
150 # Checking the openstack rc and os_cacert file
151 if [[ -f ${OPENRC} ]]; then
152 info "Opentack credentials path is ${OPENRC}"
153 if [[ -f ${OS_CACERT} ]]; then
154 info "Writing ${OS_CACERT} to ${OPENRC}"
155 echo "export OS_CACERT=${OS_CACERT}" >> ${OPENRC}
158 info "Couldn't find openstack cacert file: ${OS_CACERT}, please check if the it's been properly provided."
161 error "Couldn't find openstack rc file: ${OPENRC}, please check if the it's been properly provided."
165 # Checking ssh key id_rsa
166 if [[ -f "/tmp/id_rsa" ]]; then
167 info "Path of ssh key file for openstack nodes is /tmp/id_rsa"
169 info "Couldn't find the ssh key file for openstack nodes. If you are using user/pwd in pod.yaml, please ignore."