Create a upstream repos validator
[integration.git] / bootstrap / vagrant-onap / lib / vid
1 #!/bin/bash
2
3 set -o xtrace
4
5 source /var/onap/functions
6
7 vid_src_folder=$git_src_folder/vid
8 vid_repos=("vid" "vid/asdcclient")
9
10 # clone_all_vid_repos() - Function that clones VID source code.
11 function clone_all_vid_repos {
12     for repo in ${vid_repos[@]}; do
13         clone_repo $repo $vid_src_folder${repo#*vid}
14     done
15 }
16
17 # compile_all_vid_repos() - Function that compiles VID source repo.
18 function compile_all_vid_repos {
19     for repo in ${vid_repos[@]}; do
20         compile_src $vid_src_folder${repo#*vid}
21     done
22 }
23
24 # _build_vid_images() - Function that builds VID docker images
25 function _build_vid_images {
26     if [[ "$compile_repo" != "True" ]]; then
27         compile_src $vid_src_folder
28     fi
29     build_docker_image $vid_src_folder/deliveries
30 }
31
32 # get_vid_images() - Function that retrieves VID docker images
33 function get_vid_images {
34     if [[ "$build_image" == "True" ]]; then
35         _build_vid_images
36     else
37         pull_openecomp_image vid
38     fi
39     pull_docker_image mariadb:10
40 }
41
42 # install_vid() - Download and configure Vid source code
43 function install_vid {
44     vid_image=`docker images | grep vid | grep latest| awk '{print $1 ":" $2}'`
45
46     docker rm -f vid-mariadb
47     docker rm -f vid-server
48
49     docker run --name vid-mariadb -e MYSQL_DATABASE=vid_openecomp -e MYSQL_USER=vidadmin -e MYSQL_PASSWORD=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -e MYSQL_ROOT_PASSWORD=LF+tp_1WqgSY -v /opt/vid/lf_config/vid-my.cnf:/etc/mysql/my.cnf -v /opt/vid/lf_config/vid-pre-init.sql:/docker-entrypoint-initdb.d/vid-pre-init.sql -v /var/lib/mysql -d mariadb:10
50     docker run -e VID_MYSQL_DBNAME=vid_openecomp -e VID_MYSQL_PASS=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U --name vid-server -p 8080:8080 --link vid-mariadb:vid-mariadb-docker-instance -d $vid_image
51 }
52
53 # init_vid() - Function that initialize Vid services
54 function init_vid {
55     if [[ "$clone_repo" == "True" ]]; then
56         clone_all_vid_repos
57         if [[ "$compile_repo" == "True" ]]; then
58             compile_all_vid_repos
59         fi
60     fi
61
62     if [[ "$skip_get_images" == "False" ]]; then
63         get_vid_images
64         if [[ "$skip_install" == "False" ]]; then
65             install_vid
66         fi
67     fi
68 }