blob: 43da9f59bd7e210cacbbed27c414ba34d58c7d33 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
Victor Morales89ce3212017-06-16 18:32:48 -05006
Victor Morales80ef0a42017-08-21 19:17:07 -05007dcae_src_folder=$git_src_folder/dcae
8dcae_repos=("apod" "apod/analytics" "apod/buildtools" "apod/cdap" "collectors" "collectors/ves" "controller" "controller/analytics" "dcae-inventory"
9"demo" "demo/startup" "demo/startup/aaf" "demo/startup/controller" "demo/startup/message-router" "dmaapbc" "operation" "operation/utils" "pgaas" "utils" "utils/buildtools")
10
11# _create_config_file() - Creates a configuration yaml file for the controller
12function _create_config_file {
13 cat > $dcae_src_folder/controller/config.yaml << EOL
Victor Morales89ce3212017-06-16 18:32:48 -050014ZONE: $dcae_zone
15STATE: $dcae_state
16DCAE-VERSION: $artifacts_version
17HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
18KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
19OPENSTACK-TENANT-ID: $tenant_id
20OPENSTACK-TENANT-NAME: OPEN-ECOMP
21OPENSTACK-REGION: $openstack_region
22OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
23OPENSTACK-USER: $openstack_user
24OPENSTACK-PASSWORD: $openstack_password
25OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
26OPENSTACK-PUBKEY: $pub_key
27
28NEXUS-URL-ROOT: $nexus_repo_root
29NEXUS-USER: $nexus_username
30NEXUS-PASSWORD: $nexus_password
31NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
32NEXUS-RAWURL: $nexus_repo
33
34DOCKER-REGISTRY: $nexus_docker_repo
35
36GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
37EOL
38}
39
Victor Morales80ef0a42017-08-21 19:17:07 -050040# _build_docker_image() - Function that clones, compiles and build a Docker image
41function _build_docker_image {
42 local src_folder=$1
43 local name=$2
44 install_docker
45
Victor Morales89ce3212017-06-16 18:32:48 -050046 pushd $src_folder
Victor Morales80ef0a42017-08-21 19:17:07 -050047 # TODO(electrocucaracha) Workaround for dmmapbc images
Victor Morales89ce3212017-06-16 18:32:48 -050048 sed -i '/LocalKey/d' Dockerfile
49 local docker_build="docker build -t $name -f ./Dockerfile ."
50 if [ $http_proxy ]; then
51 docker_build+=" --build-arg http_proxy=$http_proxy"
52 fi
53 if [ $https_proxy ]; then
54 docker_build+=" --build-arg https_proxy=$https_proxy"
55 fi
56 eval $docker_build
Victor Morales89ce3212017-06-16 18:32:48 -050057 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 {
Victor Morales80ef0a42017-08-21 19:17:07 -050062 clone_repo dcae $dcae_src_folder
63 for dirc in ${dcae_repos[@]}; do
64 clone_repo dcae/$dirc $dcae_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050065 done
66}
67
68# compile_all_dcae_repos() - Function that compiles DCAE source repo.
69function compile_all_dcae_repos {
Victor Morales80ef0a42017-08-21 19:17:07 -050070 for dirc in ${dcae_repos[@]}; do
71 compile_src $dcae_src_folder/$dirc
Victor Moralesdd074802017-07-26 16:06:35 -050072 done
73}
74
Victor Morales10d21db2017-08-23 13:26:09 -050075# _build_dcae_images() Function that builds DCAE docker images from source code.
Victor Morales80ef0a42017-08-21 19:17:07 -050076function _build_dcae_images {
77 if [[ "$compile_repo" != "True" ]]; then
78 compile_src $dcae_src_folder/dmaapbc
79 compile_src $dcae_src_folder/orch-dispatcher
80 compile_src $dcae_src_folder/demo
81 compile_src $dcae_src_folder/dcae-inventory
82 fi
83 _build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc
84 _build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher
85
86 pushd $dcae_src_folder/demo
87 bash dcae-demo-controller/src/main/docker-build/build.sh
88 popd
89
90 build_docker_image $dcae_src_folder/dcae-inventory
91}
92
93# get_dcae_images() - Function that retrieves or builds DCAE docker images.
94function get_dcae_images {
95 if [[ "$build_image" == "True" ]]; then
96 _build_dcae_images
97 else
98 pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc
99 pull_openecomp_image dcae-controller
100 fi
101}
Victor Moralesdd074802017-07-26 16:06:35 -0500102
Victor Morales89ce3212017-06-16 18:32:48 -0500103# install_dcae() - Function that clones and installs the DCAE controller services from source code
104function install_dcae {
Victor Morales89ce3212017-06-16 18:32:48 -0500105 install_docker_compose
Victor Morales80ef0a42017-08-21 19:17:07 -0500106 pushd $dcae_src_folder/demo/startup/controller
107 if [[ "$build_image" == "True" ]]; then
108 dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
109 sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
110 sed -i "s|MTU|$MTU|g" docker-compose.yml
111 /opt/docker/docker-compose up -d
112 else
113 bash init.sh
114 install_package make
115 make up
116 fi
117 popd
118 # docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version>
119}
Victor Moralesdd074802017-07-26 16:06:35 -0500120
Victor Morales80ef0a42017-08-21 19:17:07 -0500121# init_dcae() - Function that initialize DCAE Controller services
122function init_dcae {
Idan Amit1690e082017-08-20 08:58:14 +0300123 if [[ "$clone_repo" == "True" ]]; then
124 clone_all_dcae_repos
125 if [[ "$compile_repo" == "True" ]]; then
126 compile_all_dcae_repos
127 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500128 fi
129
Victor Morales80ef0a42017-08-21 19:17:07 -0500130 _create_config_file
131 get_dcae_images
Victor Morales89ce3212017-06-16 18:32:48 -0500132 install_dcae
133}