blob: 0f6e275070eb85bbd658d05119a10d8b6a12ea90 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
6source /var/onap/asserts
7
8# create_config_file() - Creates a configuration yaml file for the controller
9function create_config_file {
10 mkdir -p /opt/app/dcae-controller
11 cat > /opt/app/dcae-controller/config.yaml << EOL
12ZONE: $dcae_zone
13STATE: $dcae_state
14DCAE-VERSION: $artifacts_version
15HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
16KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
17OPENSTACK-TENANT-ID: $tenant_id
18OPENSTACK-TENANT-NAME: OPEN-ECOMP
19OPENSTACK-REGION: $openstack_region
20OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
21OPENSTACK-USER: $openstack_user
22OPENSTACK-PASSWORD: $openstack_password
23OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
24OPENSTACK-PUBKEY: $pub_key
25
26NEXUS-URL-ROOT: $nexus_repo_root
27NEXUS-USER: $nexus_username
28NEXUS-PASSWORD: $nexus_password
29NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
30NEXUS-RAWURL: $nexus_repo
31
32DOCKER-REGISTRY: $nexus_docker_repo
33
34GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
35EOL
36}
37
38# compile_docker_image() - Function that clones, compiles and build a Docker image
39function compile_docker_image {
40 local repo=$1
41 local src_folder=$2
42 local name=$3
43 clone_repo dcae/dmaapbc $src_folder
44 compile_src $src_folder
45 pushd $src_folder
46 # TODO(electrocucaracha) Workaround for dmmapb images
47 sed -i '/LocalKey/d' Dockerfile
48 local docker_build="docker build -t $name -f ./Dockerfile ."
49 if [ $http_proxy ]; then
50 docker_build+=" --build-arg http_proxy=$http_proxy"
51 fi
52 if [ $https_proxy ]; then
53 docker_build+=" --build-arg https_proxy=$https_proxy"
54 fi
55 eval $docker_build
56 asserts_image $name
57 popd
58}
59
60# install_dcae() - Function that clones and installs the DCAE controller services from source code
61function install_dcae {
62 export MTU=$(/sbin/ifconfig | grep MTU | sed 's/.*MTU://' | sed 's/ .*//' | sort -n | head -1)
63 local src_folder=/opt/dcae-startup-vm-controller
64 clone_repo dcae/demo/startup/controller $src_folder
65 pushd $src_folder
66 install_docker_compose
67 if [[ "$build_image" == "True" ]]; then
68 install_docker
69 src_folder=/opt/dcae
70
71 compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc
72 compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher
73
74 clone_repo dcae/demo $src_folder/demo
75 compile_src $src_folder/demo
76 pushd $src_folder/demo
77 bash dcae-demo-controller/src/main/docker-build/build.sh
78 asserts_image dcae-controller
79 popd
80
81 clone_repo dcae/dcae-inventory $src_folder/dcae-inventory
82 compile_src $src_folder/dcae-inventory
83 build_docker_image $src_folder/dcae-inventory
84 asserts_image dcae-inventory
85
86 dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
87 sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
88 sed -i "s|MTU|$MTU|g" docker-compose.yml
89 /opt/docker/docker-compose up -d
90 else
91 bash init.sh
92 install_package make
93 make up
94 fi
95
96 popd
97}
98
99# init_dcae() - Function that initialize DCAE Controller services
100function init_dcae {
101 create_config_file
102 install_dcae
103}