aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/vfc
blob: fb32708e07e2f0c5ecd0fdff241d3bbd0a150b77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash

set -o xtrace

source /var/onap/functions

src_folder=$git_src_folder/vfc
vfc_repos=("gvnfm/vnflcm" "gvnfm/vnfmgr" "gvnfm/vnfres" "nfvo/catalog" "nfvo/driver/ems" "nfvo/driver/sfc" \
            "nfvo/driver/vnfm/gvnfm" "nfvo/driver/vnfm/svnfm" "nfvo/lcm" "nfvo/resmanagement" "nfvo/wfengine")

# clone_all_vfc_repos() - Function that clones VF-C source repo.
function clone_all_vfc_repos {
    for dirc in ${vfc_repos[@]}; do
        clone_repo vfc/$dirc $src_folder/$dirc
    done
}

# compile_all_vfc_repos() - Function that compiles VF-C source repo.
function compile_all_vfc_repos {
    install_python_package tox

    tox_repos=("gvnfm/vnflcm/lcm" "gvnfm/vnfmgr/mgr" "gvnfm/vnfres/res" "nfvo/lcm" \
        "nfvo/driver/vnfm/gvnfm/gvnfmadapter" "nfvo/driver/vnfm/svnfm/zte/vmanager")
    for dirc in ${tox_repos[@]}; do
        pushd $src_folder/$dirc
        tox -e py27
        popd
    done

    # TODO(sshank): Add compile for other vfc_repos. (Java based.)

    # Java based:
    # nfvo/catalog
    # nfvo/driver/ems/ems/sems/boco/ems-driver
    # nfvo/driver/sfc/zte/sfc-driver
    # nfvo/driver/vnfm/gvnfm/juju/juju-vnfmadapter
    # nfvo/driver/vnfm/svnfm/huawei/vnfmadapter
    # nfvo/resmanagement
    # nfvo/wfengine
}

# build_gvnfm_lcm_image() - Build VFC GVNFM VNF LCM docker image
function build_gvnfm_lcm_image {
    pushd $src_folder/gvnfm/vnflcm/lcm/docker
    sed -i '$ {s/^/#/}' build_image.sh
    ./build_image.sh
    popd
}

# build_gvnfm_vnfmgr_image() - Build VFC GVNFM VNF Manager docker image
function build_gvnfm_vnfmgr_image {
    pushd $src_folder/gvnfm/vnfmgr/mgr/docker
    sed -i '$ {s/^/#/}' build_image.sh
    ./build_image.sh
    popd
}

# build_gvnfm_vnfres_image() - Build VFC GVNFM VNF Resource Management docker image
function build_gvnfm_vnfres_image {
    pushd $src_folder/gvnfm/vnfres/res/docker
    sed -i '$ {s/^/#/}' build_image.sh
    ./build_image.sh
    popd
}

# build_nfvo_lcm_image() - Build VFC NFVO LCM docker image
function build_nfvo_lcm_image {
    pushd $src_folder/nfvo/lcm/docker
    sed -i '$ {s/^/#/}' build_image.sh
    ./build_image.sh
    popd
}

# build_nfvo_vnfm_gvnfmadapter_image() - Build VFC NFVO General VNF Adapter docker image
function build_nfvo_vnfm_gvnfmadapter_image {
    pushd $src_folder/nfvo/driver/vnfm/gvnfm/gvnfmadapter/docker
    sed -i '$ {s/^/#/}' build_image.sh
    ./build_image.sh
    popd
}

# get_vfc_images() - Build VFC docker images
function get_vfc_images {
    if [[ "$build_image" == "True" ]]; then
        install_docker
        # Separate methods are required since the image build process will change.
        build_gvnfm_lcm_image
        build_gvnfm_vnfmgr_image
        build_gvnfm_vnfres_image
        build_nfvo_lcm_image
        build_nfvo_vnfm_gvnfmadapter_image
        # TODO(sshank): Add other VFC component docker image builds.
    else
        pull_onap_image vfc/gvnfm/vnflcm/lcm
        pull_onap_image vfc/gvnfm/vnfmgr/mgr
        pull_onap_image vfc/gvnfm/vnfres/res
        pull_onap_image vfc/nfvo/lcm
        pull_onap_image vfc/nfvo/driver/vnfm/gvnfm/gvnfmadapter
    fi
}

# install_vfc() - Download and install vfc service from source code
function install_vfc {
    nslcm_image=`docker images | grep nslcm | grep latest| awk '{print $1 ":" $2}'`
    vnflcm_image=`docker images | grep vnflcm | grep latest| awk '{print $1 ":" $2}'`
    vnfmgr_image=`docker images | grep vnfmgr | grep latest| awk '{print $1 ":" $2}'`
    vnfres_image=`docker images | grep vnfres | grep latest| awk '{print $1 ":" $2}'`
    gvnfmdriver_image=`docker images | grep gvnfmdriver | grep latest| awk '{print $1 ":" $2}'`

    docker run -d --name vfc-nslcm -p 8403:8403 -e MSB_ADDR=127.0.0.1 $nslcm_image
    docker run -d --name vfc-vnflcm -p 8801:8801 -e MSB_ADDR=127.0.0.1 $vnflcm_image
    docker run -d --name vfc-vnfmgr -p 8803:8803 -e MSB_ADDR=127.0.0.1 $vnfmgr_image
    docker run -d --name vfc-vnfres -p 8802:8802 -e MSB_ADDR=127.0.0.1 $vnfres_image
    docker run -d --name vfc-gvnfmdriver -p 8484:8484 -e MSB_ADDR=127.0.0.1 $gvnfmdriver_image

    # TODO(sshank): Run other VFC component docker images.
}

# init_vfc() - Function that initialize VF-C services
function init_vfc {
    install_package libmysqlclient-dev

    if [[ "$clone_repo" == "True" ]]; then
        clone_all_vfc_repos
        if [[ "$compile_repo" == "True" ]]; then
            compile_all_vfc_repos
        fi
    fi

    get_vfc_images
    install_vfc
}