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 | 664e6e9 | 2017-09-14 12:11:23 -0700 | [diff] [blame] | 4 | source /var/onap/ccsdk |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 5 | |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 6 | sdnc_src_folder=$git_src_folder/openecomp/sdnc |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 7 | sdnc_repos=("sdnc/adaptors" "sdnc/architecture" "sdnc/core" "sdnc/features" \ |
| 8 | "sdnc/northbound" "sdnc/oam" "sdnc/parent" "sdnc/plugins") |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 9 | |
| 10 | # clone_all_sdnc_repos() - Function that clones SDNC source repo. |
| 11 | function clone_all_sdnc_repos { |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 12 | for repo in ${sdnc_repos[@]}; do |
| 13 | clone_repo $repo $sdnc_src_folder${repo#*sdnc} |
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 { |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 19 | for repo in ${sdnc_repos[@]}; do |
| 20 | if [[ "$repo" == "sdnc/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 | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 23 | compile_src $sdnc_src_folder${repo#*sdnc} |
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 | 664e6e9 | 2017-09-14 12:11:23 -0700 | [diff] [blame] | 31 | get_ccsdk_images |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 32 | install_package unzip |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 33 | clone_repo sdnc/oam $folder |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 34 | # 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] | 35 | if [[ "$compile_repo" != "True" ]]; then |
| 36 | compile_src $folder |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 37 | fi |
| 38 | for dirc in ubuntu sdnc admportal dgbuilder; do |
| 39 | build_docker_image $folder/installation/$dirc |
| 40 | done |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | # get_sdnc_images() - Build or retrieve necessary images |
| 44 | function get_sdnc_images { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 45 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 46 | _build_sdnc_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 47 | else |
| 48 | pull_openecomp_image sdnc-image openecomp/sdnc-image:latest |
| 49 | pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest |
| 50 | pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest |
| 51 | fi |
Victor Morales | dbdc30a | 2017-08-17 11:50:42 -0500 | [diff] [blame] | 52 | pull_docker_image mysql/mysql-server:5.6 |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | # install_sdnc() - Download and install SDNC services from source code |
| 56 | function install_sdnc { |
Victor Morales | 65deef2 | 2017-08-18 20:53:42 -0500 | [diff] [blame] | 57 | clone_repo sdnc/oam $sdnc_src_folder/oam |
| 58 | pushd $sdnc_src_folder/oam/installation/src/main/yaml |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 59 | install_docker_compose |
| 60 | /opt/docker/docker-compose up -d |
| 61 | popd |
| 62 | } |
| 63 | |
| 64 | # init_sdnc() - Function that initialize SDNC services |
| 65 | function init_sdnc { |
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 |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 72 | |
| 73 | if [[ "$skip_get_images" == "False" ]]; then |
| 74 | get_sdnc_images |
| 75 | if [[ "$skip_install" == "False" ]]; then |
Shashank Kumar Shankar | d52d0af | 2017-10-20 16:06:08 -0700 | [diff] [blame] | 76 | start_ODL |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 77 | install_sdnc |
| 78 | fi |
| 79 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 80 | } |