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