Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
| 5 | source /var/onap/functions |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 6 | source /var/onap/asserts |
| 7 | |
| 8 | src_folder=$git_src_folder/mso |
| 9 | mso_repos=("chef-repo" "docker-config" "libs" "mso-config") |
| 10 | |
| 11 | # clone_all_mso_repos() - Function that clones MSO source repo. |
| 12 | function 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. |
| 21 | function 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 28 | |
| 29 | # install_mso() - Installation of mso images |
| 30 | function install_mso { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 31 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 32 | export GIT_NO_PROJECT=/opt/ |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 33 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 38 | fi |
| 39 | } |
| 40 | |
| 41 | # install_mso_docker_config() - Download and install MSO Docker configuration project |
| 42 | function install_mso_docker_config { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 43 | 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 | } |
| 88 | EOF |
| 89 | export MSO_CONFIG_UPDATES |
| 90 | export MSO_DOCKER_IMAGE_VERSION=$docker_version |
| 91 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 92 | is_package_installed docker-ce || install_docker |
| 93 | install_docker_compose |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 94 | # 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 103 | popd |
| 104 | } |
| 105 | |
| 106 | # init_mso() - Function that initialize MSO services |
| 107 | function init_mso { |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 108 | clone_all_mso_repos |
| 109 | if [[ "$compile_repo" == "True" ]]; then |
| 110 | compile_all_mso_repos |
| 111 | fi |
| 112 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 113 | install_mso |
| 114 | install_mso_docker_config |
| 115 | } |