#!/bin/bash

set -o xtrace

source /var/onap/functions

src_folder=$git_src_folder/mso
mso_repos=("chef-repo" "docker-config" "libs" "mso-config")

# clone_all_mso_repos() - Function that clones MSO source repo.
function clone_all_mso_repos {
    clone_repo mso $src_folder

    for dirc in ${mso_repos[@]}; do
        clone_repo mso/$dirc $src_folder/$dirc
    done
}

# compile_all_mso_repos() - Function that compiles MSO source repo.
function compile_all_mso_repos {
    compile_src $src_folder

    for dirc in ${mso_repos[@]}; do
        compile_src $src_folder/$dirc
    done
}

# get_mso_images() - Function that retrieves or create MSO Docker images
function get_mso_images {
    if [[ "$build_image" == "True" ]]; then
        export GIT_NO_PROJECT=/opt/
        compile_src $src_folder
        build_docker_image $src_folder/packages/docker docker
    fi
}

# install_mso() - Install MSO Docker configuration project
function install_mso {
    MSO_ENCRYPTION_KEY=$(cat /opt/mso/docker-config/encryption.key)
    echo -n "$openstack_api_key" | openssl aes-128-ecb -e -K $MSO_ENCRYPTION_KEY -nosalt | xxd -c 256 -p > /opt/config/api_key.txt

    # Deployments in OpenStack require a keystone file
    if [ -e /opt/config/keystone.txt ]; then
        KEYSTONE_URL=$(cat /opt/config/keystone.txt)
        DCP_CLLI="DEFAULT_KEYSTONE"
        AUTH_TYPE="USERNAME_PASSWORD"
    else
        KEYSTONE_URL="https://identity.api.rackspacecloud.com/v2.0"
        DCP_CLLI="RAX_KEYSTONE"
        AUTH_TYPE="RACKSPACE_APIKEY"
    fi

    # Update the MSO configuration file.
    read -d '' MSO_CONFIG_UPDATES <<-EOF
{
"default_attributes":
    {
    "asdc-connections":
        {
            "asdc-controller1":
            {
                "environmentName": "$dmaap_topic"
            }
        },
        "mso-po-adapter-config":
        {
            "identity_services":
            [
                {
                    "dcp_clli": "$DCP_CLLI",
                    "identity_url": "$KEYSTONE_URL",
                    "mso_id": "$openstack_username",
                    "mso_pass": "$openstack_password",
                    "admin_tenant": "service",
                    "member_role": "admin",
                    "tenant_metadata": "true",
                    "identity_server_type": "KEYSTONE",
                    "identity_authentication_type": "$AUTH_TYPE"
                }
            ]
        }
    }
}
EOF
    export MSO_CONFIG_UPDATES
    export MSO_DOCKER_IMAGE_VERSION=$docker_version

    is_package_installed docker-ce || install_docker
    install_docker_compose
    # Deploy the environment
    pushd $src_folder/docker-config
    chmod +x deploy.sh
    if [[ "$build_image" == "True" ]]; then
        bash deploy.sh
    else
        # This script takes in input 2 nexus repos (the first one for the MSO image, the second one for mariadb)
        bash deploy.sh $nexus_docker_repo $nexus_username $nexus_password $nexus_docker_repo $nexus_username $nexus_password
    fi
    popd
}

# init_mso() - Function that initialize MSO services
function init_mso {
    if [[ "$clone_repo" == "True" ]]; then
        clone_all_mso_repos
        if [[ "$compile_repo" == "True" ]]; then
            compile_all_mso_repos
        fi
    fi

    if [[ "$skip_get_images" == "False" ]]; then
        get_mso_images
        if [[ "$skip_install" == "False" ]]; then
            install_mso
        fi
    fi
}
