blob: a1f4bef27be093be5ce953039b4191064257829a [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
Victor Moralesdd074802017-07-26 16:06:35 -05003source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05004
Victor Morales8b8e7392017-09-25 22:13:26 -07005vfc_src_folder=$git_src_folder/vfc
Victor Moralesf6c0bf12017-10-27 11:08:04 -07006vfc_repos=("vfc/gvnfm" "vfc/gvnfm/vnflcm" "vfc/gvnfm/vnfmgr" \
7"vfc/gvnfm/vnfres" "vfc/nfvo" "vfc/nfvo/catalog" "vfc/nfvo/driver" \
8"vfc/nfvo/driver/ems" "vfc/nfvo/driver/sfc" "vfc/nfvo/driver/vnfm" \
9"vfc/nfvo/driver/vnfm/gvnfm" "vfc/nfvo/driver/vnfm/svnfm" "vfc/nfvo/lcm" \
10"vfc/nfvo/resmanagement" "vfc/nfvo/wfengine")
Victor Moralesdd074802017-07-26 16:06:35 -050011
Victor Moralesdd074802017-07-26 16:06:35 -050012# compile_all_vfc_repos() - Function that compiles VF-C source repo.
13function compile_all_vfc_repos {
Victor Morales970ec192017-07-31 09:10:11 -050014 install_python_package tox
15
Victor Moralesdbe2e0b2017-09-20 09:55:45 -070016 tox_repos=("gvnfm/vnflcm/lcm" "gvnfm/vnfmgr/mgr" "gvnfm/vnfres/res" "nfvo/lcm" \
17 "nfvo/driver/vnfm/gvnfm/gvnfmadapter" "nfvo/driver/vnfm/svnfm/zte/vmanager")
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070018 for dirc in ${tox_repos[@]}; do
Victor Morales8b8e7392017-09-25 22:13:26 -070019 pushd $vfc_src_folder/$dirc
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070020 tox -e py27
21 popd
22 done
Victor Moralesdd074802017-07-26 16:06:35 -050023
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070024 # TODO(sshank): Add compile for other vfc_repos. (Java based.)
Victor Moralesdd074802017-07-26 16:06:35 -050025
26 # Java based:
27 # nfvo/catalog
28 # nfvo/driver/ems/ems/sems/boco/ems-driver
29 # nfvo/driver/sfc/zte/sfc-driver
30 # nfvo/driver/vnfm/gvnfm/juju/juju-vnfmadapter
31 # nfvo/driver/vnfm/svnfm/huawei/vnfmadapter
32 # nfvo/resmanagement
33 # nfvo/wfengine
34}
35
Victor Morales8b8e7392017-09-25 22:13:26 -070036# _build_vfc_image() - Build VFC docker image
37function _build_vfc_image {
38 pushd $vfc_src_folder/$1/docker
39 sed -i "s/^push_image/#push_image/g" build_image.sh
40 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 -070041 ./build_image.sh
42 popd
43}
44
45# get_vfc_images() - Build VFC docker images
46function get_vfc_images {
47 if [[ "$build_image" == "True" ]]; then
48 install_docker
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070049 # Separate methods are required since the image build process will change.
Victor Morales8b8e7392017-09-25 22:13:26 -070050 _build_vfc_image gvnfm/vnflcm/lcm onap/nslcm
51 _build_vfc_image gvnfm/vnfmgr/mgr onap/gvnfmdriver
52 _build_vfc_image gvnfm/vnfres/res onap/vnfres
53 _build_vfc_image nfvo/lcm onap/vnflcm
54 _build_vfc_image nfvo/driver/vnfm/gvnfm/gvnfmadapter
55
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070056 build_gvnfm_lcm_image
57 build_gvnfm_vnfmgr_image
58 build_gvnfm_vnfres_image
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070059 build_nfvo_lcm_image
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070060 build_nfvo_vnfm_gvnfmadapter_image
61 # TODO(sshank): Add other VFC component docker image builds.
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070062 else
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070063 pull_onap_image vfc/gvnfm/vnflcm/lcm
64 pull_onap_image vfc/gvnfm/vnfmgr/mgr
65 pull_onap_image vfc/gvnfm/vnfres/res
66 pull_onap_image vfc/nfvo/lcm
67 pull_onap_image vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter
Shashank Kumar Shankar6cc4a432017-09-05 13:26:19 -070068 fi
69}
70
Victor Moralesdd074802017-07-26 16:06:35 -050071# install_vfc() - Download and install vfc service from source code
72function install_vfc {
Victor Morales896c8072017-09-12 12:19:57 -070073 nslcm_image=`docker images | grep nslcm | grep latest| awk '{print $1 ":" $2}'`
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070074 vnflcm_image=`docker images | grep vnflcm | grep latest| awk '{print $1 ":" $2}'`
75 vnfmgr_image=`docker images | grep vnfmgr | grep latest| awk '{print $1 ":" $2}'`
76 vnfres_image=`docker images | grep vnfres | grep latest| awk '{print $1 ":" $2}'`
77 gvnfmdriver_image=`docker images | grep gvnfmdriver | grep latest| awk '{print $1 ":" $2}'`
78
79 docker run -d --name vfc-nslcm -p 8403:8403 -e MSB_ADDR=127.0.0.1 $nslcm_image
80 docker run -d --name vfc-vnflcm -p 8801:8801 -e MSB_ADDR=127.0.0.1 $vnflcm_image
81 docker run -d --name vfc-vnfmgr -p 8803:8803 -e MSB_ADDR=127.0.0.1 $vnfmgr_image
82 docker run -d --name vfc-vnfres -p 8802:8802 -e MSB_ADDR=127.0.0.1 $vnfres_image
83 docker run -d --name vfc-gvnfmdriver -p 8484:8484 -e MSB_ADDR=127.0.0.1 $gvnfmdriver_image
84
85 # TODO(sshank): Run other VFC component docker images.
Victor Morales94b3e972017-08-17 14:55:55 -050086}
87
88# init_vfc() - Function that initialize VF-C services
89function init_vfc {
90 install_package libmysqlclient-dev
91
Idan Amit1690e082017-08-20 08:58:14 +030092 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080093 clone_repos "vfc"
Shashank Kumar Shankar0be68942017-09-14 11:10:41 -070094 if [[ "$compile_repo" == "True" ]]; then
Idan Amit1690e082017-08-20 08:58:14 +030095 compile_all_vfc_repos
96 fi
Victor Moralesdd074802017-07-26 16:06:35 -050097 fi
98
Victor Morales6a919972017-09-28 18:29:54 -070099 if [[ "$skip_get_images" == "False" ]]; then
100 get_vfc_images
101 if [[ "$skip_install" == "False" ]]; then
102 install_vfc
103 fi
104 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500105}