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 | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 5 | # get_mso_images() - Function that retrieves or create MSO Docker images |
| 6 | function get_mso_images { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 7 | if [[ "$build_image" == "True" ]]; then |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 8 | export GIT_NO_PROJECT=/opt/ |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 9 | compile_src $mso_src_folder |
| 10 | build_docker_image $mso_src_folder/packages/docker docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 11 | fi |
| 12 | } |
| 13 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 14 | # install_mso() - Install MSO Docker configuration project |
| 15 | function install_mso { |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 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 | |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 65 | install_docker |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 66 | install_docker_compose |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 67 | # Deploy the environment |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 68 | pushd $mso_src_folder/docker-config |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 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 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 76 | popd |
| 77 | } |
| 78 | |
| 79 | # init_mso() - Function that initialize MSO services |
| 80 | function init_mso { |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 81 | if [[ "$clone_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 82 | clone_repos "mso" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 83 | if [[ "$compile_repo" == "True" ]]; then |
Victor Morales | f1f1ba5 | 2017-11-20 16:38:28 -0800 | [diff] [blame] | 84 | compile_repos "mso" |
Idan Amit | 1690e08 | 2017-08-20 08:58:14 +0300 | [diff] [blame] | 85 | fi |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 86 | fi |
| 87 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 88 | if [[ "$skip_get_images" == "False" ]]; then |
| 89 | get_mso_images |
| 90 | if [[ "$skip_install" == "False" ]]; then |
| 91 | install_mso |
| 92 | fi |
| 93 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 94 | } |