Centralize src_folder and repos info
[integration.git] / bootstrap / vagrant-onap / lib / dcae
1 #!/bin/bash
2
3 source /var/onap/functions
4
5 # _create_config_file() - Creates a configuration yaml file for the controller
6 function _create_config_file {
7     cat > $dcae_src_folder/controller/config.yaml << EOL
8 ZONE: $dcae_zone
9 STATE: $dcae_state
10 DCAE-VERSION: $artifacts_version
11 HORIZON-URL: https://mycloud.rackspace.com/cloud/$tenant_id
12 KEYSTONE-URL: https://identity.api.rackspacecloud.com/v2.0
13 OPENSTACK-TENANT-ID: $tenant_id
14 OPENSTACK-TENANT-NAME: OPEN-ECOMP
15 OPENSTACK-REGION: $openstack_region
16 OPENSTACK-PRIVATE-NETWORK: $openstack_private_network_name
17 OPENSTACK-USER: $openstack_user
18 OPENSTACK-PASSWORD: $openstack_password
19 OPENSTACK-KEYNAME: ${key_name}${rand_str}_dcae
20 OPENSTACK-PUBKEY: $pub_key
21      
22 NEXUS-URL-ROOT: $nexus_repo_root
23 NEXUS-USER: $nexus_username
24 NEXUS-PASSWORD: $nexus_password
25 NEXUS-URL-SNAPSHOTS: $nexus_url_snapshots
26 NEXUS-RAWURL: $nexus_repo
27      
28 DOCKER-REGISTRY: $nexus_docker_repo
29
30 GIT-MR-REPO: http://gerrit.onap.org/r/dcae/demo/startup/message-router.git
31 EOL
32 }
33
34 # _build_dcae_images() Function that builds DCAE docker images from source code.
35 function _build_dcae_images {
36     if [[ "$compile_repo" != "True" ]]; then
37         compile_repos "dcae"
38     fi
39     build_docker_image $dcae_src_folder/dmaapbc openecomp/dcae-dmaapbc
40     build_docker_image $dcae_src_folder/orch-dispatcher dcae/orch-dispatcher
41
42     pushd $dcae_src_folder/demo
43     bash dcae-demo-controller/src/main/docker-build/build.sh
44     popd
45
46     build_docker_image $dcae_src_folder/dcae-inventory
47 }
48
49 # get_dcae_images() - Function that retrieves or builds DCAE docker images.
50 function get_dcae_images {
51     if [[ "$build_image" == "True" ]]; then
52         _build_dcae_images
53     else
54         pull_openecomp_image dcae-dmaapbc openecomp/dcae-dmaapbc
55         pull_openecomp_image dcae-controller
56     fi
57 }
58
59 # install_dcae() - Function that clones and installs the DCAE controller services from source code
60 function install_dcae {
61     install_docker_compose
62     pushd $dcae_src_folder/demo/startup/controller
63     if [[ "$build_image" == "True" ]]; then
64         dcae_image=`docker images | grep dcae-controller | awk '{print $1 ":" $2}'`
65         sed -i "s|DOCKER-REGISTRY/openecomp/dcae-controller:DCAE-VERSION|$dcae_image|g" docker-compose.yml
66         sed -i "s|MTU|$MTU|g" docker-compose.yml
67         /opt/docker/docker-compose up -d
68     else
69         bash init.sh
70         install_package make
71         make up
72     fi
73     popd
74     # run_docker_image -p 8080:8080 -d -v <some local directory>/config.yml:/opt/config.yml --name dcae-inventory <docker registry>/dcae-inventory:<version>
75 }
76
77 # init_dcae() - Function that initialize DCAE Controller services
78 function init_dcae {
79     if [[ "$clone_repo" == "True" ]]; then
80         clone_repos "dcae"
81         if [[ "$compile_repo" == "True" ]]; then
82             compile_repos "dcae"
83         fi
84     fi
85
86     _create_config_file
87     if [[ "$skip_get_images" == "False" ]]; then
88         get_dcae_images
89         if [[ "$skip_install" == "False" ]]; then
90             install_dcae
91         fi
92     fi
93 }