blob: be4cb2c188d30a45bcc5e1930dfa25fd8aa53f66 [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
Victor Moralesdcfa2cf2017-08-30 19:12:14 -05007policy_src_folder=$git_src_folder/policy
Victor Moralesf6c0bf12017-10-27 11:08:04 -07008policy_repos=("policy/api" "policy/common" "policy/docker" \
9"policy/drools-applications" "policy/drools-pdp" "policy/engine" \
10"policy/gui" "policy/pap" "policy/pdp")
Victor Moralesdd074802017-07-26 16:06:35 -050011
12# clone_all_policy_repos() - Function that clones Policy source repo.
13function clone_all_policy_repos {
Victor Moralesf6c0bf12017-10-27 11:08:04 -070014 for repo in ${policy_repos[@]}; do
15 clone_repo $repo $policy_src_folder${repo#*policy}
Victor Moralesdd074802017-07-26 16:06:35 -050016 done
17}
18
Victor Morales96512652017-08-16 13:44:28 -050019# compile_all_policy_repos() - Function that compiles Policy source repo.
Victor Moralesdd074802017-07-26 16:06:35 -050020function compile_all_policy_repos {
Victor Moralesf6c0bf12017-10-27 11:08:04 -070021 for repo in ${policy_repos[@]}; do
22 compile_src $policy_src_folder${repo#*policy}
Victor Moralesdd074802017-07-26 16:06:35 -050023 done
24}
25
Victor Morales96512652017-08-16 13:44:28 -050026# _build_policy_images() - Function that build Policy docker images from source code
27function _build_policy_images {
Victor Moralesdcfa2cf2017-08-30 19:12:14 -050028 compile_src $policy_src_folder/docker
29 pushd $policy_src_folder/docker
Victor Morales96512652017-08-16 13:44:28 -050030 install_maven
31 mvn prepare-package
32 cp -r target/policy-pe/* policy-pe/
33 cp -r target/policy-drools/* policy-drools
34 install_docker
35 bash docker_verify.sh
36 popd
37}
38
39# get_policy_images() - Function that retrieves Policy docker images
40function get_policy_images {
Victor Moralesdd074802017-07-26 16:06:35 -050041 if [[ "$build_image" == "True" ]]; then
Victor Morales96512652017-08-16 13:44:28 -050042 _build_policy_images
Victor Moralesdd074802017-07-26 16:06:35 -050043 else
44 pull_onap_image policy/policy-db onap/policy/policy-db:latest
45 pull_onap_image policy/policy-pe onap/policy/policy-pe:latest
46 pull_onap_image policy/policy-drools onap/policy/policy-drools:latest
47 pull_onap_image policy/policy-nexus onap/policy/policy-nexus:latest
48 fi
Victor Morales96512652017-08-16 13:44:28 -050049}
50
51# install_policy() - Function that clones and installs the Policy services from source code
52function install_policy {
Victor Moralesdcfa2cf2017-08-30 19:12:14 -050053 pushd $policy_src_folder/docker
Victor Morales89ce3212017-06-16 18:32:48 -050054 chmod +x config/drools/drools-tweaks.sh
Victor Morales89ce3212017-06-16 18:32:48 -050055 echo $IP_ADDRESS > config/pe/ip_addr.txt
56 install_docker_compose
57 /opt/docker/docker-compose up -d
58 popd
59}
60
61# init_policy() - Function that initialize Policy services
62function init_policy {
Idan Amit1690e082017-08-20 08:58:14 +030063 if [[ "$clone_repo" == "True" ]]; then
64 clone_all_policy_repos
65 if [[ "$compile_repo" == "True" ]]; then
66 compile_all_policy_repos
67 fi
Victor Morales165f3e32017-08-08 16:24:05 -050068 fi
69
Victor Morales6a919972017-09-28 18:29:54 -070070 if [[ "$skip_get_images" == "False" ]]; then
71 get_policy_images
72 if [[ "$skip_install" == "False" ]]; then
73 install_policy
74 fi
75 fi
Victor Morales89ce3212017-06-16 18:32:48 -050076}