aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/dcae
blob: 05527bc1db828dade05921add513d7ba9ffddd41 (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
#!/bin/bash

set -o xtrace

source /var/onap/functions
source /var/onap/asserts

# create_config_file() - Creates a configuration yaml file for the controller
function create_config_file {
    mkdir -p /opt/app/dcae-controller
    cat > /opt/app/dcae-controller/config.yaml << EOL
ZONE: $dcae_zone
STATE: $dcae_state
DCAE-VERSION: $artifacts_version
HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
OPENSTACK-TENANT-ID: $tenant_id
OPENSTACK-TENANT-NAME: OPEN-ECOMP
OPENSTACK-REGION: $openstack_region
OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
OPENSTACK-USER: $openstack_user
OPENSTACK-PASSWORD: $openstack_password
OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
OPENSTACK-PUBKEY: $pub_key
     
NEXUS-URL-ROOT: $nexus_repo_root
NEXUS-USER: $nexus_username
NEXUS-PASSWORD: $nexus_password
NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
NEXUS-RAWURL: $nexus_repo
     
DOCKER-REGISTRY: $nexus_docker_repo

GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
EOL
}

# compile_docker_image() - Function that clones, compiles and build a Docker image
function compile_docker_image {
    local repo=$1
    local src_folder=$2
    local name=$3
    clone_repo dcae/dmaapbc $src_folder
    compile_src $src_folder
    pushd $src_folder
    # TODO(electrocucaracha) Workaround for dmmapb images
    sed -i '/LocalKey/d' Dockerfile
    local docker_build="docker build -t $name -f ./Dockerfile ."
    if [ $http_proxy ]; then
        docker_build+=" --build-arg http_proxy=$http_proxy"
    fi
    if [ $https_proxy ]; then
        docker_build+=" --build-arg https_proxy=$https_proxy"
    fi
    eval $docker_build
    asserts_image $name
    popd
}

# clone_all_dcae_repos() - Function that clones DCAE source repo.
function clone_all_dcae_repos {
    local src_folder=/opt/dcae
    clone_repo dcae $src_folder

    for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \
        demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do
        clone_repo dcae/$dirc $src_folder/$dirc
    done
}

# compile_all_dcae_repos() - Function that compiles DCAE source repo.
function compile_all_dcae_repos {
    local src_folder=/opt/dcae

    for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \
        demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do
        compile_src $src_folder/$dirc
    done
}


# install_dcae() - Function that clones and installs the DCAE controller services from source code
function install_dcae {
    install_docker_compose

    clone_all_dcae_repos
    if [[ "$compile_repo" == "True" ]]; then
        compile_all_dcae_repos
    fi

    if [[ "$build_image" == "True" ]]; then
        install_docker
        local src_folder=/opt/dcae

        compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc
        compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher

        clone_repo dcae/demo $src_folder/demo
        compile_src $src_folder/demo
        pushd $src_folder/demo
        bash dcae-demo-controller/src/main/docker-build/build.sh
        asserts_image dcae-controller
        popd

        clone_repo dcae/dcae-inventory $src_folder/dcae-inventory
        compile_src $src_folder/dcae-inventory
        build_docker_image $src_folder/dcae-inventory
        asserts_image dcae-inventory

        dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
        pushd $src_folder/demo/startup/controller
        sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
        sed -i "s|MTU|$MTU|g" docker-compose.yml
        /opt/docker/docker-compose up -d
        popd
    else
        pushd /opt/dcae/demo/startup/controller
        bash init.sh
        install_package make
        make up
        popd
    fi
}

# init_dcae() - Function that initialize DCAE Controller services
function init_dcae {
    create_config_file
    install_dcae
}