# Unset any previous variables unset $(printenv | awk 'BEGIN{FS="=";} /^OS_/ {print $1;}') keystone_addr=$(juju config keystone vip) if [ -z "$keystone_addr" ]; then keystone_addr=$(juju run --unit keystone/0 unit-get private-address) fi ssl_cert=$(juju config keystone ssl_cert) if [ -n "$ssl_cert" ]; then export OS_AUTH_PROTOCOL=https fi export OS_USERNAME=admin export OS_PASSWORD=$(juju run --unit keystone/0 leader-get admin_passwd) export OS_PROJECT_NAME=admin export OS_REGION_NAME=RegionOne api_ver="$(juju config keystone preferred-api-version)" rel="$(juju config keystone openstack-origin| sed -r 's/.+-(.+)/\1/g')" rel="$(echo -e "$rel\nqueens"| sort | head -n 1)" series=$(juju status keystone --format=json | jq -r '.machines[].series') if [ "$api_ver" = "3" ] || [[ "${rel%%/*}" > "pike" ]] || \ { [[ "$series" > "artful" ]] && [[ "$series" < "trusty" ]]; }; then export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://${keystone_addr}:5000/v3 export OS_PROJECT_DOMAIN_NAME=admin_domain export OS_USER_DOMAIN_NAME=admin_domain export OS_IDENTITY_API_VERSION=3 else export OS_AUTH_URL=${OS_AUTH_PROTOCOL:-http}://${keystone_addr}:5000/v2.0 fi