Centralize src_folder and repos info
[integration.git] / bootstrap / vagrant-onap / lib / mso
1 #!/bin/bash
2
3 source /var/onap/functions
4
5 # get_mso_images() - Function that retrieves or create MSO Docker images
6 function get_mso_images {
7     if [[ "$build_image" == "True" ]]; then
8         export GIT_NO_PROJECT=/opt/
9         compile_src $mso_src_folder
10         build_docker_image $mso_src_folder/packages/docker docker
11     fi
12 }
13
14 # install_mso() - Install MSO Docker configuration project
15 function install_mso {
16     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 }
61 EOF
62     export MSO_CONFIG_UPDATES
63     export MSO_DOCKER_IMAGE_VERSION=$docker_version
64
65     install_docker
66     install_docker_compose
67     # Deploy the environment
68     pushd $mso_src_folder/docker-config
69     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
76     popd
77 }
78
79 # init_mso() - Function that initialize MSO services
80 function init_mso {
81     if [[ "$clone_repo" == "True" ]]; then
82         clone_repos "mso"
83         if [[ "$compile_repo" == "True" ]]; then
84             compile_repos "mso"
85         fi
86     fi
87
88     if [[ "$skip_get_images" == "False" ]]; then
89         get_mso_images
90         if [[ "$skip_install" == "False" ]]; then
91             install_mso
92         fi
93     fi
94 }