Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 3 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 4 | |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 5 | mso_src_folder=$git_src_folder/mso |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 6 | mso_repos=("mso" "mso/chef-repo" "mso/docker-config" "mso/libs" |
| 7 | "mso/mso-config") |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 8 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 9 | # get_mso_images() - Function that retrieves or create MSO Docker images |
| 10 | function get_mso_images { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 11 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 12 | export GIT_NO_PROJECT=/opt/ |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 13 | compile_src $mso_src_folder |
| 14 | build_docker_image $mso_src_folder/packages/docker docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 15 | fi |
| 16 | } |
| 17 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 18 | # install_mso() - Install MSO Docker configuration project |
| 19 | function install_mso { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 20 | 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 | } |
| 65 | EOF |
| 66 | export MSO_CONFIG_UPDATES |
| 67 | export MSO_DOCKER_IMAGE_VERSION=$docker_version |
| 68 | |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 69 | install_docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 70 | install_docker_compose |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 71 | # Deploy the environment |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 72 | pushd $mso_src_folder/docker-config |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 73 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 80 | popd |
| 81 | } |
| 82 | |
| 83 | # init_mso() - Function that initialize MSO services |
| 84 | function init_mso { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 85 | if [[ "$clone_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 86 | clone_repos "mso" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 87 | if [[ "$compile_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 88 | compile_repos "mso" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 89 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 90 | fi |
| 91 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 92 | if [[ "$skip_get_images" == "False" ]]; then |
| 93 | get_mso_images |
| 94 | if [[ "$skip_install" == "False" ]]; then |
| 95 | install_mso |
| 96 | fi |
| 97 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 98 | } |