blob: e99bff912d51692b93bee88136026b706ab71c56 [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
Victor Moralesf1f1ba52017-11-20 16:38:28 -08005mso_src_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
Victor Morales6a919972017-09-28 18:29:54 -07009# get_mso_images() - Function that retrieves or create MSO Docker images
10function get_mso_images {
Victor Morales89ce3212017-06-16 18:32:48 -050011 if [[ "$build_image" == "True" ]]; then
Victor Morales89ce3212017-06-16 18:32:48 -050012 export GIT_NO_PROJECT=/opt/
Victor Moralesf1f1ba52017-11-20 16:38:28 -080013 compile_src $mso_src_folder
14 build_docker_image $mso_src_folder/packages/docker docker
Victor Morales89ce3212017-06-16 18:32:48 -050015 fi
16}
17
Victor Morales6a919972017-09-28 18:29:54 -070018# install_mso() - Install MSO Docker configuration project
19function install_mso {
Victor Morales89ce3212017-06-16 18:32:48 -050020 MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key)
21 echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt
22
23 # Deployments in OpenStack require a keystone file
24 if [ -e /opt/config/keystone.txt ]; then
25 KEYSTONE_URL=$(cat /opt/config/keystone.txt)
26 DCP_CLLI="DEFAULT_KEYSTONE"
27 AUTH_TYPE="USERNAME_PASSWORD"
28 else
29 KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
30 DCP_CLLI="RAX_KEYSTONE"
31 AUTH_TYPE="RACKSPACE_APIKEY"
32 fi
33
34 # Update the MSO configuration file.
35 read -d '' MSO_CONFIG_UPDATES <<-EOF
36{
37"default_attributes":
38 {
39 "asdc-connections":
40 {
41 "asdc-controller1":
42 {
43 "environmentName": "$dmaap_topic"
44 }
45 },
46 "mso-po-adapter-config":
47 {
48 "identity_services":
49 [
50 {
51 "dcp_clli": "$DCP_CLLI",
52 "identity_url": "$KEYSTONE_URL",
53 "mso_id": "$openstack_username",
54 "mso_pass": "$openstack_password",
55 "admin_tenant": "service",
56 "member_role": "admin",
57 "tenant_metadata": "true",
58 "identity_server_type": "KEYSTONE",
59 "identity_authentication_type": "$AUTH_TYPE"
60 }
61 ]
62 }
63 }
64}
65EOF
66 export MSO_CONFIG_UPDATES
67 export MSO_DOCKER_IMAGE_VERSION=$docker_version
68
Victor Moralesf1f1ba52017-11-20 16:38:28 -080069 install_docker
Victor Morales89ce3212017-06-16 18:32:48 -050070 install_docker_compose
Victor Moralesdd074802017-07-26 16:06:35 -050071 # Deploy the environment
Victor Moralesf1f1ba52017-11-20 16:38:28 -080072 pushd $mso_src_folder/docker-config
Victor Moralesdd074802017-07-26 16:06:35 -050073 chmod +x deploy.sh
74 if [[ "$build_image" == "True" ]]; then
75 bash deploy.sh
76 else
77 # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
78 bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password
79 fi
Victor Morales89ce3212017-06-16 18:32:48 -050080 popd
81}
82
83# init_mso() - Function that initialize MSO services
84function init_mso {
Idan Amit1690e082017-08-20 08:58:14 +030085 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080086 clone_repos "mso"
Idan Amit1690e082017-08-20 08:58:14 +030087 if [[ "$compile_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080088 compile_repos "mso"
Idan Amit1690e082017-08-20 08:58:14 +030089 fi
Victor Moralesdd074802017-07-26 16:06:35 -050090 fi
91
Victor Morales6a919972017-09-28 18:29:54 -070092 if [[ "$skip_get_images" == "False" ]]; then
93 get_mso_images
94 if [[ "$skip_install" == "False" ]]; then
95 install_mso
96 fi
97 fi
Victor Morales89ce3212017-06-16 18:32:48 -050098}