blob: 5cf0ed13b30e11878619d1fac107453b529803d5 [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 Morales8b8e7392017-09-25 22:13:26 -07007vfc_src_folder=$git_src_folder/vfc
8vfc_repos=("gvnfm" "gvnfm/vnflcm" "gvnfm/vnfmgr" "gvnfm/vnfres" "nfvo" \
9"nfvo/catalog" "nfvo/driver" "nfvo/driver/ems" "nfvo/driver/sfc" \
10"nfvo/driver/vnfm" "nfvo/driver/vnfm/gvnfm" "nfvo/driver/vnfm/svnfm" \
11"nfvo/lcm" "nfvo/resmanagement" "nfvo/wfengine")
Victor Moralesdd074802017-07-26 16:06:35 -050012
13# clone_all_vfc_repos() - Function that clones VF-C source repo.
14function clone_all_vfc_repos {
Victor Morales8b8e7392017-09-25 22:13:26 -070015 clone_repo vfc $vfc_src_folder
16
Victor Moralesdd074802017-07-26 16:06:35 -050017 for dirc in ${vfc_repos[@]}; do
Victor Morales8b8e7392017-09-25 22:13:26 -070018 clone_repo vfc/$dirc $vfc_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050019 done
20}
21
22# compile_all_vfc_repos() - Function that compiles VF-C source repo.
23function compile_all_vfc_repos {
Victor Morales970ec192017-07-31 09:10:11 -050024 install_python_package tox
25
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070026 tox_repos=("gvnfm/vnflcm/lcm" "gvnfm/vnfmgr/mgr" "gvnfm/vnfres/res" "nfvo/lcm" \
27 "nfvo/driver/vnfm/gvnfm/gvnfmadapter" "nfvo/driver/vnfm/svnfm/zte/vmanager")
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070028 for dirc in ${tox_repos[@]}; do
Victor Morales8b8e7392017-09-25 22:13:26 -070029 pushd $vfc_src_folder/$dirc
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070030 tox -e py27
31 popd
32 done
Victor Moralesdd074802017-07-26 16:06:35 -050033
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070034 # TODO(sshank): Add compile for other vfc_repos. (Java based.)
Victor Moralesdd074802017-07-26 16:06:35 -050035
36 # Java based:
37 # nfvo/catalog
38 # nfvo/driver/ems/ems/sems/boco/ems-driver
39 # nfvo/driver/sfc/zte/sfc-driver
40 # nfvo/driver/vnfm/gvnfm/juju/juju-vnfmadapter
41 # nfvo/driver/vnfm/svnfm/huawei/vnfmadapter
42 # nfvo/resmanagement
43 # nfvo/wfengine
44}
45
Victor Morales8b8e7392017-09-25 22:13:26 -070046# _build_vfc_image() - Build VFC docker image
47function _build_vfc_image {
48 pushd $vfc_src_folder/$1/docker
49 sed -i "s/^push_image/#push_image/g" build_image.sh
50 sed -i 's|IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"|IMAGE_NAME=${ORG}/${IMAGE}|g' build_image.sh
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070051 ./build_image.sh
52 popd
53}
54
55# get_vfc_images() - Build VFC docker images
56function get_vfc_images {
57 if [[ "$build_image" == "True" ]]; then
58 install_docker
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070059 # Separate methods are required since the image build process will change.
Victor Morales8b8e7392017-09-25 22:13:26 -070060 _build_vfc_image gvnfm/vnflcm/lcm onap/nslcm
61 _build_vfc_image gvnfm/vnfmgr/mgr onap/gvnfmdriver
62 _build_vfc_image gvnfm/vnfres/res onap/vnfres
63 _build_vfc_image nfvo/lcm onap/vnflcm
64 _build_vfc_image nfvo/driver/vnfm/gvnfm/gvnfmadapter
65
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070066 build_gvnfm_lcm_image
67 build_gvnfm_vnfmgr_image
68 build_gvnfm_vnfres_image
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070069 build_nfvo_lcm_image
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070070 build_nfvo_vnfm_gvnfmadapter_image
71 # TODO(sshank): Add other VFC component docker image builds.
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070072 else
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070073 pull_onap_image vfc/gvnfm/vnflcm/lcm
74 pull_onap_image vfc/gvnfm/vnfmgr/mgr
75 pull_onap_image vfc/gvnfm/vnfres/res
76 pull_onap_image vfc/nfvo/lcm
77 pull_onap_image vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070078 fi
79}
80
Victor Moralesdd074802017-07-26 16:06:35 -050081# install_vfc() - Download and install vfc service from source code
82function install_vfc {
Victor Morales896c8072017-09-12 12:19:57 -070083 nslcm_image=`docker images | grep nslcm | grep latest| awk '{print $1 ":" $2}'`
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070084 vnflcm_image=`docker images | grep vnflcm | grep latest| awk '{print $1 ":" $2}'`
85 vnfmgr_image=`docker images | grep vnfmgr | grep latest| awk '{print $1 ":" $2}'`
86 vnfres_image=`docker images | grep vnfres | grep latest| awk '{print $1 ":" $2}'`
87 gvnfmdriver_image=`docker images | grep gvnfmdriver | grep latest| awk '{print $1 ":" $2}'`
88
89 docker run -d --name vfc-nslcm -p 8403:8403 -e MSB_ADDR=127.0.0.1 $nslcm_image
90 docker run -d --name vfc-vnflcm -p 8801:8801 -e MSB_ADDR=127.0.0.1 $vnflcm_image
91 docker run -d --name vfc-vnfmgr -p 8803:8803 -e MSB_ADDR=127.0.0.1 $vnfmgr_image
92 docker run -d --name vfc-vnfres -p 8802:8802 -e MSB_ADDR=127.0.0.1 $vnfres_image
93 docker run -d --name vfc-gvnfmdriver -p 8484:8484 -e MSB_ADDR=127.0.0.1 $gvnfmdriver_image
94
95 # TODO(sshank): Run other VFC component docker images.
Victor Morales94b3e972017-08-17 14:55:55 -050096}
97
98# init_vfc() - Function that initialize VF-C services
99function init_vfc {
100 install_package libmysqlclient-dev
101
Idan Amit1690e082017-08-20 08:58:14 +0300102 if [[ "$clone_repo" == "True" ]]; then
103 clone_all_vfc_repos
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -0700104 if [[ "$compile_repo" == "True" ]]; then
Idan Amit1690e082017-08-20 08:58:14 +0300105 compile_all_vfc_repos
106 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500107 fi
108
Victor Morales6a919972017-09-28 18:29:54 -0700109 if [[ "$skip_get_images" == "False" ]]; then
110 get_vfc_images
111 if [[ "$skip_install" == "False" ]]; then
112 install_vfc
113 fi
114 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500115}