blob: 22066fdd491369f757fac7deee36714536efad09 [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 Morales664e6e92017-09-14 12:11:23 -07006source /var/onap/ccsdk
Victor Moralesdd074802017-07-26 16:06:35 -05007
Victor Morales65deef22017-08-18 20:53:42 -05008sdnc_src_folder=$git_src_folder/openecomp/sdnc
Victor Moralesa81fafc2017-09-21 13:55:36 -07009sdnc_repos=("adaptors" "architecture" "core" "features" "northbound" "oam" "parent" "plugins")
Victor Moralesdd074802017-07-26 16:06:35 -050010
11# clone_all_sdnc_repos() - Function that clones SDNC source repo.
12function clone_all_sdnc_repos {
13 for dirc in ${sdnc_repos[@]}; do
Victor Morales65deef22017-08-18 20:53:42 -050014 clone_repo sdnc/$dirc $sdnc_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050015 done
Victor Morales89ce3212017-06-16 18:32:48 -050016}
17
Victor Moralesdd074802017-07-26 16:06:35 -050018# compile_all_sdnc_repos() - Function that compiles SDNC source repo.
19function compile_all_sdnc_repos {
20 for dirc in ${sdnc_repos[@]}; do
21 if [[ "$dirc" == "core" ]]; then
Victor Morales65deef22017-08-18 20:53:42 -050022 compile_src $sdnc_src_folder/core/rootpom
Victor Moralesdd074802017-07-26 16:06:35 -050023 fi
Victor Morales65deef22017-08-18 20:53:42 -050024 compile_src $sdnc_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050025 done
26}
27
Victor Morales65deef22017-08-18 20:53:42 -050028# _build_sdnc_images() - Builds SDNC images from source code
29function _build_sdnc_images {
30 local folder=$sdnc_src_folder/oam
Victor Moralesdd074802017-07-26 16:06:35 -050031
Victor Morales664e6e92017-09-14 12:11:23 -070032 get_ccsdk_images
Victor Moralesdbdc30a2017-08-17 11:50:42 -050033 install_package unzip
Victor Morales65deef22017-08-18 20:53:42 -050034 clone_repo sdnc/oam $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050035 # The OAM code depends on all the SDNC repos which should be downloaded and compiled first
Victor Morales65deef22017-08-18 20:53:42 -050036 if [[ "$compile_repo" != "True" ]]; then
37 compile_src $folder
Victor Moralesdbdc30a2017-08-17 11:50:42 -050038 fi
39 for dirc in ubuntu sdnc admportal dgbuilder; do
40 build_docker_image $folder/installation/$dirc
41 done
Victor Moralesdd074802017-07-26 16:06:35 -050042}
43
44# get_sdnc_images() - Build or retrieve necessary images
45function get_sdnc_images {
Victor Morales89ce3212017-06-16 18:32:48 -050046 if [[ "$build_image" == "True" ]]; then
Victor Morales65deef22017-08-18 20:53:42 -050047 _build_sdnc_images
Victor Morales89ce3212017-06-16 18:32:48 -050048 else
49 pull_openecomp_image sdnc-image openecomp/sdnc-image:latest
50 pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest
51 pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest
52 fi
Victor Moralesdbdc30a2017-08-17 11:50:42 -050053 pull_docker_image mysql/mysql-server:5.6
Victor Moralesdd074802017-07-26 16:06:35 -050054}
55
56# install_sdnc() - Download and install SDNC services from source code
57function install_sdnc {
Victor Morales65deef22017-08-18 20:53:42 -050058 clone_repo sdnc/oam $sdnc_src_folder/oam
59 pushd $sdnc_src_folder/oam/installation/src/main/yaml
Victor Morales89ce3212017-06-16 18:32:48 -050060 install_docker_compose
61 /opt/docker/docker-compose up -d
62 popd
63}
64
65# init_sdnc() - Function that initialize SDNC services
66function init_sdnc {
Victor Moralesdd074802017-07-26 16:06:35 -050067 start_ODL
Idan Amit1690e082017-08-20 08:58:14 +030068 if [[ "$clone_repo" == "True" ]]; then
69 clone_all_sdnc_repos
70 if [[ "$compile_repo" == "True" ]]; then
71 compile_all_sdnc_repos
72 fi
Victor Moralesdd074802017-07-26 16:06:35 -050073 fi
Victor Morales6a919972017-09-28 18:29:54 -070074
75 if [[ "$skip_get_images" == "False" ]]; then
76 get_sdnc_images
77 if [[ "$skip_install" == "False" ]]; then
78 install_sdnc
79 fi
80 fi
Victor Morales89ce3212017-06-16 18:32:48 -050081}