-
Notifications
You must be signed in to change notification settings - Fork 5
/
admin-openrc
32 lines (27 loc) · 1.14 KB
/
admin-openrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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