d6726c7a72576ac6a08c1f3eddfdd2490e3f7156
[integration/csit.git] / plans / policy / xacml-pdp / setup.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
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 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 source ${SCRIPTS}/policy/config/policy-csit.conf
21 export POLICY_MARIADB_VER
22 echo ${GERRIT_BRANCH}
23 echo ${POLICY_MARIADB_VER}
24
25 echo "Uninstall docker-py and reinstall docker."
26 pip uninstall -y docker-py
27 pip uninstall -y docker
28 pip install -U docker==2.7.0
29
30 # the directory of the script
31 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
32 echo ${DIR}
33
34 # the temp directory used, within $DIR
35 # omit the -p parameter to create a temporal directory in the default location
36 WORK_DIR=`mktemp -d -p "$DIR"`
37 echo ${WORK_DIR}
38
39 cd ${WORK_DIR}
40
41 # check if tmp dir was created
42 if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
43     echo "Could not create temp dir"
44     exit 1
45 fi
46
47 SCR_DMAAP=${SCRIPTS}/policy/drools-apps
48
49 sudo apt-get -y install libxml2-utils
50 bash ${SCRIPTS}/policy/policy-models-dmaap-sim.sh
51
52 POLICY_API_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
53 export POLICY_API_VERSION="${POLICY_API_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
54 POLICY_PAP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
55 export POLICY_PAP_VERSION="${POLICY_PAP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
56 POLICY_XACML_PDP_VERSION_EXTRACT="$(curl -q --silent https://git.onap.org/policy/xacml-pdp/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
57 export POLICY_XACML_PDP_VERSION="${POLICY_XACML_PDP_VERSION_EXTRACT:0:3}-SNAPSHOT-latest"
58
59 echo ${POLICY_API_VERSION}
60 echo ${POLICY_PAP_VERSION}
61 echo ${POLICY_XACML_PDP_VERSION}
62
63 # Adding this waiting container due to race condition between pap and mariadb
64 docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_dependencies
65
66 # now bring everything else up
67 docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_all
68
69 unset http_proxy https_proxy
70
71 POLICY_API_IP=`get-instance-ip.sh policy-api`
72 MARIADB_IP=`get-instance-ip.sh mariadb`
73 POLICY_PDPX_IP=`get-instance-ip.sh policy-xacml-pdp`
74 DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
75 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
76
77 echo PDP IP IS ${POLICY_PDPX_IP}
78 echo API IP IS ${POLICY_API_IP}
79 echo PAP IP IS ${POLICY_PAP_IP}
80 echo MARIADB IP IS ${MARIADB_IP}
81 echo DMAAP_IP IS ${DMAAP_IP}
82
83 DATA2=${WORKSPACE}/dmaap-sim/models/models-examples/src/main/resources/policies
84
85 ROBOT_VARIABLES=""
86 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v SCR_DMAAP:${SCR_DMAAP}"
87 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v DATA2:${DATA2}"
88 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_PDPX_IP:${POLICY_PDPX_IP}"
89 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_API_IP:${POLICY_API_IP}"
90 ROBOT_VARIABLES="${ROBOT_VARIABLES} -v POLICY_PAP_IP:${POLICY_PAP_IP}"