c0cdc3dc2b3a32648ab5dddbd5f4590f3118aeee
[releng.git] / jjb / fuel / fuel-deploy.sh
1 #!/bin/bash
2 # SPDX-license-identifier: Apache-2.0
3 ##############################################################################
4 # Copyright (c) 2018 Ericsson AB, Mirantis Inc., Enea Software 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 # set deployment parameters
16 export TMPDIR=${HOME}/tmpdir
17 # shellcheck disable=SC2153
18 LAB_NAME=${NODE_NAME/-*}
19 # shellcheck disable=SC2153
20 POD_NAME=${NODE_NAME/*-}
21
22 # Fuel currently supports arm, enea, ericsson, intel, lf, unh and zte labs
23 if [[ ! "${LAB_NAME}" =~ (arm|enea|ericsson|intel|lf|unh|zte) ]]; then
24     echo "Unsupported/unidentified lab ${LAB_NAME}. Cannot continue!"
25     exit 1
26 fi
27
28 echo "Using configuration for ${LAB_NAME}"
29
30 # create TMPDIR if it doesn't exist, change permissions
31 mkdir -p "${TMPDIR}"
32 sudo chmod a+x "${HOME}" "${TMPDIR}"
33
34 cd "${WORKSPACE}" || exit 1
35
36 # log file name
37 FUEL_LOG_FILENAME="${JOB_NAME}_${BUILD_NUMBER}.log.tar.gz"
38
39 # Limited scope for vPOD verify jobs running on armband-virtual
40 [[ ! "${JOB_NAME}" =~ verify-deploy-virtual-arm64 ]] || EXTRA_ARGS='-e'
41
42 # construct the command
43 DEPLOY_COMMAND="${WORKSPACE}/ci/deploy.sh \
44     -l ${LAB_NAME} -p ${POD_NAME} -s ${DEPLOY_SCENARIO} \
45     -S ${TMPDIR} ${EXTRA_ARGS:-} \
46     -L ${WORKSPACE}/${FUEL_LOG_FILENAME}"
47
48 # log info to console
49 echo "Deployment parameters"
50 echo "--------------------------------------------------------"
51 echo "Scenario: ${DEPLOY_SCENARIO}"
52 echo "Lab: ${LAB_NAME}"
53 echo "POD: ${POD_NAME}"
54 echo
55 echo "Starting the deployment using ${INSTALLER_TYPE}. This could take some time..."
56 echo "--------------------------------------------------------"
57 echo
58
59 # start the deployment
60 echo "Issuing command"
61 echo "${DEPLOY_COMMAND}"
62 echo
63
64 ${DEPLOY_COMMAND}
65 exit_code=$?
66
67 echo
68 echo "--------------------------------------------------------"
69 echo "Deployment is done!"
70
71 # upload logs for baremetal deployments
72 # work with virtual deployments is still going on, so skip that for now
73 if [[ "${JOB_NAME}" =~ baremetal-daily ]]; then
74     echo "Uploading deployment logs"
75     gsutil cp "${WORKSPACE}/${FUEL_LOG_FILENAME}" \
76         "gs://${GS_URL}/logs/${FUEL_LOG_FILENAME}" > /dev/null 2>&1
77     echo "Logs are available at http://${GS_URL}/logs/${FUEL_LOG_FILENAME}"
78 fi
79
80 if [[ "${exit_code}" -ne 0 ]]; then
81     echo "Deployment failed!"
82     exit "${exit_code}"
83 fi
84
85 echo "Deployment is successful!"
86 exit 0