#!/bin/bash

log_info "Load envrionment variables config"

log_info "[common] RUNENV=${RUNENV}"
log_info "[common] PRODUCTION=${PRODUCTION}"
log_info "[common] DEPLOY_MODE=${DEPLOY_MODE}"
log_info "[common] REGION=${REGION}"
log_info "[common] SSL=${SSL}"
log_info "[common] DOMAIN_NAME=${DOMAIN_NAME}"
log_info "[common] SERVICE_PORT=${NODE_PORT}"
log_info "[common] STORAGE_MODE=${STORAGE_MODE}"

for ip in ${IP_LIST[@]}; do
    HOST_ROLE=$(get_node_attribute ${REGION} ${ip} labels)
    SWARM_ROLE=$(get_node_attribute ${REGION} ${ip} role)
    log_info "[${REGION}] IP: ${ip}, SWARM_ROLE: ${SWARM_ROLE} HOST_ROLE: ${HOST_ROLE}"
done

if [ "${REGION}"x == "subregion"x ]; then
    log_info "[subregionconf] REGIONNAME=${REGIONNAME}"
    log_info "[subregionconf] PRIMARYURL=${PRIMARYURL}"
    log_info "[subregionconf] REGISTERCODE=${REGISTERCODE}"
    log_info "[subregionconf] REGIONURL=${REGIONURL}"
    log_info "[subregionconf] INTRANETADDRESS=${INTRANETADDRESS}"
    log_info "[subregionconf] REGION_TSAP=${REGION_TSAP}"
fi

log_info "[docker] DOCKER0_NETWORK=${DOCKER0_NETWORK}"
log_info "[docker] DOCKER_GWBRIDGE_NETWORK=${DOCKER_GWBRIDGE_NETWORK}"
log_info "[docker] MACROWING_NETWORK=${MACROWING_NETWORK}"
log_info "[docker] DOCKER_DATA_ROOT=${DOCKER_DATA_ROOT}"

log_info "[middleware] MIDDLEWARE_MODE=${MIDDLEWARE_MODE}"
log_info "[middleware] MIDDLEWARE_STANDALONE_HA=${MIDDLEWARE_STANDALONE_HA}"
log_info "[middleware] MIDDLEWARE_DATA_PATH=${MIDDLEWARE_DATA_PATH}"
log_info "[middleware] DBBACKUP_PATH=${DBBACKUP_PATH}"
log_info "[middleware] ES_JAVA_OPTS=${ES_JAVA_OPTS}"

if [ "${UsedDatabase}"x == "external" ]; then
    log_info "[database] UsedDatabase=${UsedDatabase}"
    log_info "[database] DatabaseType=${DatabaseType}"
    log_info "[database] DatabaseServerName=${DatabaseServerName}"
    log_info "[database] DatabaseUserName=${DatabaseUserName}"
    log_info "[database] DatabasePassword=${DatabasePassword}"
    log_info "[database] DatabaseServerPort=${DatabaseServerPort}"
    log_info "[database] DatabaseName=${DatabaseName}"
fi

if [ "${STORAGE_MODE}"x == "local"x -o "${SOTRAGE_MODE}"x == "nas"x ]; then
    log_info "[local] STORAGE_PATH=${DATA_PATH}"
elif [ "${STORAGE_MODE}"x == "oss"x -o "${STORAGE_MODE}"x == "s3"x ]; then
    log_info "[${STORAGE_MODE}] S3SECRET=${S3SECRET}"
    log_info "[${STORAGE_MODE}] S3URL=${S3URL}"
    log_info "[${STORAGE_MODE}] S3ACCESS=${S3ACCESS}"
    log_info "[${STORAGE_MODE}] S3BUCKET=${S3BUCKET}"
elif [ "${STORAGE_MODE}"x == "ceph"x ]; then
    log_info "[ceph] S3SECRET=${S3SECRET}"
    log_info "[ceph] S3URL=${S3URL}"
    log_info "[ceph] S3ACCESS=${S3ACCESS}"
    log_info "[ceph] S3BUCKET=${S3BUCKET}"
    log_info "[ceph] S3HealthUrl=${S3HealthUrl}"
elif [ "${STORAGE_MODE}"x == "swift"x ]; then
    log_info "[swift] S3SECRET=${S3SECRET}"
    log_info "[swift] S3URL=${S3URL}"
    log_info "[swift] S3ACCESS=${S3ACCESS}"
    log_info "[swift] S3BUCKET=${S3BUCKET}"
    log_info "[swift] S3HealthUrl=${S3HealthUrl}"
    log_info "[swift] SWIFTUSERNAME=${SWIFTUSERNAME}"
    log_info "[swift] CONTAINERID=${CONTAINERID}"
fi

log_info "[All Host] ${IP_LIST[@]}"
