blob: a69ce18fba2f95d7140e421d2113ca74093b0366 [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 Morales664e6e92017-09-14 12:11:23 -07004source /var/onap/ccsdk
Victor Moralesdd074802017-07-26 16:06:35 -05005
Victor Morales65deef22017-08-18 20:53:42 -05006sdnc_src_folder=$git_src_folder/openecomp/sdnc
Victor Moralesf6c0bf12017-10-27 11:08:04 -07007sdnc_repos=("sdnc/adaptors" "sdnc/architecture" "sdnc/core" "sdnc/features" \
8"sdnc/northbound" "sdnc/oam" "sdnc/parent" "sdnc/plugins")
Victor Moralesdd074802017-07-26 16:06:35 -05009
10# clone_all_sdnc_repos() - Function that clones SDNC source repo.
11function clone_all_sdnc_repos {
Victor Moralesf6c0bf12017-10-27 11:08:04 -070012 for repo in ${sdnc_repos[@]}; do
13 clone_repo $repo $sdnc_src_folder${repo#*sdnc}
Victor Moralesdd074802017-07-26 16:06:35 -050014 done
Victor Morales89ce3212017-06-16 18:32:48 -050015}
16
Victor Moralesdd074802017-07-26 16:06:35 -050017# compile_all_sdnc_repos() - Function that compiles SDNC source repo.
18function compile_all_sdnc_repos {
Victor Moralesf6c0bf12017-10-27 11:08:04 -070019 for repo in ${sdnc_repos[@]}; do
20 if [[ "$repo" == "sdnc/core" ]]; then
Victor Morales65deef22017-08-18 20:53:42 -050021 compile_src $sdnc_src_folder/core/rootpom
Victor Moralesdd074802017-07-26 16:06:35 -050022 fi
Victor Moralesf6c0bf12017-10-27 11:08:04 -070023 compile_src $sdnc_src_folder${repo#*sdnc}
Victor Moralesdd074802017-07-26 16:06:35 -050024 done
25}
26
Victor Morales65deef22017-08-18 20:53:42 -050027# _build_sdnc_images() - Builds SDNC images from source code
28function _build_sdnc_images {
29 local folder=$sdnc_src_folder/oam
Victor Moralesdd074802017-07-26 16:06:35 -050030
Victor Morales664e6e92017-09-14 12:11:23 -070031 get_ccsdk_images
Victor Moralesdbdc30a2017-08-17 11:50:42 -050032 install_package unzip
Victor Morales65deef22017-08-18 20:53:42 -050033 clone_repo sdnc/oam $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050034 # The OAM code depends on all the SDNC repos which should be downloaded and compiled first
Victor Morales65deef22017-08-18 20:53:42 -050035 if [[ "$compile_repo" != "True" ]]; then
36 compile_src $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050037 fi
38 for dirc in ubuntu sdnc admportal dgbuilder; do
39 build_docker_image $folder/installation/$dirc
40 done
Victor Moralesdd074802017-07-26 16:06:35 -050041}
42
43# get_sdnc_images() - Build or retrieve necessary images
44function get_sdnc_images {
Victor Morales89ce3212017-06-16 18:32:48 -050045 if [[ "$build_image" == "True" ]]; then
Victor Morales65deef22017-08-18 20:53:42 -050046 _build_sdnc_images
Victor Morales89ce3212017-06-16 18:32:48 -050047 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 Moralesdbdc30a2017-08-17 11:50:42 -050052 pull_docker_image mysql/mysql-server:5.6
Victor Moralesdd074802017-07-26 16:06:35 -050053}
54
55# install_sdnc() - Download and install SDNC services from source code
56function install_sdnc {
Victor Morales65deef22017-08-18 20:53:42 -050057 clone_repo sdnc/oam $sdnc_src_folder/oam
58 pushd $sdnc_src_folder/oam/installation/src/main/yaml
Victor Morales89ce3212017-06-16 18:32:48 -050059 install_docker_compose
60 /opt/docker/docker-compose up -d
61 popd
62}
63
64# init_sdnc() - Function that initialize SDNC services
65function init_sdnc {
Idan Amit1690e082017-08-20 08:58:14 +030066 if [[ "$clone_repo" == "True" ]]; then
67 clone_all_sdnc_repos
68 if [[ "$compile_repo" == "True" ]]; then
69 compile_all_sdnc_repos
70 fi
Victor Moralesdd074802017-07-26 16:06:35 -050071 fi
Victor Morales6a919972017-09-28 18:29:54 -070072
73 if [[ "$skip_get_images" == "False" ]]; then
74 get_sdnc_images
75 if [[ "$skip_install" == "False" ]]; then
Shashank Kumar Shankard52d0af2017-10-20 16:06:08 -070076 start_ODL
Victor Morales6a919972017-09-28 18:29:54 -070077 install_sdnc
78 fi
79 fi
Victor Morales89ce3212017-06-16 18:32:48 -050080}