blob: 65a65a186568dbaa6dfa75b3b529d0760669961a [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Moralesdd074802017-07-26 16:06:35 -05003source /var/onap/functions
Victor Morales165f3e32017-08-08 16:24:05 -05004
Victor Moralesdcfa2cf2017-08-30 19:12:14 -05005policy_src_folder=$git_src_folder/policy
Victor Moralesf6c0bf12017-10-27 11:08:04 -07006policy_repos=("policy/api" "policy/common" "policy/docker" \
7"policy/drools-applications" "policy/drools-pdp" "policy/engine" \
8"policy/gui" "policy/pap" "policy/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 Moralesf6c0bf12017-10-27 11:08:04 -070012 for repo in ${policy_repos[@]}; do
13 clone_repo $repo $policy_src_folder${repo#*policy}
Victor Moralesdd074802017-07-26 16:06:35 -050014 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 Moralesf6c0bf12017-10-27 11:08:04 -070019 for repo in ${policy_repos[@]}; do
20 compile_src $policy_src_folder${repo#*policy}
Victor Moralesdd074802017-07-26 16:06:35 -050021 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 {
Victor Moralesdcfa2cf2017-08-30 19:12:14 -050026 compile_src $policy_src_folder/docker
27 pushd $policy_src_folder/docker
Victor Morales96512652017-08-16 13:44:28 -050028 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 Moralesdcfa2cf2017-08-30 19:12:14 -050051 pushd $policy_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 Morales6a919972017-09-28 18:29:54 -070068 if [[ "$skip_get_images" == "False" ]]; then
69 get_policy_images
70 if [[ "$skip_install" == "False" ]]; then
71 install_policy
72 fi
73 fi
Victor Morales89ce3212017-06-16 18:32:48 -050074}