Add functest-healthcheck alpine to xci-verify-healthcheck-macro
[releng.git] / jjb / fuel / fuel-deploy.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 export TERM="vt220"
14
15 if [[ "$BRANCH" != 'master' ]]; then
16     # source the file so we get OPNFV vars
17     source latest.properties
18
19     # echo the info about artifact that is used during the deployment
20     echo "Using ${OPNFV_ARTIFACT_URL/*\/} for deployment"
21 fi
22
23 if [[ "$JOB_NAME" =~ "merge" ]]; then
24     # set simplest scenario for virtual deploys to run for merges
25     DEPLOY_SCENARIO="os-nosdn-nofeature-ha"
26 elif [[ "$BRANCH" != 'master' ]]; then
27     # for none-merge deployments
28     # checkout the commit that was used for building the downloaded artifact
29     # to make sure the ISO and deployment mechanism uses same versions
30     echo "Checking out $OPNFV_GIT_SHA1"
31     git checkout $OPNFV_GIT_SHA1 --quiet
32 fi
33
34 # set deployment parameters
35 export TMPDIR=$HOME/tmpdir
36 BRIDGE=${BRIDGE:-pxebr}
37 LAB_NAME=${NODE_NAME/-*}
38 POD_NAME=${NODE_NAME/*-}
39
40 if [[ "$NODE_NAME" =~ "virtual" ]]; then
41     POD_NAME="virtual_kvm"
42 fi
43
44 # we currently support ericsson, intel, lf and zte labs
45 if [[ ! "$LAB_NAME" =~ (ericsson|intel|lf|zte) ]]; then
46     echo "Unsupported/unidentified lab $LAB_NAME. Cannot continue!"
47     exit 1
48 else
49     echo "Using configuration for $LAB_NAME"
50 fi
51
52 # create TMPDIR if it doesn't exist
53 export TMPDIR=$HOME/tmpdir
54 mkdir -p $TMPDIR
55
56 # change permissions down to TMPDIR
57 chmod a+x $HOME
58 chmod a+x $TMPDIR
59
60 # clone the securedlab repo
61 cd $WORKSPACE
62 echo "Cloning securedlab repo $BRANCH"
63 git clone ssh://jenkins-ericsson@gerrit.opnfv.org:29418/securedlab --quiet \
64     --branch $BRANCH
65
66 # Source local_env if present, which contains POD-specific config
67 local_env="${WORKSPACE}/securedlab/labs/$LAB_NAME/$POD_NAME/fuel/config/local_env"
68 if [ -e "${local_env}" ]; then
69     echo "-- Sourcing local environment file"
70     source "${local_env}"
71 fi
72
73 # log file name
74 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
75
76 # construct the command
77 DEPLOY_COMMAND="sudo $WORKSPACE/ci/deploy.sh -b file://$WORKSPACE/securedlab \
78     -l $LAB_NAME -p $POD_NAME -s $DEPLOY_SCENARIO -i file://$WORKSPACE/opnfv.iso \
79     -B ${DEFAULT_BRIDGE:-${BRIDGE}} -S $TMPDIR -L $WORKSPACE/$FUEL_LOG_FILENAME"
80
81 # log info to console
82 echo "Deployment parameters"
83 echo "--------------------------------------------------------"
84 echo "Scenario: $DEPLOY_SCENARIO"
85 echo "Lab: $LAB_NAME"
86 echo "POD: $POD_NAME"
87 [[ "$BRANCH" != 'master' ]] && echo "ISO: ${OPNFV_ARTIFACT_URL/*\/}"
88 echo
89 echo "Starting the deployment using $INSTALLER_TYPE. This could take some time..."
90 echo "--------------------------------------------------------"
91 echo
92
93 # start the deployment
94 echo "Issuing command"
95 echo "$DEPLOY_COMMAND"
96 echo
97
98 $DEPLOY_COMMAND
99 exit_code=$?
100
101 echo
102 echo "--------------------------------------------------------"
103 echo "Deployment is done!"
104
105 # upload logs for baremetal deployments
106 # work with virtual deployments is still going on so we skip that for the timebeing
107 if [[ "$JOB_NAME" =~ (baremetal-daily|baremetal-weekly) ]]; then
108     echo "Uploading deployment logs"
109     gsutil cp $WORKSPACE/$FUEL_LOG_FILENAME gs://$GS_URL/logs/$FUEL_LOG_FILENAME > /dev/null 2>&1
110     echo "Logs are available as http://$GS_URL/logs/$FUEL_LOG_FILENAME"
111 fi
112
113 if [[ $exit_code -ne 0 ]]; then
114     echo "Deployment failed!"
115     exit $exit_code
116 else
117     echo "Deployment is successful!"
118     exit 0
119 fi