Merge "Enable bgpvpn scenario in pipeline again"
[releng.git] / jjb / multisite / fuel-deploy-for-multisite.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2016 Ericsson AB 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 ##############################################################################
10 set -o nounset
11 set -o pipefail
12
13 # do not continue with the deployment if FRESH_INSTALL is not requested
14 if [[ "$FRESH_INSTALL" == "true" ]]; then
15     echo "Fresh install requested. Proceeding with the installation."
16 else
17     echo "Fresh install is not requested. Skipping the installation."
18     exit 0
19 fi
20
21 export TERM="vt220"
22
23 # get the latest successful job console log and extract the properties filename
24 FUEL_DEPLOY_BUILD_URL="https://build.opnfv.org/ci/job/fuel-deploy-virtual-daily-master/lastSuccessfulBuild/consoleText"
25 FUEL_PROPERTIES_FILE=$(curl -s -L ${FUEL_DEPLOY_URL} | grep 'ISO:' | awk '{print $2}' | sed 's/iso/properties/g')
26 if [[ -z "FUEL_PROPERTIES_FILE" ]]; then
27     echo "Unable to extract the url to Fuel ISO properties from ${FUEL_DEPLOY_URL}"
28     exit 1
29 fi
30 curl -L -s -o $WORKSPACE/latest.properties http://artifacts.opnfv.org/fuel/$FUEL_PROPERTIES_FILE
31
32 # source the file so we get OPNFV vars
33 source latest.properties
34
35 # echo the info about artifact that is used during the deployment
36 echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment"
37
38 # download the iso
39 echo "Downloading the ISO using the link http://$OPNFV_ARTIFACT_URL"
40 curl -L -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
41
42 echo "Checking out $OPNFV_GIT_SHA1"
43 git checkout $OPNFV_GIT_SHA1 --quiet
44
45 # set deployment parameters
46 DEPLOY_SCENARIO="os-nosdn-nofeature-noha"
47 export TMPDIR=$HOME/tmpdir
48 BRIDGE=${BRIDGE:-pxebr}
49 LAB_NAME=${NODE_NAME/-*}
50 POD_NAME=${NODE_NAME/*-}
51
52 if [[ "$NODE_NAME" =~ "virtual" ]]; then
53     POD_NAME="virtual_kvm"
54 fi
55
56 # we currently support ericsson, intel, lf and zte labs
57 if [[ ! "$LAB_NAME" =~ (ericsson|intel|lf|zte) ]]; then
58     echo "Unsupported/unidentified lab $LAB_NAME. Cannot continue!"
59     exit 1
60 else
61     echo "Using configuration for $LAB_NAME"
62 fi
63
64 # create TMPDIR if it doesn't exist
65 export TMPDIR=$HOME/tmpdir
66 mkdir -p $TMPDIR
67
68 # change permissions down to TMPDIR
69 chmod a+x $HOME
70 chmod a+x $TMPDIR
71
72 # clone the securedlab repo
73 cd $WORKSPACE
74 echo "Cloning securedlab repo ${GIT_BRANCH##origin/}"
75 git clone ssh://jenkins-ericsson@gerrit.opnfv.org:29418/securedlab --quiet \
76     --branch ${GIT_BRANCH##origin/}
77
78 # log file name
79 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
80
81 # construct the command
82 DEPLOY_COMMAND="sudo $WORKSPACE/ci/deploy.sh -b file://$WORKSPACE/securedlab \
83     -l $LAB_NAME -p $POD_NAME -s $DEPLOY_SCENARIO -i file://$WORKSPACE/opnfv.iso \
84     -H -B $BRIDGE -S $TMPDIR -L $WORKSPACE/$FUEL_LOG_FILENAME"
85
86 # log info to console
87 echo "Deployment parameters"
88 echo "--------------------------------------------------------"
89 echo "Scenario: $DEPLOY_SCENARIO"
90 echo "Lab: $LAB_NAME"
91 echo "POD: $POD_NAME"
92 echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
93 echo
94 echo "Starting the deployment using $INSTALLER_TYPE. This could take some time..."
95 echo "--------------------------------------------------------"
96 echo
97
98 # start the deployment
99 echo "Issuing command"
100 echo "$DEPLOY_COMMAND"
101 echo
102
103 $DEPLOY_COMMAND
104 exit_code=$?
105
106 echo
107 echo "--------------------------------------------------------"
108 echo "Deployment is done!"
109
110 if [[ $exit_code -ne 0 ]]; then
111     echo "Deployment failed!"
112     exit $exit_code
113 else
114     echo "Deployment is successful!"
115     exit 0
116 fi