blob: 78ca8de06f86198a2257133017b18266341d3b5b [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
Victor Morales21404d72017-10-20 13:18:26 -07008dcae_repos=("dcae" "dcae/apod" "dcae/apod/analytics" "dcae/apod/buildtools"
9"dcae/apod/cdap" "dcae/collectors" "dcae/collectors/ves" "dcae/controller"
10"dcae/controller/analytics" "dcae/dcae-inventory" "dcae/demo"
11"dcae/demo/startup" "dcae/demo/startup/aaf" "dcae/demo/startup/controller"
12"dcae/demo/startup/message-router" "dcae/dmaapbc" "dcae/operation"
13"dcae/operation/utils" "dcae/orch-dispatcher" "dcae/pgaas" "dcae/utils" "dcae/utils/buildtools")
Victor Morales80ef0a42017-08-21 19:17:07 -050014
15# _create_config_file() - Creates a configuration yaml file for the controller
16function _create_config_file {
17 cat > $dcae_src_folder/controller/config.yaml << EOL
Victor Morales89ce3212017-06-16 18:32:48 -050018ZONE: $dcae_zone
19STATE: $dcae_state
20DCAE-VERSION: $artifacts_version
21HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
22KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
23OPENSTACK-TENANT-ID: $tenant_id
24OPENSTACK-TENANT-NAME: OPEN-ECOMP
25OPENSTACK-REGION: $openstack_region
26OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
27OPENSTACK-USER: $openstack_user
28OPENSTACK-PASSWORD: $openstack_password
29OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
30OPENSTACK-PUBKEY: $pub_key
31
32NEXUS-URL-ROOT: $nexus_repo_root
33NEXUS-USER: $nexus_username
34NEXUS-PASSWORD: $nexus_password
35NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
36NEXUS-RAWURL: $nexus_repo
37
38DOCKER-REGISTRY: $nexus_docker_repo
39
40GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
41EOL
42}
43
Victor Morales80ef0a42017-08-21 19:17:07 -050044# _build_docker_image() - Function that clones, compiles and build a Docker image
45function _build_docker_image {
46 local src_folder=$1
47 local name=$2
48 install_docker
49
Victor Morales89ce3212017-06-16 18:32:48 -050050 pushd $src_folder
Victor Moralescf269992017-10-18 09:29:55 -070051 # NOTE: Workaround for dmmapbc images
Victor Morales89ce3212017-06-16 18:32:48 -050052 sed -i '/LocalKey/d' Dockerfile
53 local docker_build="docker build -t $name -f ./Dockerfile ."
54 if [ $http_proxy ]; then
55 docker_build+=" --build-arg http_proxy=$http_proxy"
56 fi
57 if [ $https_proxy ]; then
58 docker_build+=" --build-arg https_proxy=$https_proxy"
59 fi
60 eval $docker_build
Victor Morales89ce3212017-06-16 18:32:48 -050061 popd
62}
63
Victor Moralesdd074802017-07-26 16:06:35 -050064# clone_all_dcae_repos() - Function that clones DCAE source repo.
65function clone_all_dcae_repos {
Victor Morales21404d72017-10-20 13:18:26 -070066 for repo in ${dcae_repos[@]}; do
67 clone_repo $repo $dcae_src_folder${repo#*dcae}
Victor Moralesdd074802017-07-26 16:06:35 -050068 done
69}
70
71# compile_all_dcae_repos() - Function that compiles DCAE source repo.
72function compile_all_dcae_repos {
Victor Morales21404d72017-10-20 13:18:26 -070073 for repo in ${dcae_repos[@]}; do
74 compile_src $dcae_src_folder${repo#*dcae}
Victor Moralesdd074802017-07-26 16:06:35 -050075 done
76}
77
Victor Morales10d21db2017-08-23 13:26:09 -050078# _build_dcae_images() Function that builds DCAE docker images from source code.
Victor Morales80ef0a42017-08-21 19:17:07 -050079function _build_dcae_images {
80 if [[ "$compile_repo" != "True" ]]; then
81 compile_src $dcae_src_folder/dmaapbc
82 compile_src $dcae_src_folder/orch-dispatcher
83 compile_src $dcae_src_folder/demo
84 compile_src $dcae_src_folder/dcae-inventory
85 fi
86 _build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc
87 _build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher
88
89 pushd $dcae_src_folder/demo
90 bash dcae-demo-controller/src/main/docker-build/build.sh
91 popd
92
93 build_docker_image $dcae_src_folder/dcae-inventory
94}
95
96# get_dcae_images() - Function that retrieves or builds DCAE docker images.
97function get_dcae_images {
98 if [[ "$build_image" == "True" ]]; then
99 _build_dcae_images
100 else
101 pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc
102 pull_openecomp_image dcae-controller
103 fi
104}
Victor Moralesdd074802017-07-26 16:06:35 -0500105
Victor Morales89ce3212017-06-16 18:32:48 -0500106# install_dcae() - Function that clones and installs the DCAE controller services from source code
107function install_dcae {
Victor Morales89ce3212017-06-16 18:32:48 -0500108 install_docker_compose
Victor Morales80ef0a42017-08-21 19:17:07 -0500109 pushd $dcae_src_folder/demo/startup/controller
110 if [[ "$build_image" == "True" ]]; then
111 dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
112 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
115 else
116 bash init.sh
117 install_package make
118 make up
119 fi
120 popd
121 # docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version>
122}
Victor Moralesdd074802017-07-26 16:06:35 -0500123
Victor Morales80ef0a42017-08-21 19:17:07 -0500124# init_dcae() - Function that initialize DCAE Controller services
125function init_dcae {
Idan Amit1690e082017-08-20 08:58:14 +0300126 if [[ "$clone_repo" == "True" ]]; then
127 clone_all_dcae_repos
128 if [[ "$compile_repo" == "True" ]]; then
129 compile_all_dcae_repos
130 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500131 fi
132
Victor Morales80ef0a42017-08-21 19:17:07 -0500133 _create_config_file
Victor Morales6a919972017-09-28 18:29:54 -0700134 if [[ "$skip_get_images" == "False" ]]; then
135 get_dcae_images
136 if [[ "$skip_install" == "False" ]]; then
137 install_dcae
138 fi
139 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500140}