Merge "Adding a new verification job for testapi UI."
[releng.git] / jjb / daisy4nfv / daisy-deploy.sh
1 #!/bin/bash
2 set -o nounset
3 set -o pipefail
4
5 echo "--------------------------------------------------------"
6 echo "This is $INSTALLER_TYPE deploy job!"
7 echo "--------------------------------------------------------"
8
9 DEPLOY_SCENARIO=${DEPLOY_SCENARIO:-"os-nosdn-nofeature-noha"}
10 BRIDGE=${BRIDGE:-pxebr}
11 LAB_NAME=${NODE_NAME/-*}
12 POD_NAME=${NODE_NAME/*-}
13 deploy_ret=0
14
15 if [[ ! "$NODE_NAME" =~ "-virtual" ]] && [[ ! "$LAB_NAME" =~ (zte) ]]; then
16     echo "Unsupported lab $LAB_NAME for now, Cannot continue!"
17     exit $deploy_ret
18 fi
19
20 # clone the securedlab/pharos repo
21 cd $WORKSPACE
22
23 # There are no PDFs in euphrates branch of pharos repo.
24 if [[  "$BRANCH" =~ "euphrates" ]]; then
25     CONFIG_REPO_NAME=securedlab
26 else
27     CONFIG_REPO_NAME=pharos
28 fi
29
30 if [[  "$BRANCH" =~ "master" ]]; then
31     DOCTOR_OPT="-d 1"
32 else
33     DOCTOR_OPT=""
34 fi
35
36 LABS_DIR=/var/tmp/opnfv-${CONFIG_REPO_NAME}
37
38 echo "Cloning ${CONFIG_REPO_NAME} repo $BRANCH to $LABS_DIR"
39 sudo rm -rf $LABS_DIR
40 git clone ssh://jenkins-zte@gerrit.opnfv.org:29418/${CONFIG_REPO_NAME} \
41     --quiet --branch $BRANCH $LABS_DIR
42
43 DEPLOY_COMMAND="sudo -E ./ci/deploy/deploy.sh -L $LABS_DIR \
44                 -l $LAB_NAME -p $POD_NAME -B $BRIDGE -s $DEPLOY_SCENARIO \
45                 $DOCTOR_OPT"
46
47 # log info to console
48 echo """
49 Deployment parameters
50 --------------------------------------------------------
51 Scenario: $DEPLOY_SCENARIO
52 LAB: $LAB_NAME
53 POD: $POD_NAME
54 BRIDGE: $BRIDGE
55
56 Starting the deployment using $INSTALLER_TYPE. This could take some time...
57 --------------------------------------------------------
58 Issuing command
59 $DEPLOY_COMMAND
60 """
61
62 # start the deployment
63 $DEPLOY_COMMAND
64
65 if [ $? -ne 0 ]; then
66     echo
67     echo "Depolyment failed!"
68     deploy_ret=1
69 else
70     echo
71     echo "--------------------------------------------------------"
72     echo "Deployment done!"
73 fi
74
75 exit $deploy_ret