a8cf756b4286ba77047ed8e944739d6a8653fc82
[integration.git] / bootstrap / vagrant-onap / lib / sdnc
1 #!/bin/bash
2
3 source /var/onap/functions
4 source /var/onap/ccsdk
5
6 # compile_all_sdnc_repos() - Function that compiles SDNC source repo.
7 function compile_all_sdnc_repos {
8     for repo in ${repos[sdnc]}; do
9         if [[ "$repo" == "sdnc/core" ]]; then
10             compile_src $sdnc_src_folder/core/rootpom
11         fi
12         compile_src $sdnc_src_folder${repo#*sdnc}
13     done
14 }
15
16 # _build_sdnc_images() - Builds SDNC images from source code
17 function _build_sdnc_images {
18     local folder=$sdnc_src_folder/oam
19
20     get_ccsdk_images
21     install_package unzip
22     # The OAM code depends on all the SDNC repos which should be downloaded and compiled first
23     if [[ "$compile_repo" != "True" ]]; then
24         compile_src $folder
25     fi
26     for dirc in ubuntu sdnc admportal dgbuilder; do
27         build_docker_image $folder/installation/$dirc
28     done
29 }
30
31 # get_sdnc_images() - Build or retrieve necessary images
32 function get_sdnc_images {
33     if [[ "$build_image" == "True" ]]; then
34         _build_sdnc_images
35     else
36         pull_openecomp_image sdnc-image openecomp/sdnc-image:latest
37         pull_openecomp_image admportal-sdnc-image openecomp/admportal-sdnc-image:latest
38         pull_openecomp_image dgbuilder-sdnc-image openecomp/dgbuilder-sdnc-image:latest
39     fi
40     pull_docker_image mysql/mysql-server:5.6
41 }
42
43 # install_sdnc() -  Download and install SDNC services from source code
44 function install_sdnc {
45     pushd $sdnc_src_folder/oam/installation/src/main/yaml
46     install_docker_compose
47     /opt/docker/docker-compose up -d
48     popd
49 }
50
51 # init_sdnc() - Function that initialize SDNC services
52 function init_sdnc {
53     if [[ "$clone_repo" == "True" ]]; then
54         clone_repos "sdnc"
55         if [[ "$compile_repo" == "True" ]]; then
56             compile_all_sdnc_repos
57         fi
58     fi
59
60     if [[ "$skip_get_images" == "False" ]]; then
61         get_sdnc_images
62         if [[ "$skip_install" == "False" ]]; then
63             start_ODL
64             install_sdnc
65         fi
66     fi
67 }