[fuel] deploy: whitelist itri lab
[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, zte and itri labs
23 if [[ ! "${LAB_NAME}" =~ (arm|enea|ericsson|intel|lf|unh|zte|itri) ]]; 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 # turn on DEBUG mode
43 [[ ${CI_DEBUG,,} == true ]] && EXTRA_ARGS="-D ${EXTRA_ARGS:-}"
44
45 # construct the command
46 DEPLOY_COMMAND="${WORKSPACE}/ci/deploy.sh \
47     -l ${LAB_NAME} -p ${POD_NAME} -s ${DEPLOY_SCENARIO} \
48     -S ${TMPDIR} ${EXTRA_ARGS:-} \
49     -L ${WORKSPACE}/${FUEL_LOG_FILENAME}"
50
51 # log info to console
52 echo "Deployment parameters"
53 echo "--------------------------------------------------------"
54 echo "Scenario: ${DEPLOY_SCENARIO}"
55 echo "Lab: ${LAB_NAME}"
56 echo "POD: ${POD_NAME}"
57 echo
58 echo "Starting the deployment using ${INSTALLER_TYPE}. This could take some time..."
59 echo "--------------------------------------------------------"
60 echo
61
62 # start the deployment
63 echo "Issuing command"
64 echo "${DEPLOY_COMMAND}"
65 echo
66
67 ${DEPLOY_COMMAND}
68 exit_code=$?
69
70 echo
71 echo "--------------------------------------------------------"
72 echo "Deployment is done!"
73
74 # upload logs for baremetal deployments
75 # work with virtual deployments is still going on, so skip that for now
76 if [[ "${JOB_NAME}" =~ baremetal-daily ]]; then
77     echo "Uploading deployment logs"
78     gsutil cp "${WORKSPACE}/${FUEL_LOG_FILENAME}" \
79         "gs://${GS_URL}/logs/${FUEL_LOG_FILENAME}" > /dev/null 2>&1
80     echo "Logs are available at http://${GS_URL}/logs/${FUEL_LOG_FILENAME}"
81 fi
82
83 if [[ "${exit_code}" -ne 0 ]]; then
84     echo "Deployment failed!"
85     exit "${exit_code}"
86 fi
87
88 echo "Deployment is successful!"
89 exit 0