Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 3 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 4 | |
Victor Morales | 8b8e739 | 2017-09-25 22:13:26 -0700 | [diff] [blame] | 5 | vfc_src_folder=$git_src_folder/vfc |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 6 | vfc_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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 11 | |
| 12 | # clone_all_vfc_repos() - Function that clones VF-C source repo. |
| 13 | function clone_all_vfc_repos { |
Victor Morales | f6c0bf1 | 2017-10-27 11:08:04 -0700 | [diff] [blame] | 14 | for repo in ${vfc_repos[@]}; do |
| 15 | clone_repo $repo $vfc_src_folder${repo#*vfc} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 16 | done |
| 17 | } |
| 18 | |
| 19 | # compile_all_vfc_repos() - Function that compiles VF-C source repo. |
| 20 | function compile_all_vfc_repos { |
Victor Morales | 970ec19 | 2017-07-31 09:10:11 -0500 | [diff] [blame] | 21 | install_python_package tox |
| 22 | |
Victor Morales | dbe2e0b | 2017-09-20 09:55:45 -0700 | [diff] [blame] | 23 | tox_repos=("gvnfm/vnflcm/lcm" "gvnfm/vnfmgr/mgr" "gvnfm/vnfres/res" "nfvo/lcm" \ |
| 24 | "nfvo/driver/vnfm/gvnfm/gvnfmadapter" "nfvo/driver/vnfm/svnfm/zte/vmanager") |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 25 | for dirc in ${tox_repos[@]}; do |
Victor Morales | 8b8e739 | 2017-09-25 22:13:26 -0700 | [diff] [blame] | 26 | pushd $vfc_src_folder/$dirc |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 27 | tox -e py27 |
| 28 | popd |
| 29 | done |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 30 | |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 31 | # TODO(sshank): Add compile for other vfc_repos. (Java based.) |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 32 | |
| 33 | # Java based: |
| 34 | # nfvo/catalog |
| 35 | # nfvo/driver/ems/ems/sems/boco/ems-driver |
| 36 | # nfvo/driver/sfc/zte/sfc-driver |
| 37 | # nfvo/driver/vnfm/gvnfm/juju/juju-vnfmadapter |
| 38 | # nfvo/driver/vnfm/svnfm/huawei/vnfmadapter |
| 39 | # nfvo/resmanagement |
| 40 | # nfvo/wfengine |
| 41 | } |
| 42 | |
Victor Morales | 8b8e739 | 2017-09-25 22:13:26 -0700 | [diff] [blame] | 43 | # _build_vfc_image() - Build VFC docker image |
| 44 | function _build_vfc_image { |
| 45 | pushd $vfc_src_folder/$1/docker |
| 46 | sed -i "s/^push_image/#push_image/g" build_image.sh |
| 47 | sed -i 's|IMAGE_NAME="${DOCKER_REPOSITORY}/${ORG}/${PROJECT}/${IMAGE}"|IMAGE_NAME=${ORG}/${IMAGE}|g' build_image.sh |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 48 | ./build_image.sh |
| 49 | popd |
| 50 | } |
| 51 | |
| 52 | # get_vfc_images() - Build VFC docker images |
| 53 | function get_vfc_images { |
| 54 | if [[ "$build_image" == "True" ]]; then |
| 55 | install_docker |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 56 | # Separate methods are required since the image build process will change. |
Victor Morales | 8b8e739 | 2017-09-25 22:13:26 -0700 | [diff] [blame] | 57 | _build_vfc_image gvnfm/vnflcm/lcm onap/nslcm |
| 58 | _build_vfc_image gvnfm/vnfmgr/mgr onap/gvnfmdriver |
| 59 | _build_vfc_image gvnfm/vnfres/res onap/vnfres |
| 60 | _build_vfc_image nfvo/lcm onap/vnflcm |
| 61 | _build_vfc_image nfvo/driver/vnfm/gvnfm/gvnfmadapter |
| 62 | |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 63 | build_gvnfm_lcm_image |
| 64 | build_gvnfm_vnfmgr_image |
| 65 | build_gvnfm_vnfres_image |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 66 | build_nfvo_lcm_image |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 67 | build_nfvo_vnfm_gvnfmadapter_image |
| 68 | # TODO(sshank): Add other VFC component docker image builds. |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 69 | else |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 70 | pull_onap_image vfc/gvnfm/vnflcm/lcm |
| 71 | pull_onap_image vfc/gvnfm/vnfmgr/mgr |
| 72 | pull_onap_image vfc/gvnfm/vnfres/res |
| 73 | pull_onap_image vfc/nfvo/lcm |
| 74 | pull_onap_image vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter |
Shashank Kumar Shankar | 6cc4a43 | 2017-09-05 13:26:19 -0700 | [diff] [blame] | 75 | fi |
| 76 | } |
| 77 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 78 | # install_vfc() - Download and install vfc service from source code |
| 79 | function install_vfc { |
Victor Morales | 896c807 | 2017-09-12 12:19:57 -0700 | [diff] [blame] | 80 | 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] | 81 | vnflcm_image=`docker images | grep vnflcm | grep latest| awk '{print $1 ":" $2}'` |
| 82 | vnfmgr_image=`docker images | grep vnfmgr | grep latest| awk '{print $1 ":" $2}'` |
| 83 | vnfres_image=`docker images | grep vnfres | grep latest| awk '{print $1 ":" $2}'` |
| 84 | gvnfmdriver_image=`docker images | grep gvnfmdriver | grep latest| awk '{print $1 ":" $2}'` |
| 85 | |
| 86 | docker run -d --name vfc-nslcm -p 8403:8403 -e MSB_ADDR=127.0.0.1 $nslcm_image |
| 87 | docker run -d --name vfc-vnflcm -p 8801:8801 -e MSB_ADDR=127.0.0.1 $vnflcm_image |
| 88 | docker run -d --name vfc-vnfmgr -p 8803:8803 -e MSB_ADDR=127.0.0.1 $vnfmgr_image |
| 89 | docker run -d --name vfc-vnfres -p 8802:8802 -e MSB_ADDR=127.0.0.1 $vnfres_image |
| 90 | docker run -d --name vfc-gvnfmdriver -p 8484:8484 -e MSB_ADDR=127.0.0.1 $gvnfmdriver_image |
| 91 | |
| 92 | # TODO(sshank): Run other VFC component docker images. |
Victor Morales | 94b3e97 | 2017-08-17 14:55:55 -0500 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | # init_vfc() - Function that initialize VF-C services |
| 96 | function init_vfc { |
| 97 | install_package libmysqlclient-dev |
| 98 | |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 99 | if [[ "$clone_repo" == "True" ]]; then |
| 100 | clone_all_vfc_repos |
Shashank Kumar Shankar | 0be6894 | 2017-09-14 11:10:41 -0700 | [diff] [blame] | 101 | if [[ "$compile_repo" == "True" ]]; then |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 102 | compile_all_vfc_repos |
| 103 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 104 | fi |
| 105 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 106 | if [[ "$skip_get_images" == "False" ]]; then |
| 107 | get_vfc_images |
| 108 | if [[ "$skip_install" == "False" ]]; then |
| 109 | install_vfc |
| 110 | fi |
| 111 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 112 | } |