blob: 0f29b33c5d41c844a9833100cc61f2201c5c221e [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 Moralesdd074802017-07-26 16:06:35 -05004
5src_folder=$git_src_folder/mso
Victor Morales21404d72017-10-20 13:18:26 -07006mso_repos=("mso" "mso/chef-repo" "mso/docker-config" "mso/libs"
7"mso/mso-config")
Victor Moralesdd074802017-07-26 16:06:35 -05008
9# clone_all_mso_repos() - Function that clones MSO source repo.
10function clone_all_mso_repos {
Victor Morales21404d72017-10-20 13:18:26 -070011 for repo in ${mso_repos[@]}; do
12 clone_repo $repo $src_folder${repo#*mso}
Victor Moralesdd074802017-07-26 16:06:35 -050013 done
14}
15
16# compile_all_mso_repos() - Function that compiles MSO source repo.
17function compile_all_mso_repos {
Victor Morales21404d72017-10-20 13:18:26 -070018 for repo in ${mso_repos[@]}; do
19 compile_src $src_folder${repo#*mso}
Victor Moralesdd074802017-07-26 16:06:35 -050020 done
21}
Victor Morales89ce3212017-06-16 18:32:48 -050022
Victor Morales6a919972017-09-28 18:29:54 -070023# get_mso_images() - Function that retrieves or create MSO Docker images
24function get_mso_images {
Victor Morales89ce3212017-06-16 18:32:48 -050025 if [[ "$build_image" == "True" ]]; then
Victor Morales89ce3212017-06-16 18:32:48 -050026 export GIT_NO_PROJECT=/opt/
Victor Moralesdd074802017-07-26 16:06:35 -050027 compile_src $src_folder
28 build_docker_image $src_folder/packages/docker docker
Victor Morales89ce3212017-06-16 18:32:48 -050029 fi
30}
31
Victor Morales6a919972017-09-28 18:29:54 -070032# install_mso() - Install MSO Docker configuration project
33function install_mso {
Victor Morales89ce3212017-06-16 18:32:48 -050034 MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key)
35 echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt
36
37 # Deployments in OpenStack require a keystone file
38 if [ -e /opt/config/keystone.txt ]; then
39 KEYSTONE_URL=$(cat /opt/config/keystone.txt)
40 DCP_CLLI="DEFAULT_KEYSTONE"
41 AUTH_TYPE="USERNAME_PASSWORD"
42 else
43 KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
44 DCP_CLLI="RAX_KEYSTONE"
45 AUTH_TYPE="RACKSPACE_APIKEY"
46 fi
47
48 # Update the MSO configuration file.
49 read -d '' MSO_CONFIG_UPDATES <<-EOF
50{
51"default_attributes":
52 {
53 "asdc-connections":
54 {
55 "asdc-controller1":
56 {
57 "environmentName": "$dmaap_topic"
58 }
59 },
60 "mso-po-adapter-config":
61 {
62 "identity_services":
63 [
64 {
65 "dcp_clli": "$DCP_CLLI",
66 "identity_url": "$KEYSTONE_URL",
67 "mso_id": "$openstack_username",
68 "mso_pass": "$openstack_password",
69 "admin_tenant": "service",
70 "member_role": "admin",
71 "tenant_metadata": "true",
72 "identity_server_type": "KEYSTONE",
73 "identity_authentication_type": "$AUTH_TYPE"
74 }
75 ]
76 }
77 }
78}
79EOF
80 export MSO_CONFIG_UPDATES
81 export MSO_DOCKER_IMAGE_VERSION=$docker_version
82
Victor Morales89ce3212017-06-16 18:32:48 -050083 is_package_installed docker-ce || install_docker
84 install_docker_compose
Victor Moralesdd074802017-07-26 16:06:35 -050085 # Deploy the environment
86 pushd $src_folder/docker-config
87 chmod +x deploy.sh
88 if [[ "$build_image" == "True" ]]; then
89 bash deploy.sh
90 else
91 # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
92 bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password
93 fi
Victor Morales89ce3212017-06-16 18:32:48 -050094 popd
95}
96
97# init_mso() - Function that initialize MSO services
98function init_mso {
Idan Amit1690e082017-08-20 08:58:14 +030099 if [[ "$clone_repo" == "True" ]]; then
100 clone_all_mso_repos
101 if [[ "$compile_repo" == "True" ]]; then
102 compile_all_mso_repos
103 fi
Victor Moralesdd074802017-07-26 16:06:35 -0500104 fi
105
Victor Morales6a919972017-09-28 18:29:54 -0700106 if [[ "$skip_get_images" == "False" ]]; then
107 get_mso_images
108 if [[ "$skip_install" == "False" ]]; then
109 install_mso
110 fi
111 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500112}