blob: 05527bc1db828dade05921add513d7ba9ffddd41 [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
Victor Moralesdd074802017-07-26 16:06:35 -050060# clone_all_dcae_repos() - Function that clones DCAE source repo.
61function clone_all_dcae_repos {
62 local src_folder=/opt/dcae
63 clone_repo dcae $src_folder
64
65 for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \
66 demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do
67 clone_repo dcae/$dirc $src_folder/$dirc
68 done
69}
70
71# compile_all_dcae_repos() - Function that compiles DCAE source repo.
72function compile_all_dcae_repos {
73 local src_folder=/opt/dcae
74
75 for dirc in apod apod/analytics apod/buildtools apod/buildtools collectors collectors/ves controller controller/analytics dcae-inventory \
76 demo demo/startup demo/startup/aaf demo/startup/controller demo/startup/message-router dmaapbc operation operation/utils pgaas utils utils/buildtools; do
77 compile_src $src_folder/$dirc
78 done
79}
80
81
Victor Morales89ce3212017-06-16 18:32:48 -050082# install_dcae() - Function that clones and installs the DCAE controller services from source code
83function install_dcae {
Victor Morales89ce3212017-06-16 18:32:48 -050084 install_docker_compose
Victor Moralesdd074802017-07-26 16:06:35 -050085
86 clone_all_dcae_repos
87 if [[ "$compile_repo" == "True" ]]; then
88 compile_all_dcae_repos
89 fi
90
Victor Morales89ce3212017-06-16 18:32:48 -050091 if [[ "$build_image" == "True" ]]; then
92 install_docker
Victor Moralesdd074802017-07-26 16:06:35 -050093 local src_folder=/opt/dcae
Victor Morales89ce3212017-06-16 18:32:48 -050094
95 compile_docker_image dcae/dmaapb $src_folder/dmaapbc openecomp/dcae-dmaapbc
96 compile_docker_image dcae/orch-dispatcher $src_folder/orch-dispatcher dcae/orch-dispatcher
97
98 clone_repo dcae/demo $src_folder/demo
99 compile_src $src_folder/demo
100 pushd $src_folder/demo
101 bash dcae-demo-controller/src/main/docker-build/build.sh
102 asserts_image dcae-controller
103 popd
104
105 clone_repo dcae/dcae-inventory $src_folder/dcae-inventory
106 compile_src $src_folder/dcae-inventory
107 build_docker_image $src_folder/dcae-inventory
108 asserts_image dcae-inventory
109
110 dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
Victor Moralesdd074802017-07-26 16:06:35 -0500111 pushd $src_folder/demo/startup/controller
Victor Morales89ce3212017-06-16 18:32:48 -0500112 sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
113 sed -i "s|MTU|$MTU|g" docker-compose.yml
114 /opt/docker/docker-compose up -d
Victor Moralesdd074802017-07-26 16:06:35 -0500115 popd
Victor Morales89ce3212017-06-16 18:32:48 -0500116 else
Victor Moralesdd074802017-07-26 16:06:35 -0500117 pushd /opt/dcae/demo/startup/controller
Victor Morales89ce3212017-06-16 18:32:48 -0500118 bash init.sh
119 install_package make
120 make up
Victor Moralesdd074802017-07-26 16:06:35 -0500121 popd
Victor Morales89ce3212017-06-16 18:32:48 -0500122 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500123}
124
125# init_dcae() - Function that initialize DCAE Controller services
126function init_dcae {
127 create_config_file
128 install_dcae
129}