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 | |
| 5 | 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 | |
| 9 | # clone_all_mso_repos() - Function that clones MSO source repo. |
| 10 | function clone_all_mso_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 11 | for repo in ${mso_repos[@]}; do |
| 12 | clone_repo $repo $src_folder${repo#*mso} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 13 | done |
| 14 | } |
| 15 | |
| 16 | # compile_all_mso_repos() - Function that compiles MSO source repo. |
| 17 | function compile_all_mso_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 18 | for repo in ${mso_repos[@]}; do |
| 19 | compile_src $src_folder${repo#*mso} |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 20 | done |
| 21 | } |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 22 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 23 | # get_mso_images() - Function that retrieves or create MSO Docker images |
| 24 | function get_mso_images { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 25 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 26 | export GIT_NO_PROJECT=/opt/ |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 27 | compile_src $src_folder |
| 28 | build_docker_image $src_folder/packages/docker docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 29 | fi |
| 30 | } |
| 31 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 32 | # install_mso() - Install MSO Docker configuration project |
| 33 | function install_mso { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 34 | MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key) |
| 35 | echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt |
| 36 | |
| 37 | # Deployments in OpenStack require a keystone file |
| 38 | if [ -e /opt/config/keystone.txt ]; then |
| 39 | KEYSTONE_URL=$(cat /opt/config/keystone.txt) |
| 40 | DCP_CLLI="DEFAULT_KEYSTONE" |
| 41 | AUTH_TYPE="USERNAME_PASSWORD" |
| 42 | else |
| 43 | KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0" |
| 44 | DCP_CLLI="RAX_KEYSTONE" |
| 45 | AUTH_TYPE="RACKSPACE_APIKEY" |
| 46 | fi |
| 47 | |
| 48 | # Update the MSO configuration file. |
| 49 | read -d '' MSO_CONFIG_UPDATES <<-EOF |
| 50 | { |
| 51 | "default_attributes": |
| 52 | { |
| 53 | "asdc-connections": |
| 54 | { |
| 55 | "asdc-controller1": |
| 56 | { |
| 57 | "environmentName": "$dmaap_topic" |
| 58 | } |
| 59 | }, |
| 60 | "mso-po-adapter-config": |
| 61 | { |
| 62 | "identity_services": |
| 63 | [ |
| 64 | { |
| 65 | "dcp_clli": "$DCP_CLLI", |
| 66 | "identity_url": "$KEYSTONE_URL", |
| 67 | "mso_id": "$openstack_username", |
| 68 | "mso_pass": "$openstack_password", |
| 69 | "admin_tenant": "service", |
| 70 | "member_role": "admin", |
| 71 | "tenant_metadata": "true", |
| 72 | "identity_server_type": "KEYSTONE", |
| 73 | "identity_authentication_type": "$AUTH_TYPE" |
| 74 | } |
| 75 | ] |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | EOF |
| 80 | export MSO_CONFIG_UPDATES |
| 81 | export MSO_DOCKER_IMAGE_VERSION=$docker_version |
| 82 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 83 | is_package_installed docker-ce || install_docker |
| 84 | install_docker_compose |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 85 | # Deploy the environment |
| 86 | pushd $src_folder/docker-config |
| 87 | chmod +x deploy.sh |
| 88 | if [[ "$build_image" == "True" ]]; then |
| 89 | bash deploy.sh |
| 90 | else |
| 91 | # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb) |
| 92 | bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password |
| 93 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 94 | popd |
| 95 | } |
| 96 | |
| 97 | # init_mso() - Function that initialize MSO services |
| 98 | function init_mso { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 99 | if [[ "$clone_repo" == "True" ]]; then |
| 100 | clone_all_mso_repos |
| 101 | if [[ "$compile_repo" == "True" ]]; then |
| 102 | compile_all_mso_repos |
| 103 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 104 | fi |
| 105 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 106 | if [[ "$skip_get_images" == "False" ]]; then |
| 107 | get_mso_images |
| 108 | if [[ "$skip_install" == "False" ]]; then |
| 109 | install_mso |
| 110 | fi |
| 111 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 112 | } |