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