multisite: Use known/working version of fuel
[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_BUILD_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
31 # use known/working version of fuel
32 FUEL_PROPERTIES_FILE="opnfv-2017-03-06_16-00-15.properties"
33 curl -L -s -o $WORKSPACE/latest.properties http://artifacts.opnfv.org/fuel/$FUEL_PROPERTIES_FILE
34
35 # source the file so we get OPNFV vars
36 source latest.properties
37
38 # echo the info about artifact that is used during the deployment
39 echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment"
40
41 # download the iso
42 echo "Downloading the ISO using the link http://$OPNFV_ARTIFACT_URL"
43 curl -L -s -o $WORKSPACE/opnfv.iso http://$OPNFV_ARTIFACT_URL > gsutil.iso.log 2>&1
44
45
46 # set deployment parameters
47 DEPLOY_SCENARIO="os-nosdn-nofeature-noha"
48 export TMPDIR=$HOME/tmpdir
49 BRIDGE=${BRIDGE:-pxebr}
50 LAB_NAME=${NODE_NAME/-*}
51 POD_NAME=${NODE_NAME/*-}
52
53 if [[ "$NODE_NAME" =~ "virtual" ]]; then
54     POD_NAME="virtual_kvm"
55 fi
56
57 # we currently support ericsson, intel, lf and zte labs
58 if [[ ! "$LAB_NAME" =~ (ericsson|intel|lf|zte) ]]; then
59     echo "Unsupported/unidentified lab $LAB_NAME. Cannot continue!"
60     exit 1
61 else
62     echo "Using configuration for $LAB_NAME"
63 fi
64
65 # create TMPDIR if it doesn't exist
66 export TMPDIR=$HOME/tmpdir
67 mkdir -p $TMPDIR
68
69 # change permissions down to TMPDIR
70 chmod a+x $HOME
71 chmod a+x $TMPDIR
72
73 # clone fuel repo and checkout the sha1 that corresponds to the ISO
74 echo "Cloning fuel repo"
75 git clone https://gerrit.opnfv.org/gerrit/p/fuel.git fuel
76 cd $WORKSPACE/fuel
77 echo "Checking out $OPNFV_GIT_SHA1"
78 git checkout $OPNFV_GIT_SHA1 --quiet
79
80 # clone the securedlab repo
81 cd $WORKSPACE
82 echo "Cloning securedlab repo ${GIT_BRANCH##origin/}"
83 git clone ssh://jenkins-ericsson@gerrit.opnfv.org:29418/securedlab --quiet \
84     --branch ${GIT_BRANCH##origin/}
85
86 # log file name
87 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
88
89 # construct the command
90 DEPLOY_COMMAND="sudo $WORKSPACE/fuel/ci/deploy.sh -b file://$WORKSPACE/securedlab \
91     -l $LAB_NAME -p $POD_NAME -s $DEPLOY_SCENARIO -i file://$WORKSPACE/opnfv.iso \
92     -H -B $BRIDGE -S $TMPDIR -L $WORKSPACE/$FUEL_LOG_FILENAME"
93
94 # log info to console
95 echo "Deployment parameters"
96 echo "--------------------------------------------------------"
97 echo "Scenario: $DEPLOY_SCENARIO"
98 echo "Lab: $LAB_NAME"
99 echo "POD: $POD_NAME"
100 echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
101 echo
102 echo "Starting the deployment using $INSTALLER_TYPE. This could take some time..."
103 echo "--------------------------------------------------------"
104 echo
105
106 # start the deployment
107 echo "Issuing command"
108 echo "$DEPLOY_COMMAND"
109 echo
110
111 $DEPLOY_COMMAND
112 exit_code=$?
113
114 echo
115 echo "--------------------------------------------------------"
116 echo "Deployment is done!"
117
118 if [[ $exit_code -ne 0 ]]; then
119     echo "Deployment failed!"
120     exit $exit_code
121 else
122     echo "Deployment is successful!"
123     exit 0
124 fi