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 | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 6 | |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 7 | sdnc_src_folder=$git_src_folder/openecomp/sdnc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 8 | sdnc_repos=("core" "adaptors" "northbound" "plugins" "oam") |
| 9 | |
| 10 | # clone_all_sdnc_repos() - Function that clones SDNC source repo. |
| 11 | function clone_all_sdnc_repos { |
| 12 | for dirc in ${sdnc_repos[@]}; do |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 13 | clone_repo sdnc/$dirc $sdnc_src_folder/$dirc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 14 | done |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 15 | } |
| 16 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 17 | # compile_all_sdnc_repos() - Function that compiles SDNC source repo. |
| 18 | function compile_all_sdnc_repos { |
| 19 | for dirc in ${sdnc_repos[@]}; do |
| 20 | if [[ "$dirc" == "core" ]]; then |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 21 | compile_src $sdnc_src_folder/core/rootpom |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 22 | fi |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 23 | compile_src $sdnc_src_folder/$dirc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 24 | done |
| 25 | } |
| 26 | |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 27 | # _build_sdnc_images() - Builds SDNC images from source code |
| 28 | function _build_sdnc_images { |
| 29 | local folder=$sdnc_src_folder/oam |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 30 | |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 31 | install_package unzip |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 32 | clone_repo sdnc/oam $folder |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 33 | # The OAM code depends on all the SDNC repos which should be downloaded and compiled first |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 34 | if [[ "$compile_repo" != "True" ]]; then |
| 35 | compile_src $folder |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 36 | fi |
| 37 | for dirc in ubuntu sdnc admportal dgbuilder; do |
| 38 | build_docker_image $folder/installation/$dirc |
| 39 | done |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | # get_sdnc_images() - Build or retrieve necessary images |
| 43 | function get_sdnc_images { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 44 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 45 | _build_sdnc_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 46 | else |
| 47 | pull_openecomp_image sdnc-image openecomp/sdnc-image:latest |
| 48 | pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest |
| 49 | pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest |
| 50 | fi |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 51 | pull_docker_image mysql/mysql-server:5.6 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | # install_sdnc() - Download and install SDNC services from source code |
| 55 | function install_sdnc { |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 56 | clone_repo sdnc/oam $sdnc_src_folder/oam |
| 57 | pushd $sdnc_src_folder/oam/installation/src/main/yaml |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 58 | install_docker_compose |
| 59 | /opt/docker/docker-compose up -d |
| 60 | popd |
| 61 | } |
| 62 | |
| 63 | # init_sdnc() - Function that initialize SDNC services |
| 64 | function init_sdnc { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 65 | start_ODL |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 66 | if [[ "$clone_repo" == "True" ]]; then |
| 67 | clone_all_sdnc_repos |
| 68 | if [[ "$compile_repo" == "True" ]]; then |
| 69 | compile_all_sdnc_repos |
| 70 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 71 | fi |
| 72 | get_sdnc_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 73 | install_sdnc |
| 74 | } |