blob: 4f88e90858de2739fbbd0b7921ffb0a5a47c9c77 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
Victor Moralesdd074802017-07-26 16:06:35 -05006
7src_folder=$git_src_folder/mso
8mso_repos=("chef-repo" "docker-config" "libs" "mso-config")
9
10# clone_all_mso_repos() - Function that clones MSO source repo.
11function clone_all_mso_repos {
12 clone_repo mso $src_folder
13
14 for dirc in ${mso_repos[@]}; do
15 clone_repo mso/$dirc $src_folder/$dirc
16 done
17}
18
19# compile_all_mso_repos() - Function that compiles MSO source repo.
20function compile_all_mso_repos {
21 compile_src $src_folder
22
23 for dirc in ${mso_repos[@]}; do
24 compile_src $src_folder/$dirc
25 done
26}
Victor Morales89ce3212017-06-16 18:32:48 -050027
28# install_mso() - Installation of mso images
29function install_mso {
Victor Morales89ce3212017-06-16 18:32:48 -050030 if [[ "$build_image" == "True" ]]; then
Victor Morales89ce3212017-06-16 18:32:48 -050031 export GIT_NO_PROJECT=/opt/
Victor Moralesdd074802017-07-26 16:06:35 -050032 compile_src $src_folder
33 build_docker_image $src_folder/packages/docker docker
Victor Morales89ce3212017-06-16 18:32:48 -050034 fi
35}
36
37# install_mso_docker_config() - Download and install MSO Docker configuration project
38function install_mso_docker_config {
Victor Morales89ce3212017-06-16 18:32:48 -050039 MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key)
40 echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt
41
42 # Deployments in OpenStack require a keystone file
43 if [ -e /opt/config/keystone.txt ]; then
44 KEYSTONE_URL=$(cat /opt/config/keystone.txt)
45 DCP_CLLI="DEFAULT_KEYSTONE"
46 AUTH_TYPE="USERNAME_PASSWORD"
47 else
48 KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
49 DCP_CLLI="RAX_KEYSTONE"
50 AUTH_TYPE="RACKSPACE_APIKEY"
51 fi
52
53 # Update the MSO configuration file.
54 read -d '' MSO_CONFIG_UPDATES <<-EOF
55{
56"default_attributes":
57 {
58 "asdc-connections":
59 {
60 "asdc-controller1":
61 {
62 "environmentName": "$dmaap_topic"
63 }
64 },
65 "mso-po-adapter-config":
66 {
67 "identity_services":
68 [
69 {
70 "dcp_clli": "$DCP_CLLI",
71 "identity_url": "$KEYSTONE_URL",
72 "mso_id": "$openstack_username",
73 "mso_pass": "$openstack_password",
74 "admin_tenant": "service",
75 "member_role": "admin",
76 "tenant_metadata": "true",
77 "identity_server_type": "KEYSTONE",
78 "identity_authentication_type": "$AUTH_TYPE"
79 }
80 ]
81 }
82 }
83}
84EOF
85 export MSO_CONFIG_UPDATES
86 export MSO_DOCKER_IMAGE_VERSION=$docker_version
87
Victor Morales89ce3212017-06-16 18:32:48 -050088 is_package_installed docker-ce || install_docker
89 install_docker_compose
Victor Moralesdd074802017-07-26 16:06:35 -050090 # Deploy the environment
91 pushd $src_folder/docker-config
92 chmod +x deploy.sh
93 if [[ "$build_image" == "True" ]]; then
94 bash deploy.sh
95 else
96 # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
97 bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password
98 fi
Victor Morales89ce3212017-06-16 18:32:48 -050099 popd
100}
101
102# init_mso() - Function that initialize MSO services
103function init_mso {
Victor Moralesdd074802017-07-26 16:06:35 -0500104 clone_all_mso_repos
105 if [[ "$compile_repo" == "True" ]]; then
106 compile_all_mso_repos
107 fi
108
Victor Morales89ce3212017-06-16 18:32:48 -0500109 install_mso
110 install_mso_docker_config
111}