blob: 2d1418258149c91f79a2062627ef185856d566f7 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05006
Victor Morales94b3e972017-08-17 14:55:55 -05007src_folder=$git_src_folder/vfc
Victor Moralesdd074802017-07-26 16:06:35 -05008vfc_repos=("gvnfm/vnflcm" "gvnfm/vnfmgr" "gvnfm/vnfres" "nfvo/catalog" "nfvo/driver/ems" "nfvo/driver/sfc" \
9 "nfvo/driver/vnfm/gvnfm" "nfvo/driver/vnfm/svnfm" "nfvo/lcm" "nfvo/resmanagement" "nfvo/wfengine")
10
11# clone_all_vfc_repos() - Function that clones VF-C source repo.
12function clone_all_vfc_repos {
13 for dirc in ${vfc_repos[@]}; do
14 clone_repo vfc/$dirc $src_folder/$dirc
15 done
16}
17
18# compile_all_vfc_repos() - Function that compiles VF-C source repo.
19function compile_all_vfc_repos {
Victor Morales970ec192017-07-31 09:10:11 -050020 install_python_package tox
21
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070022 tox_repos=("gvnfm/vnflcm/lcm" "gvnfm/vnfmgr/mgr" "gvnfm/vnfres/res" "nfvo/lcm"
23 "nfvo/driver/vnfm/gvnfm/gvnfmadapter" "nfvo/driver/vnfm/svnfm/zte/vmanager")
24 for dirc in ${tox_repos[@]}; do
25 pushd $src_folder/$dirc
26 tox -e py27
27 popd
28 done
Victor Moralesdd074802017-07-26 16:06:35 -050029
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070030 # TODO(sshank): Add compile for other vfc_repos. (Java based.)
Victor Moralesdd074802017-07-26 16:06:35 -050031
32 # Java based:
33 # nfvo/catalog
34 # nfvo/driver/ems/ems/sems/boco/ems-driver
35 # nfvo/driver/sfc/zte/sfc-driver
36 # nfvo/driver/vnfm/gvnfm/juju/juju-vnfmadapter
37 # nfvo/driver/vnfm/svnfm/huawei/vnfmadapter
38 # nfvo/resmanagement
39 # nfvo/wfengine
40}
41
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070042# build_gvnfm_lcm_image() - Build VFC GVNFM VNF LCM docker image
43function build_gvnfm_lcm_image {
44 pushd $src_folder/gvnfm/vnflcm/lcm/docker
45 sed -i '$ {s/^/#/}' build_image.sh
46 ./build_image.sh
47 popd
48}
49
50# build_gvnfm_vnfmgr_image() - Build VFC GVNFM VNF Manager docker image
51function build_gvnfm_vnfmgr_image {
52 pushd $src_folder/gvnfm/vnfmgr/mgr/docker
53 sed -i '$ {s/^/#/}' build_image.sh
54 ./build_image.sh
55 popd
56}
57
58# build_gvnfm_vnfres_image() - Build VFC GVNFM VNF Resource Management docker image
59function build_gvnfm_vnfres_image {
60 pushd $src_folder/gvnfm/vnfres/res/docker
61 sed -i '$ {s/^/#/}' build_image.sh
62 ./build_image.sh
63 popd
64}
65
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070066# build_nfvo_lcm_image() - Build VFC NFVO LCM docker image
67function build_nfvo_lcm_image {
68 pushd $src_folder/nfvo/lcm/docker
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070069 sed -i '$ {s/^/#/}' build_image.sh
70 ./build_image.sh
71 popd
72}
73
74# build_nfvo_vnfm_gvnfmadapter_image() - Build VFC NFVO General VNF Adapter docker image
75function build_nfvo_vnfm_gvnfmadapter_image {
76 pushd $src_folder/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker
77 sed -i '$ {s/^/#/}' build_image.sh
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070078 ./build_image.sh
79 popd
80}
81
82# get_vfc_images() - Build VFC docker images
83function get_vfc_images {
84 if [[ "$build_image" == "True" ]]; then
85 install_docker
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070086 # Separate methods are required since the image build process will change.
87 build_gvnfm_lcm_image
88 build_gvnfm_vnfmgr_image
89 build_gvnfm_vnfres_image
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070090 build_nfvo_lcm_image
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070091 build_nfvo_vnfm_gvnfmadapter_image
92 # TODO(sshank): Add other VFC component docker image builds.
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070093 else
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070094 pull_onap_image vfc/gvnfm/vnflcm/lcm
95 pull_onap_image vfc/gvnfm/vnfmgr/mgr
96 pull_onap_image vfc/gvnfm/vnfres/res
97 pull_onap_image vfc/nfvo/lcm
98 pull_onap_image vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070099 fi
100}
101
Victor Moralesdd074802017-07-26 16:06:35 -0500102# install_vfc() - Download and install vfc service from source code
103function install_vfc {
Victor Morales896c8072017-09-12 12:19:57 -0700104 nslcm_image=`docker images | grep nslcm | grep latest| awk '{print $1 ":" $2}'`
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -0700105 vnflcm_image=`docker images | grep vnflcm | grep latest| awk '{print $1 ":" $2}'`
106 vnfmgr_image=`docker images | grep vnfmgr | grep latest| awk '{print $1 ":" $2}'`
107 vnfres_image=`docker images | grep vnfres | grep latest| awk '{print $1 ":" $2}'`
108 gvnfmdriver_image=`docker images | grep gvnfmdriver | grep latest| awk '{print $1 ":" $2}'`
109
110 docker run -d --name vfc-nslcm -p 8403:8403 -e MSB_ADDR=127.0.0.1 $nslcm_image
111 docker run -d --name vfc-vnflcm -p 8801:8801 -e MSB_ADDR=127.0.0.1 $vnflcm_image
112 docker run -d --name vfc-vnfmgr -p 8803:8803 -e MSB_ADDR=127.0.0.1 $vnfmgr_image
113 docker run -d --name vfc-vnfres -p 8802:8802 -e MSB_ADDR=127.0.0.1 $vnfres_image
114 docker run -d --name vfc-gvnfmdriver -p 8484:8484 -e MSB_ADDR=127.0.0.1 $gvnfmdriver_image
115
116 # TODO(sshank): Run other VFC component docker images.
Victor Morales94b3e972017-08-17 14:55:55 -0500117}
118
119# init_vfc() - Function that initialize VF-C services
120function init_vfc {
121 install_package libmysqlclient-dev
122
Idan Amit1690e082017-08-20 08:58:14 +0300123 if [[ "$clone_repo" == "True" ]]; then
124 clone_all_vfc_repos
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -0700125 if [[ "$compile_repo" == "True" ]]; then
Idan Amit1690e082017-08-20 08:58:14 +0300126 compile_all_vfc_repos
127 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500128 fi
129
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -0700130 get_vfc_images
Victor Moralesdd074802017-07-26 16:06:35 -0500131 install_vfc
132}