Merge changes I4960c4a8,I8cc3c2ae
[integration/csit.git] / scripts / sdc-workflow-d / sdc_workflow_d.sh
1 #!/bin/bash
2 #
3 # Copyright 2019 © Samsung Electronics Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 echo "[INFO] This is sdc_workflow_d.sh"
18 # run sdc deployment
19 source "${WORKSPACE}/scripts/sdc/setup_sdc_for_sanity.sh"
20 export ROBOT_VARIABLES
21
22 # fail quick if error
23 set -exo pipefail
24
25 export ENV_NAME='CSIT'
26
27 function iss_true {
28     _value=$(eval echo "\$${1}" | tr '[:upper:]' '[:lower:]')
29
30     case "$_value" in
31         1|yes|true|Y)
32             return 0
33             ;;
34     esac
35
36     return 1
37 }
38
39 # returns 0: if SDC_LOCAL_IMAGES is set to true value
40 # returns 1: otherwise
41 function using_local_workflow_images {
42     iss_true WORKFLOW_LOCAL_IMAGES
43 }
44
45 # cloning workflow directory 
46 mkdir -p "${WORKSPACE}/data/clone/"
47 cd "${WORKSPACE}/data/clone"
48 if using_local_workflow_images && [ -n "$WORKFLOW_LOCAL_GITREPO" ] ; then
49     WORKFLOW_LOCAL_GITREPO=$(realpath "$WORKFLOW_LOCAL_GITREPO")
50     if [ -d "$WORKFLOW_LOCAL_GITREPO" ] ; then
51         rm -rf ./workflow
52         cp -a "$WORKFLOW_LOCAL_GITREPO" ./workflow
53     else
54         echo "[ERROR]: Local git repo for workflow does not exist: ${WORKFLOW_LOCAL_GITREPO}"
55         exit 1
56     fi
57 else
58     git clone --depth 1 "https://github.com/onap/sdc-sdc-workflow-designer.git" -b ${GERRIT_BRANCH}
59 fi
60 # set enviroment variables
61 source ${WORKSPACE}/data/clone/workflow/version.properties
62 export WORKFLOW_RELEASE=$major.$minor-STAGING-latest
63
64 SDC_CS=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sdc-cs)
65 SDC_BE=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' sdc-BE)
66 echo "[INFO] Initialization  of workflow init"
67 echo ${SDC_CS}
68 echo ${SDC_BE}
69 docker run -ti \
70     -e "CS_HOST=${SDC_CS}" \
71     -e "CS_PORT=9042" \
72     -e "CS_AUTHENTICATE=true"\
73     -e "CS_USER=asdc_user" \
74     -e "CS_PASSWORD=Aa1234%^!" nexus3.onap.org:10001/onap/sdc-workflow-init:latest
75
76 echo "[INFO] Initialization  of workflow Backend init"
77 docker run -d --name "workflow-backend" -e "SDC_PROTOCOL=http" \
78     -e "SDC_ENDPOINT=${SDC_BE}:8080" \
79     -e "SDC_USER=workflow" \
80     -e "SDC_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U" \
81     -e "CS_HOSTS=${SDC_CS}" \
82     -e "CS_PORT=9042" \
83     -e "CS_AUTHENTICATE=true"\
84     -e "CS_USER=asdc_user" \
85     -e "CS_PASSWORD=Aa1234%^!" \
86     -e "CS_SSL_ENABLED=false"\
87     -e "SERVER_SSL_ENABLED=false" \
88     --env JAVA_OPTIONS="${BE_JAVA_OPTIONS}" --publish 8384:8080 --publish 10443:8443 --publish 8000:8000 nexus3.onap.org:10001/onap/sdc-workflow-backend:latest
89
90 WORKFLOW_BE=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' workflow-backend)
91 echo "[INFO] starting workflow designer fronend"
92 docker run -d --name "workflow-frontend" \
93     -e BACKEND="http://${WORKFLOW_BE}:8080"\
94     --publish 8484:8080 --publish 11443:8443  nexus3.onap.org:10001/onap/sdc-workflow-frontend:latest
95
96 cp "${WORKSPACE}/data/clone/sdc/sdc-os-chef/environments/plugins-configuration.yaml" \
97     "${WORKSPACE}/data/environments/plugins-configuration.yaml"
98
99 WF_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' workflow-frontend)
100 WFADDR="http:\/\/${WF_IP}:8080\/workflows"
101 echo ${WFADDR}
102 sed -i \
103     -e "s/<%= @workflow_discovery_url %>/${WFADDR}/g" \
104     -e "s/<%= @workflow_source_url %>/${WFADDR}/g" \
105     "${WORKSPACE}/data/environments/plugins-configuration.yaml"
106
107 cp "${WORKSPACE}/data/clone/sdc/sdc-os-chef/scripts/docker_run.sh" "${WORKSPACE}/scripts/sdc-workflow-d/"
108
109 echo "[INFO] restarting sdc-FE with updated plugin configuration file with Worflow host ip"
110 docker stop sdc-FE
111 "${WORKSPACE}/scripts/sdc-workflow-d/docker_run.sh" \
112     --local \
113     -e "${ENV_NAME}" \
114     -p 10001 -d sdc-FE
115 # This file is sourced in another script which is out of our control...
116 set +e
117 set +o pipefail