f2faad54cc18f3ffaa01a2b282a9bb3d2700295b
[infra/cicd.git] / jjb / cloud-infra / onap-deploy.sh
1 #!/bin/bash
2
3 # ============LICENSE_START=======================================================
4 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
20
21 set -o errexit
22 set -o nounset
23
24 cd $WORKSPACE
25 /bin/rm -f ../inventory.ini
26 echo "Info: Preparing for ONAP deployment"
27
28 # checkout given engine version
29 if [[ "$ENGINE_VERSION" != "master" ]]; then
30   echo "Warning: Checking out $ENGINE_VERSION"
31   git checkout -q $ENGINE_VERSION
32 fi
33
34 # checkout given engine refspec
35 if [[ "$ENGINE_REFSPEC" != "master" ]]; then
36   echo "Warning: Checking out engine $ENGINE_REFSPEC"
37   echo "-------------------------------------------------------------------------"
38   git fetch https://gerrit.nordix.org/infra/engine $ENGINE_REFSPEC && git checkout -q FETCH_HEAD
39   echo "-------------------------------------------------------------------------"
40 fi
41
42 # update scenario version and refspec in engine/envine/var/sdf.yml
43 if [[ "$DEPLOY_SCENARIO_VERSION" != "master" && "$DEPLOY_SCENARIO_REFSPEC" != "master" ]]; then
44   echo "Warning: Adding $DEPLOY_SCENARIO_VERSION as scenario version and $DEPLOY_SCENARIO_REFSPEC as scenario refspec"
45 cat << EOF > $WORKSPACE/engine/var/sdf.yml
46 scenario:
47   $DEPLOY_SCENARIO:
48     scm: git
49     src: https://gerrit.nordix.org/infra/swconfig.git
50     version: $DEPLOY_SCENARIO_VERSION
51     refspec: $DEPLOY_SCENARIO_REFSPEC
52     provisioners:
53       - $PROVISIONER_TYPE
54     installers:
55       $INSTALLER_TYPE:
56         role: scenarios/$DEPLOY_SCENARIO/$INSTALLER_TYPE/role/$DEPLOY_SCENARIO
57         distros:
58           - $DISTRO
59 EOF
60
61   echo "Info: Temporary SDF content"
62   echo "-------------------------------------------------------------------------"
63   cat $WORKSPACE/engine/var/sdf.yml
64   echo "-------------------------------------------------------------------------"
65 fi
66
67 echo "Info: Starting K8S cluster creation and ONAP deployment"
68 echo "-------------------------------------------------------------------------"
69 cd $WORKSPACE
70 ./engine/deploy.sh -r $PROVISIONER_TYPE -u /tmp/openrc \
71   -s $DEPLOY_SCENARIO -e $HEAT_ENVIRONMENT_FILE
72
73 cd $WORKSPACE
74 /bin/cp /opt/engine/.cache/config/inventory.ini ../inventory.ini
75 # vim: set ts=2 sw=2 expandtab: