83b530995126a03b232186746f294cb87bdf91c8
[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
9 # clone_all_vid_repos() - Function that clones VID source code.
10 function clone_all_vid_repos {
11     clone_repo vid $vid_src_folder
12     clone_repo vid/asdcclient $vid_src_folder/asdcclient
13 }
14
15 # compile_all_vid_repos() - Function that compiles VID source repo.
16 function compile_all_vid_repos {
17     compile_src $vid_src_folder/asdcclient
18     compile_src $vid_src_folder
19 }
20
21 # _build_vid_images() - Function that builds VID docker images
22 function _build_vid_images {
23     if [[ "$compile_repo" != "True" ]]; then
24         compile_src $vid_src_folder
25     fi
26     build_docker_image $vid_src_folder/deliveries
27 }
28
29 # get_vid_images() - Function that retrieves VID docker images
30 function get_vid_images {
31     if [[ "$build_image" == "True" ]]; then
32         _build_vid_images
33     else
34         pull_openecomp_image vid
35     fi
36     pull_docker_image mariadb:10
37 }
38
39 # install_vid() - Download and configure Vid source code
40 function install_vid {
41     vid_image=`docker images | grep vid | grep latest| awk '{print $1 ":" $2}'`
42
43     docker rm -f vid-mariadb
44     docker rm -f vid-server
45
46     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
47     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
48 }
49
50 # init_vid() - Function that initialize Vid services
51 function init_vid {
52     if [[ "$clone_repo" == "True" ]]; then
53         clone_all_vid_repos
54         if [[ "$compile_repo" == "True" ]]; then
55             compile_all_vid_repos
56         fi
57     fi
58
59     if [[ "$skip_get_images" == "False" ]]; then
60         get_vid_images
61         if [[ "$skip_install" == "False" ]]; then
62             install_vid
63         fi
64     fi
65 }