2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB, Huawei Technologies Co.,Ltd and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 # Perepare the environment to run yardstick ci
13 : ${DEPLOY_TYPE:='bm'} # Can be any of 'bm' (Bare Metal) or 'virt' (Virtual)
14 : ${INSTALLER_TYPE:='unknown'}
15 : ${NODE_NAME:='unknown'}
16 : ${EXTERNAL_NETWORK:='admin_floating_net'}
17 : ${USER_NAME:='ubuntu'}
18 : ${SSH_KEY:='/root/.ssh/id_rsa'}
20 # Extract network name from EXTERNAL_NETWORK
21 # e.g. EXTERNAL_NETWORK='ext-net;flat;192.168.0.2;192.168.0.253;192.168.0.1;192.168.0.0/24'
22 export EXTERNAL_NETWORK=$(echo $EXTERNAL_NETWORK | cut -f1 -d \;)
24 # Create openstack credentials
25 echo "INFO: Creating openstack credentials .."
26 mkdir -p /etc/yardstick
27 OPENRC=/etc/yardstick/openstack.creds
28 INSTALLERS=(apex compass fuel joid)
31 if [ "${OS_AUTH_URL}" -a "${OS_USERNAME}" -a "${OS_PASSWORD}" -a "${EXTERNAL_NETWORK}" ];then
35 if [ "${RC_VAR_EXIST}" = false ]; then
36 if [ ! -f $OPENRC ];then
37 # credentials file is not given, check if environment variables are set
38 # to get the creds using fetch_os_creds.sh later on
39 echo "INFO: Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
40 if [ -z ${INSTALLER_TYPE} ]; then
41 echo "environment variable 'INSTALLER_TYPE' is not defined."
43 elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
44 echo "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
46 echo "Invalid env variable INSTALLER_TYPE=${INSTALLER_TYPE}"
50 if [ "$DEPLOY_TYPE" == "virt" ]; then
51 FETCH_CRED_ARG="-v -d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
53 FETCH_CRED_ARG="-d $OPENRC -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}"
56 $RELENG_REPO_DIR/utils/fetch_os_creds.sh $FETCH_CRED_ARG
61 export EXTERNAL_NETWORK INSTALLER_TYPE DEPLOY_TYPE NODE_NAME
63 # Prepare a admin-rc file for StorPerf integration
64 $YARDSTICK_REPO_DIR/tests/ci/prepare_storperf_admin-rc.sh
66 # copy Storperf related files to the deployment location
67 if [ "$INSTALLER_TYPE" == "compass" ]; then
68 source $YARDSTICK_REPO_DIR/tests/ci/scp_storperf_files.sh
71 # Fetching id_rsa file from jump_server..."
72 verify_connectivity() {
74 echo "Verifying connectivity to $ip..."
75 for i in $(seq 0 10); do
76 if ping -c 1 -W 1 $ip > /dev/null; then
77 echo "$ip is reachable!"
82 error "Can not talk to $ip."
85 ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
87 if [ "$INSTALLER_TYPE" == "fuel" ]; then
89 # check the connection
90 verify_connectivity $INSTALLER_IP
92 pod_yaml="$YARDSTICK_REPO_DIR/etc/yardstick/nodes/fuel_baremetal/pod.yaml"
94 # update "ip" according to the CI env
95 ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \
96 "sudo salt -C 'ctl* or cmp*' grains.get fqdn_ip4 --out yaml">node_info
98 controller_ips=($(cat node_info|awk '/ctl/{getline; print $2}'))
99 compute_ips=($(cat node_info|awk '/cmp/{getline; print $2}'))
101 if [[ ${controller_ips[0]} ]]; then
102 sed -i "s|ip1|${controller_ips[0]}|" $pod_yaml;
104 if [[ ${controller_ips[1]} ]]; then
105 sed -i "s|ip2|${controller_ips[1]}|" $pod_yaml;
107 if [[ ${controller_ips[2]} ]]; then
108 sed -i "s|ip3|${controller_ips[2]}|" $pod_yaml;
110 if [[ ${compute_ips[0]} ]]; then
111 sed -i "s|ip4|${compute_ips[0]}|" $pod_yaml;
113 if [[ ${compute_ips[1]} ]]; then
114 sed -i "s|ip5|${compute_ips[1]}|" $pod_yaml;
117 # update 'user' and 'key_filename' according to the CI env
118 sed -i "s|node_username|${USER_NAME}|;s|node_keyfile|${SSH_KEY}|" $pod_yaml;