Pull correct docker images.
[integration/csit.git] / plans / policy / xacml-pdp / setup.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 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 GERRIT_BRANCH=$(cat ${SCRIPTS}/policy/config/policy-csit.conf | cut -d "=" -f2)
21 echo $GERRIT_BRANCH
22
23 echo "Uninstall docker-py and reinstall docker."
24 pip uninstall -y docker-py
25 pip uninstall -y docker
26 pip install -U docker==2.7.0
27
28 # the directory of the script
29 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
30 echo ${DIR}
31
32 # the temp directory used, within $DIR
33 # omit the -p parameter to create a temporal directory in the default location
34 WORK_DIR=`mktemp -d -p "$DIR"`
35 echo ${WORK_DIR}
36
37 cd ${WORK_DIR}
38
39 # check if tmp dir was created
40 if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
41     echo "Could not create temp dir"
42     exit 1
43 fi
44
45 # bring down maven
46 mkdir maven
47 cd maven
48 curl -O http://apache.claz.org/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
49 tar -xzvf apache-maven-3.3.9-bin.tar.gz
50 ls -l
51 export PATH=${PATH}:${WORK_DIR}/maven/apache-maven-3.3.9/bin
52 ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn -v
53 cd ..
54
55 git clone http://gerrit.onap.org/r/oparent
56 git clone --depth 1 https://gerrit.onap.org/r/policy/models -b $GERRIT_BRANCH
57 cd models/models-sim/models-sim-dmaap
58 ${WORK_DIR}/maven/apache-maven-3.3.9/bin/mvn clean install -DskipTests  --settings ${WORK_DIR}/oparent/settings.xml
59 bash ./src/main/package/docker/docker_build.sh
60 cd ${WORKSPACE}
61 rm -rf ${WORK_DIR}
62 sleep 3
63
64
65
66 sudo apt-get -y install libxml2-utils
67 export POLICY_API_VERSION="$(curl --silent https://git.onap.org/policy/api/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
68 export POLICY_PAP_VERSION="$(curl --silent https://git.onap.org/policy/pap/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
69 export POLICY_XACML_PDP_VERSION="$(curl --silent https://git.onap.org/policy/xacml-pdp/plain/pom.xml?h=${GERRIT_BRANCH} | xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' -)"
70
71 echo $POLICY_API_VERSION
72 echo $POLICY_PAP_VERSION
73 echo $POLICY_XACML_PDP_VERSION
74 # Adding this waiting container due to race condition between pap and mariadb
75 docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_dependencies
76
77 #Configure the database
78 docker exec -it mariadb  chmod +x /docker-entrypoint-initdb.d/db.sh
79 docker exec -it mariadb  /docker-entrypoint-initdb.d/db.sh
80
81 # now bring everything else up
82 docker-compose -f ${WORKSPACE}/scripts/policy/policy-xacml-pdp/docker-compose-pdpx.yml run --rm start_all
83
84 unset http_proxy https_proxy
85
86 POLICY_API_IP=`get-instance-ip.sh policy-api`
87 MARIADB_IP=`get-instance-ip.sh mariadb`
88 POLICY_PDPX_IP=`get-instance-ip.sh policy-xacml-pdp`
89 DMAAP_IP=`get-instance-ip.sh dmaap-simulator`
90 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
91
92
93 echo PDP IP IS ${POLICY_PDPX_IP}
94 echo API IP IS ${POLICY_API_IP}
95 echo PAP IP IS ${POLICY_PAP_IP}
96 echo MARIADB IP IS ${MARIADB_IP}
97 echo DMAAP_IP IS ${DMAAP_IP}
98
99 ROBOT_VARIABLES="-v POLICY_PDPX_IP:${POLICY_PDPX_IP} -v POLICY_API_IP:${POLICY_API_IP} -v POLICY_PAP_IP:${POLICY_PAP_IP}"