blob: 44d4a7b0493f55d4ece63b89af4f6afcba060bae [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 Morales6a919972017-09-28 18:29:54 -07005# get_mso_images() - Function that retrieves or create MSO Docker images
6function get_mso_images {
Victor Morales89ce3212017-06-16 18:32:48 -05007 if [[ "$build_image" == "True" ]]; then
Victor Morales89ce3212017-06-16 18:32:48 -05008 export GIT_NO_PROJECT=/opt/
Victor Moralesf1f1ba52017-11-20 16:38:28 -08009 compile_src $mso_src_folder
10 build_docker_image $mso_src_folder/packages/docker docker
Victor Morales89ce3212017-06-16 18:32:48 -050011 fi
12}
13
Victor Morales6a919972017-09-28 18:29:54 -070014# install_mso() - Install MSO Docker configuration project
15function install_mso {
Victor Morales89ce3212017-06-16 18:32:48 -050016 MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key)
17 echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt
18
19 # Deployments in OpenStack require a keystone file
20 if [ -e /opt/config/keystone.txt ]; then
21 KEYSTONE_URL=$(cat /opt/config/keystone.txt)
22 DCP_CLLI="DEFAULT_KEYSTONE"
23 AUTH_TYPE="USERNAME_PASSWORD"
24 else
25 KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
26 DCP_CLLI="RAX_KEYSTONE"
27 AUTH_TYPE="RACKSPACE_APIKEY"
28 fi
29
30 # Update the MSO configuration file.
31 read -d '' MSO_CONFIG_UPDATES <<-EOF
32{
33"default_attributes":
34 {
35 "asdc-connections":
36 {
37 "asdc-controller1":
38 {
39 "environmentName": "$dmaap_topic"
40 }
41 },
42 "mso-po-adapter-config":
43 {
44 "identity_services":
45 [
46 {
47 "dcp_clli": "$DCP_CLLI",
48 "identity_url": "$KEYSTONE_URL",
49 "mso_id": "$openstack_username",
50 "mso_pass": "$openstack_password",
51 "admin_tenant": "service",
52 "member_role": "admin",
53 "tenant_metadata": "true",
54 "identity_server_type": "KEYSTONE",
55 "identity_authentication_type": "$AUTH_TYPE"
56 }
57 ]
58 }
59 }
60}
61EOF
62 export MSO_CONFIG_UPDATES
63 export MSO_DOCKER_IMAGE_VERSION=$docker_version
64
Victor Moralesf1f1ba52017-11-20 16:38:28 -080065 install_docker
Victor Morales89ce3212017-06-16 18:32:48 -050066 install_docker_compose
Victor Moralesdd074802017-07-26 16:06:35 -050067 # Deploy the environment
Victor Moralesf1f1ba52017-11-20 16:38:28 -080068 pushd $mso_src_folder/docker-config
Victor Moralesdd074802017-07-26 16:06:35 -050069 chmod +x deploy.sh
70 if [[ "$build_image" == "True" ]]; then
71 bash deploy.sh
72 else
73 # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
74 bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password
75 fi
Victor Morales89ce3212017-06-16 18:32:48 -050076 popd
77}
78
79# init_mso() - Function that initialize MSO services
80function init_mso {
Idan Amit1690e082017-08-20 08:58:14 +030081 if [[ "$clone_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080082 clone_repos "mso"
Idan Amit1690e082017-08-20 08:58:14 +030083 if [[ "$compile_repo" == "True" ]]; then
Victor Moralesf1f1ba52017-11-20 16:38:28 -080084 compile_repos "mso"
Idan Amit1690e082017-08-20 08:58:14 +030085 fi
Victor Moralesdd074802017-07-26 16:06:35 -050086 fi
87
Victor Morales6a919972017-09-28 18:29:54 -070088 if [[ "$skip_get_images" == "False" ]]; then
89 get_mso_images
90 if [[ "$skip_install" == "False" ]]; then
91 install_mso
92 fi
93 fi
Victor Morales89ce3212017-06-16 18:32:48 -050094}