blob: 5b3e58109ba73e372e15e0759a763c78673c05b0 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
Victor Moralesdd074802017-07-26 16:06:35 -05005source /var/onap/functions
Victor Morales165f3e32017-08-08 16:24:05 -05006
7src_folder=$git_src_folder/policy
8policy_repos=("api" "common" "docker" "drools-applications" "drools-pdp" "engine" "gui" "pap" "pdp")
Victor Moralesdd074802017-07-26 16:06:35 -05009
10# clone_all_policy_repos() - Function that clones Policy source repo.
11function clone_all_policy_repos {
Victor Morales96512652017-08-16 13:44:28 -050012 for dirc in ${policy_repos[@]}; do
Victor Moralesdd074802017-07-26 16:06:35 -050013 clone_repo policy/$dirc $src_folder/$dirc
14 done
15}
16
Victor Morales96512652017-08-16 13:44:28 -050017# compile_all_policy_repos() - Function that compiles Policy source repo.
Victor Moralesdd074802017-07-26 16:06:35 -050018function compile_all_policy_repos {
Victor Morales165f3e32017-08-08 16:24:05 -050019 for dirc in ${aai_repos[@]}; do
Victor Moralesdd074802017-07-26 16:06:35 -050020 compile_src $src_folder/$dirc
21 done
22}
23
Victor Morales96512652017-08-16 13:44:28 -050024# _build_policy_images() - Function that build Policy docker images from source code
25function _build_policy_images {
26 compile_src $src_folder/docker
27 pushd $src_folder/docker
28 install_maven
29 mvn prepare-package
30 cp -r target/policy-pe/* policy-pe/
31 cp -r target/policy-drools/* policy-drools
32 install_docker
33 bash docker_verify.sh
34 popd
35}
36
37# get_policy_images() - Function that retrieves Policy docker images
38function get_policy_images {
Victor Moralesdd074802017-07-26 16:06:35 -050039 if [[ "$build_image" == "True" ]]; then
Victor Morales96512652017-08-16 13:44:28 -050040 _build_policy_images
Victor Moralesdd074802017-07-26 16:06:35 -050041 else
42 pull_onap_image policy/policy-db onap/policy/policy-db:latest
43 pull_onap_image policy/policy-pe onap/policy/policy-pe:latest
44 pull_onap_image policy/policy-drools onap/policy/policy-drools:latest
45 pull_onap_image policy/policy-nexus onap/policy/policy-nexus:latest
46 fi
Victor Morales96512652017-08-16 13:44:28 -050047}
48
49# install_policy() - Function that clones and installs the Policy services from source code
50function install_policy {
Victor Moralesdd074802017-07-26 16:06:35 -050051 pushd $src_folder/docker
Victor Morales89ce3212017-06-16 18:32:48 -050052 chmod +x config/drools/drools-tweaks.sh
Victor Morales89ce3212017-06-16 18:32:48 -050053 echo $IP_ADDRESS > config/pe/ip_addr.txt
54 install_docker_compose
55 /opt/docker/docker-compose up -d
56 popd
57}
58
59# init_policy() - Function that initialize Policy services
60function init_policy {
Idan Amit1690e082017-08-20 08:58:14 +030061 if [[ "$clone_repo" == "True" ]]; then
62 clone_all_policy_repos
63 if [[ "$compile_repo" == "True" ]]; then
64 compile_all_policy_repos
65 fi
Victor Morales165f3e32017-08-08 16:24:05 -050066 fi
67
Victor Morales96512652017-08-16 13:44:28 -050068 get_policy_images
Victor Morales89ce3212017-06-16 18:32:48 -050069 install_policy
70}