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