Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 5 | source /var/onap/functions |
Victor Morales | 165f3e3 | 2017-08-08 16:24:05 -0500 | [diff] [blame] | 6 | |
Victor Morales | dcfa2cf | 2017-08-30 19:12:14 -0500 | [diff] [blame] | 7 | policy_src_folder=$git_src_folder/policy |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame^] | 8 | policy_repos=("policy/api" "policy/common" "policy/docker" \ |
| 9 | "policy/drools-applications" "policy/drools-pdp" "policy/engine" \ |
| 10 | "policy/gui" "policy/pap" "policy/pdp") |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 11 | |
| 12 | # clone_all_policy_repos() - Function that clones Policy source repo. |
| 13 | function clone_all_policy_repos { |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame^] | 14 | for repo in ${policy_repos[@]}; do |
| 15 | clone_repo $repo $policy_src_folder${repo#*policy} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 16 | done |
| 17 | } |
| 18 | |
Victor Morales | 9651265 | 2017-08-16 13:44:28 -0500 | [diff] [blame] | 19 | # compile_all_policy_repos() - Function that compiles Policy source repo. |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 20 | function compile_all_policy_repos { |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame^] | 21 | for repo in ${policy_repos[@]}; do |
| 22 | compile_src $policy_src_folder${repo#*policy} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 23 | done |
| 24 | } |
| 25 | |
Victor Morales | 9651265 | 2017-08-16 13:44:28 -0500 | [diff] [blame] | 26 | # _build_policy_images() - Function that build Policy docker images from source code |
| 27 | function _build_policy_images { |
Victor Morales | dcfa2cf | 2017-08-30 19:12:14 -0500 | [diff] [blame] | 28 | compile_src $policy_src_folder/docker |
| 29 | pushd $policy_src_folder/docker |
Victor Morales | 9651265 | 2017-08-16 13:44:28 -0500 | [diff] [blame] | 30 | 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 |
| 40 | function get_policy_images { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 41 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 9651265 | 2017-08-16 13:44:28 -0500 | [diff] [blame] | 42 | _build_policy_images |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 43 | 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 Morales | 9651265 | 2017-08-16 13:44:28 -0500 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | # install_policy() - Function that clones and installs the Policy services from source code |
| 52 | function install_policy { |
Victor Morales | dcfa2cf | 2017-08-30 19:12:14 -0500 | [diff] [blame] | 53 | pushd $policy_src_folder/docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 54 | chmod +x config/drools/drools-tweaks.sh |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 55 | 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 |
| 62 | function init_policy { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 63 | if [[ "$clone_repo" == "True" ]]; then |
| 64 | clone_all_policy_repos |
| 65 | if [[ "$compile_repo" == "True" ]]; then |
| 66 | compile_all_policy_repos |
| 67 | fi |
Victor Morales | 165f3e3 | 2017-08-08 16:24:05 -0500 | [diff] [blame] | 68 | fi |
| 69 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 70 | if [[ "$skip_get_images" == "False" ]]; then |
| 71 | get_policy_images |
| 72 | if [[ "$skip_install" == "False" ]]; then |
| 73 | install_policy |
| 74 | fi |
| 75 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 76 | } |