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 (compass, fuel, joid, apex)
25 $(basename "$0") -i compass"
30 # Process input variables
45 redirect="/dev/stdout"
52 # Define alias for log printing
54 logger -s -t "BOTTLENECKS INFO" "$*"
58 logger -s -t "BOTTLENECKS ERROR" "$*"
63 echo "BOTTLENECKS INFO: Downloading Releng"
64 RELENG_REPO="/home/releng"
65 [ -d ${RELENG_REPO} ] && rm -rf ${RELENG_REPO}
66 git clone https://gerrit.opnfv.org/gerrit/releng ${RELENG_REPO} >${redirect}
68 echo "BOTTLENECKS INFO: Downloading Yardstick"
69 YARDSTICK_REPO="/home/yardstick"
70 [ -d ${YARDSTICK_REPO} ] && rm -rf ${YARDSTICK_REPO}
71 git clone https://gerrit.opnfv.org/gerrit/yardstick ${YARDSTICK_REPO} >${redirect}
73 BOTTLENECKS_CONFIG=/tmp
75 OPENRC=${BOTTLENECKS_CONFIG}/admin_rc.sh
76 OS_CACERT=${BOTTLENECKS_CONFIG}/os_cacert
78 # Preparing configuration files for testing
79 if [[ ${INSTALLER_TYPE} != "" ]]; then
80 # Preparing OpenStack RC and Cacert files
81 info "fetching os credentials from $INSTALLER_TYPE"
82 if [[ $INSTALLER_TYPE == 'compass' ]]; then
83 export BRANCH="master"
84 INSTALLER_IP=192.168.200.2
85 if [[ ${BRANCH} == 'master' ]]; then
86 ${RELENG_REPO}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} -o ${OS_CACERT} >${redirect}
87 if [[ -f ${OS_CACERT} ]]; then
88 echo "BOTTLENECKS INFO: successfully fetching os_cacert for openstack: ${OS_CACERT}"
90 echo "BOTTLENECKS ERROR: couldn't find os_cacert file: ${OS_CACERT}, please check if the it's been properly provided."
94 ${RELENG_REPO}/utils/fetch_os_creds.sh -d ${OPENRC} -i ${INSTALLER_TYPE} -a ${INSTALLER_IP} >${redirect}
97 error "The isntaller is not specified"
101 if [[ -f ${OPENRC} ]]; then
102 echo "BOTTLENECKS INFO: openstack credentials path is ${OPENRC}"
103 if [[ $INSTALLER_TYPE == 'compass' && ${BRANCH} == 'master' ]]; then
104 echo "BOTTLENECKS INFO: writing ${OS_CACERT} to ${OPENRC}"
105 echo "export OS_CACERT=${OS_CACERT}" >> ${OPENRC}
109 echo "BOTTLENECKS ERROR: couldn't find openstack rc file: ${OPENRC}, please check if the it's been properly provided."
113 # Finding and crearting POD description files from different deployments
114 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
116 if [ "$INSTALLER_TYPE" == "fuel" ]; then
117 echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
118 sshpass -p r00tme sudo scp $ssh_options root@${INSTALLER_IP}:~/.ssh/id_rsa ${BOTTLENECKS_CONFIG}/id_rsa
121 if [ "$INSTALLER_TYPE" == "apex" ]; then
122 echo "Fetching id_rsa file from jump_server $INSTALLER_IP..."
123 sudo scp $ssh_options stack@${INSTALLER_IP}:~/.ssh/id_rsa ${BOTTLENECKS_CONFIG}/id_rsa
126 if [[ ${INSTALLER_TYPE} == compass ]]; then
127 options="-u root -p root"
128 elif [[ ${INSTALLER_TYPE} == fuel ]]; then
129 options="-u root -p r00tme"
130 elif [[ ${INSTALLER_TYPE} == apex ]]; then
131 options="-u stack -k /root/.ssh/id_rsa"
133 echo "Don't support to generate pod.yaml on ${INSTALLER_TYPE} currently."
136 if [[ ${INSTALLER_TYPE} != compass ]]; then
137 cmd="sudo python ${RELENG_REPO}/utils/create_pod_file.py -t ${INSTALLER_TYPE} \
138 -i ${INSTALLER_IP} ${options} -f ${BOTTLENECKS_CONFIG}/pod.yaml \
139 -s ${BOTTLENECKS_CONFIG}/id_rsa"
143 cmd="sudo cp ${YARDSTICK_REPO}/etc/yardstick/nodes/compass_sclab_virtual/pod.yaml \
144 ${BOTTLENECKS_CONFIG}"
149 if [ -f ${BOTTLENECKS_CONFIG}/pod.yaml ]; then
150 echo "FILE: ${BOTTLENECKS_CONFIG}/pod.yaml:"
151 cat ${BOTTLENECKS_CONFIG}/pod.yaml
153 echo "ERROR: cannot find file ${BOTTLENECKS_CONFIG}/pod.yaml. Please check if it is existing."
154 sudo ls -al ${BOTTLENECKS_CONFIG}