Pull correct docker images.
[integration/csit.git] / plans / policy / pap / setup.sh
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 Nordix Foundation.
4 #  Modifications Copyright (C) 2019 AT&T Intellectual Property.
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 GERRIT_BRANCH=$(cat ${SCRIPTS}/policy/config/policy-csit.conf | cut -d "=" -f2)
22 echo $GERRIT_BRANCH
23
24 echo "Uninstall docker-py and reinstall docker."
25 pip uninstall -y docker-py
26 pip uninstall -y docker
27 pip install -U docker==2.7.0
28
29
30 sudo apt-get -y install libxml2-utils
31 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()' -)"
32 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()' -)"
33 echo $POLICY_API_VERSION
34 echo $POLICY_PAP_VERSION
35 # Adding this waiting container due to race condition between pap and mariadb
36 docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-pap.yml run --rm start_dependencies
37
38 #Configure the database
39 docker exec -it mariadb  chmod +x /docker-entrypoint-initdb.d/db.sh
40 docker exec -it mariadb  /docker-entrypoint-initdb.d/db.sh
41
42 # now bring everything else up
43 docker-compose -f ${WORKSPACE}/scripts/policy/docker-compose-pap.yml run --rm start_all
44
45 unset http_proxy https_proxy
46
47
48 POLICY_PAP_IP=`get-instance-ip.sh policy-pap`
49 POLICY_API_IP=`get-instance-ip.sh policy-api`
50 MARIADB_IP=`get-instance-ip.sh mariadb`
51
52 echo PAP IP IS ${POLICY_PAP_IP}
53 echo API IP IS ${POLICY_API_IP}
54 echo MARIADB IP IS ${MARIADB_IP}
55
56 #Add policy type and policy to the database via the Policy Api
57 AUTH="healthcheck:zb!XztG34"
58 CONTYPE="Content-Type: application/json"
59 URL=https://${POLICY_API_IP}:6969/policy/api/v1/policytypes
60 CONFIGDIR=${WORKSPACE}/scripts/policy/config/pap
61 POLTYPE=onap.policies.monitoring.cdap.tca.hi.lo.app
62
63 SRCFILE=${CONFIGDIR}/${POLTYPE}.json
64 curl -sS -k --user "${AUTH}" -H "${CONTYPE}" -d @${SRCFILE} $URL
65
66 URL2=${URL}/${POLTYPE}/versions/1.0.0/policies
67 SRCFILE=${CONFIGDIR}/vCPE.policy.monitoring.input.tosca.json
68 curl -sS -k --user "${AUTH}" -H "${CONTYPE}" -d @${SRCFILE} $URL2
69
70
71 ROBOT_VARIABLES="-v POLICY_PAP_IP:${POLICY_PAP_IP}"