blob: 6fc7f351fd7e39802c94cc6452d2752b04ddc6ea [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Moralesdd074802017-07-26 16:06:35 -05003source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05004
Victor Morales7ba76472017-08-23 15:19:36 -05005vid_src_folder=$git_src_folder/vid
Victor Morales21404d72017-10-20 13:18:26 -07006vid_repos=("vid" "vid/asdcclient")
Victor Morales89ce3212017-06-16 18:32:48 -05007
Victor Moralesdd074802017-07-26 16:06:35 -05008# clone_all_vid_repos() - Function that clones VID source code.
9function clone_all_vid_repos {
Victor Morales21404d72017-10-20 13:18:26 -070010 for repo in ${vid_repos[@]}; do
11 clone_repo $repo $vid_src_folder${repo#*vid}
12 done
Victor Moralesdd074802017-07-26 16:06:35 -050013}
14
15# compile_all_vid_repos() - Function that compiles VID source repo.
16function compile_all_vid_repos {
Victor Morales21404d72017-10-20 13:18:26 -070017 for repo in ${vid_repos[@]}; do
18 compile_src $vid_src_folder${repo#*vid}
19 done
Victor Morales7ba76472017-08-23 15:19:36 -050020}
21
22# _build_vid_images() - Function that builds VID docker images
23function _build_vid_images {
24 if [[ "$compile_repo" != "True" ]]; then
25 compile_src $vid_src_folder
26 fi
27 build_docker_image $vid_src_folder/deliveries
28}
29
30# get_vid_images() - Function that retrieves VID docker images
31function get_vid_images {
32 if [[ "$build_image" == "True" ]]; then
33 _build_vid_images
34 else
35 pull_openecomp_image vid
36 fi
37 pull_docker_image mariadb:10
Victor Moralesdd074802017-07-26 16:06:35 -050038}
39
Victor Morales89ce3212017-06-16 18:32:48 -050040# install_vid() - Download and configure Vid source code
41function install_vid {
Victor Morales7ba76472017-08-23 15:19:36 -050042 vid_image=`docker images | grep vid | grep latest| awk '{print $1 ":" $2}'`
Victor Morales89ce3212017-06-16 18:32:48 -050043
44 docker rm -f vid-mariadb
45 docker rm -f vid-server
46
47 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
Victor Moralesdd074802017-07-26 16:06:35 -050048 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
Victor Morales89ce3212017-06-16 18:32:48 -050049}
50
51# init_vid() - Function that initialize Vid services
52function init_vid {
Idan Amit1690e082017-08-20 08:58:14 +030053 if [[ "$clone_repo" == "True" ]]; then
54 clone_all_vid_repos
55 if [[ "$compile_repo" == "True" ]]; then
56 compile_all_vid_repos
57 fi
Victor Morales7ba76472017-08-23 15:19:36 -050058 fi
59
Victor Morales6a919972017-09-28 18:29:54 -070060 if [[ "$skip_get_images" == "False" ]]; then
61 get_vid_images
62 if [[ "$skip_install" == "False" ]]; then
63 install_vid
64 fi
65 fi
Victor Morales89ce3212017-06-16 18:32:48 -050066}