blob: 7ab32fd2479b9a4e0ab914f312473c9fe17ff929 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Morales89ce3212017-06-16 18:32:48 -05003source /var/onap/functions
Victor Morales89ce3212017-06-16 18:32:48 -05004
Victor Morales80ef0a42017-08-21 19:17:07 -05005dcae_src_folder=$git_src_folder/dcae
Victor Morales21404d72017-10-20 13:18:26 -07006dcae_repos=("dcae" "dcae/apod" "dcae/apod/analytics" "dcae/apod/buildtools"
7"dcae/apod/cdap" "dcae/collectors" "dcae/collectors/ves" "dcae/controller"
8"dcae/controller/analytics" "dcae/dcae-inventory" "dcae/demo"
9"dcae/demo/startup" "dcae/demo/startup/aaf" "dcae/demo/startup/controller"
10"dcae/demo/startup/message-router" "dcae/dmaapbc" "dcae/operation"
11"dcae/operation/utils" "dcae/orch-dispatcher" "dcae/pgaas" "dcae/utils" "dcae/utils/buildtools")
Victor Morales80ef0a42017-08-21 19:17:07 -050012
13# _create_config_file() - Creates a configuration yaml file for the controller
14function _create_config_file {
15 cat > $dcae_src_folder/controller/config.yaml << EOL
Victor Morales89ce3212017-06-16 18:32:48 -050016ZONE: $dcae_zone
17STATE: $dcae_state
18DCAE-VERSION: $artifacts_version
19HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
20KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
21OPENSTACK-TENANT-ID: $tenant_id
22OPENSTACK-TENANT-NAME: OPEN-ECOMP
23OPENSTACK-REGION: $openstack_region
24OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
25OPENSTACK-USER: $openstack_user
26OPENSTACK-PASSWORD: $openstack_password
27OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
28OPENSTACK-PUBKEY: $pub_key
29
30NEXUS-URL-ROOT: $nexus_repo_root
31NEXUS-USER: $nexus_username
32NEXUS-PASSWORD: $nexus_password
33NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
34NEXUS-RAWURL: $nexus_repo
35
36DOCKER-REGISTRY: $nexus_docker_repo
37
38GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
39EOL
40}
41
Victor Morales80ef0a42017-08-21 19:17:07 -050042# _build_docker_image() - Function that clones, compiles and build a Docker image
43function _build_docker_image {
44 local src_folder=$1
45 local name=$2
46 install_docker
47
Victor Morales89ce3212017-06-16 18:32:48 -050048 pushd $src_folder
Victor Moralescf269992017-10-18 09:29:55 -070049 # NOTE: Workaround for dmmapbc images
Victor Morales89ce3212017-06-16 18:32:48 -050050 sed -i '/LocalKey/d' Dockerfile
51 local docker_build="docker build -t $name -f ./Dockerfile ."
52 if [ $http_proxy ]; then
53 docker_build+=" --build-arg http_proxy=$http_proxy"
54 fi
55 if [ $https_proxy ]; then
56 docker_build+=" --build-arg https_proxy=$https_proxy"
57 fi
58 eval $docker_build
Victor Morales89ce3212017-06-16 18:32:48 -050059 popd
60}
61
Victor Moralesdd074802017-07-26 16:06:35 -050062# clone_all_dcae_repos() - Function that clones DCAE source repo.
63function clone_all_dcae_repos {
Victor Morales21404d72017-10-20 13:18:26 -070064 for repo in ${dcae_repos[@]}; do
65 clone_repo $repo $dcae_src_folder${repo#*dcae}
Victor Moralesdd074802017-07-26 16:06:35 -050066 done
67}
68
69# compile_all_dcae_repos() - Function that compiles DCAE source repo.
70function compile_all_dcae_repos {
Victor Morales21404d72017-10-20 13:18:26 -070071 for repo in ${dcae_repos[@]}; do
72 compile_src $dcae_src_folder${repo#*dcae}
Victor Moralesdd074802017-07-26 16:06:35 -050073 done
74}
75
Victor Morales10d21db2017-08-23 13:26:09 -050076# _build_dcae_images() Function that builds DCAE docker images from source code.
Victor Morales80ef0a42017-08-21 19:17:07 -050077function _build_dcae_images {
78 if [[ "$compile_repo" != "True" ]]; then
79 compile_src $dcae_src_folder/dmaapbc
80 compile_src $dcae_src_folder/orch-dispatcher
81 compile_src $dcae_src_folder/demo
82 compile_src $dcae_src_folder/dcae-inventory
83 fi
84 _build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc
85 _build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher
86
87 pushd $dcae_src_folder/demo
88 bash dcae-demo-controller/src/main/docker-build/build.sh
89 popd
90
91 build_docker_image $dcae_src_folder/dcae-inventory
92}
93
94# get_dcae_images() - Function that retrieves or builds DCAE docker images.
95function get_dcae_images {
96 if [[ "$build_image" == "True" ]]; then
97 _build_dcae_images
98 else
99 pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc
100 pull_openecomp_image dcae-controller
101 fi
102}
Victor Moralesdd074802017-07-26 16:06:35 -0500103
Victor Morales89ce3212017-06-16 18:32:48 -0500104# install_dcae() - Function that clones and installs the DCAE controller services from source code
105function install_dcae {
Victor Morales89ce3212017-06-16 18:32:48 -0500106 install_docker_compose
Victor Morales80ef0a42017-08-21 19:17:07 -0500107 pushd $dcae_src_folder/demo/startup/controller
108 if [[ "$build_image" == "True" ]]; then
109 dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
110 sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
111 sed -i "s|MTU|$MTU|g" docker-compose.yml
112 /opt/docker/docker-compose up -d
113 else
114 bash init.sh
115 install_package make
116 make up
117 fi
118 popd
119 # docker run -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version>
120}
Victor Moralesdd074802017-07-26 16:06:35 -0500121
Victor Morales80ef0a42017-08-21 19:17:07 -0500122# init_dcae() - Function that initialize DCAE Controller services
123function init_dcae {
Idan Amit1690e082017-08-20 08:58:14 +0300124 if [[ "$clone_repo" == "True" ]]; then
125 clone_all_dcae_repos
126 if [[ "$compile_repo" == "True" ]]; then
127 compile_all_dcae_repos
128 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500129 fi
130
Victor Morales80ef0a42017-08-21 19:17:07 -0500131 _create_config_file
Victor Morales6a919972017-09-28 18:29:54 -0700132 if [[ "$skip_get_images" == "False" ]]; then
133 get_dcae_images
134 if [[ "$skip_install" == "False" ]]; then
135 install_dcae
136 fi
137 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500138}