Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
| 5 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 6 | |
Victor Morales | 94b3e97 | 2017-08-17 14:55:55 -0500 | [diff] [blame] | 7 | src_folder=$git_src_folder/vfc |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 8 | vfc_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. |
| 12 | function 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. |
| 19 | function compile_all_vfc_repos { |
Victor Morales | 970ec19 | 2017-07-31 09:10:11 -0500 | [diff] [blame] | 20 | install_python_package tox |
| 21 | |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 22 | 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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 29 | |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 30 | # TODO(sshank): Add compile for other vfc_repos. (Java based.) |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 31 | |
| 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 Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 42 | # build_gvnfm_lcm_image() - Build VFC GVNFM VNF LCM docker image |
| 43 | function 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 |
| 51 | function 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 |
| 59 | function 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 Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 66 | # build_nfvo_lcm_image() - Build VFC NFVO LCM docker image |
| 67 | function build_nfvo_lcm_image { |
| 68 | pushd $src_folder/nfvo/lcm/docker |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 69 | 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 |
| 75 | function build_nfvo_vnfm_gvnfmadapter_image { |
| 76 | pushd $src_folder/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker |
| 77 | sed -i '$ {s/^/#/}' build_image.sh |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 78 | ./build_image.sh |
| 79 | popd |
| 80 | } |
| 81 | |
| 82 | # get_vfc_images() - Build VFC docker images |
| 83 | function get_vfc_images { |
| 84 | if [[ "$build_image" == "True" ]]; then |
| 85 | install_docker |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 86 | # 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 Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 90 | build_nfvo_lcm_image |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 91 | build_nfvo_vnfm_gvnfmadapter_image |
| 92 | # TODO(sshank): Add other VFC component docker image builds. |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 93 | else |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 94 | 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 Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 99 | fi |
| 100 | } |
| 101 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 102 | # install_vfc() - Download and install vfc service from source code |
| 103 | function install_vfc { |
Victor Morales | 896c807 | 2017-09-12 12:19:57 -0700 | [diff] [blame] | 104 | nslcm_image=`docker images | grep nslcm | grep latest| awk '{print $1 ":" $2}'` |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 105 | 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 Morales | 94b3e97 | 2017-08-17 14:55:55 -0500 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | # init_vfc() - Function that initialize VF-C services |
| 120 | function init_vfc { |
| 121 | install_package libmysqlclient-dev |
| 122 | |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 123 | if [[ "$clone_repo" == "True" ]]; then |
| 124 | clone_all_vfc_repos |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 125 | if [[ "$compile_repo" == "True" ]]; then |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 126 | compile_all_vfc_repos |
| 127 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 128 | fi |
| 129 | |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 130 | get_vfc_images |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 131 | install_vfc |
| 132 | } |