blob: c7c2745d88198c28b5cb7c696c521b42f1bd6dfa [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
Victor Moralesdd074802017-07-26 16:06:35 -05005source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05006
Victor Morales65deef22017-08-18 20:53:42 -05007sdnc_src_folder=$git_src_folder/openecomp/sdnc
Victor Moralesdd074802017-07-26 16:06:35 -05008sdnc_repos=("core" "adaptors" "northbound" "plugins" "oam")
9
10# clone_all_sdnc_repos() - Function that clones SDNC source repo.
11function clone_all_sdnc_repos {
12 for dirc in ${sdnc_repos[@]}; do
Victor Morales65deef22017-08-18 20:53:42 -050013 clone_repo sdnc/$dirc $sdnc_src_folder/$dirc
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 {
19 for dirc in ${sdnc_repos[@]}; do
20 if [[ "$dirc" == "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 Morales65deef22017-08-18 20:53:42 -050023 compile_src $sdnc_src_folder/$dirc
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 Moralesdbdc30a2017-08-17 11:50:42 -050031 install_package unzip
Victor Morales65deef22017-08-18 20:53:42 -050032 clone_repo sdnc/oam $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050033 # The OAM code depends on all the SDNC repos which should be downloaded and compiled first
Victor Morales65deef22017-08-18 20:53:42 -050034 if [[ "$compile_repo" != "True" ]]; then
35 compile_src $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050036 fi
37 for dirc in ubuntu sdnc admportal dgbuilder; do
38 build_docker_image $folder/installation/$dirc
39 done
Victor Moralesdd074802017-07-26 16:06:35 -050040}
41
42# get_sdnc_images() - Build or retrieve necessary images
43function get_sdnc_images {
Victor Morales89ce3212017-06-16 18:32:48 -050044 if [[ "$build_image" == "True" ]]; then
Victor Morales65deef22017-08-18 20:53:42 -050045 _build_sdnc_images
Victor Morales89ce3212017-06-16 18:32:48 -050046 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 Moralesdbdc30a2017-08-17 11:50:42 -050051 pull_docker_image mysql/mysql-server:5.6
Victor Moralesdd074802017-07-26 16:06:35 -050052}
53
54# install_sdnc() - Download and install SDNC services from source code
55function install_sdnc {
Victor Morales65deef22017-08-18 20:53:42 -050056 clone_repo sdnc/oam $sdnc_src_folder/oam
57 pushd $sdnc_src_folder/oam/installation/src/main/yaml
Victor Morales89ce3212017-06-16 18:32:48 -050058 install_docker_compose
59 /opt/docker/docker-compose up -d
60 popd
61}
62
63# init_sdnc() - Function that initialize SDNC services
64function init_sdnc {
Victor Moralesdd074802017-07-26 16:06:35 -050065 start_ODL
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
72 get_sdnc_images
Victor Morales89ce3212017-06-16 18:32:48 -050073 install_sdnc
74}