Use consistent region during login
This change makes it so that the auth_url you have configured will be the primary region used during initial login. This will help make multi region keystone / horizon deployments more reliable and predictable. Also, it may perform better if horizon is configured to point to the nearest auth_url in multi region setups. Change-Id: I99d40ed580a25f3694fbbd8e54d0b6416907f31b Closes-bug: #1531003
This commit is contained in:
@@ -217,12 +217,24 @@ class KeystoneBackend(object):
|
|||||||
# Check expiry for our new scoped token.
|
# Check expiry for our new scoped token.
|
||||||
self.check_auth_expiry(scoped_auth_ref)
|
self.check_auth_expiry(scoped_auth_ref)
|
||||||
|
|
||||||
|
# We want to try to use the same region we just logged into
|
||||||
|
# which may or may not be the default depending upon the order
|
||||||
|
# keystone uses
|
||||||
|
region_name = None
|
||||||
|
id_endpoints = scoped_auth_ref.service_catalog.\
|
||||||
|
get_endpoints(service_type='identity')
|
||||||
|
for id_endpoint in [cat for cat in id_endpoints['identity']]:
|
||||||
|
if auth_url in id_endpoint.values():
|
||||||
|
region_name = id_endpoint['region']
|
||||||
|
break
|
||||||
|
|
||||||
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'public')
|
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'public')
|
||||||
|
|
||||||
endpoint = utils.fix_auth_url_version(
|
endpoint = utils.fix_auth_url_version(
|
||||||
scoped_auth_ref.service_catalog.url_for(
|
scoped_auth_ref.service_catalog.url_for(
|
||||||
service_type='identity',
|
service_type='identity',
|
||||||
interface=interface))
|
interface=interface,
|
||||||
|
region_name=region_name))
|
||||||
|
|
||||||
# If we made it here we succeeded. Create our User!
|
# If we made it here we succeeded. Create our User!
|
||||||
unscoped_token = unscoped_auth_ref.auth_token
|
unscoped_token = unscoped_auth_ref.auth_token
|
||||||
@@ -230,7 +242,8 @@ class KeystoneBackend(object):
|
|||||||
user = auth_user.create_user_from_token(
|
user = auth_user.create_user_from_token(
|
||||||
request,
|
request,
|
||||||
auth_user.Token(scoped_auth_ref, unscoped_token=unscoped_token),
|
auth_user.Token(scoped_auth_ref, unscoped_token=unscoped_token),
|
||||||
endpoint)
|
endpoint,
|
||||||
|
services_region=region_name)
|
||||||
|
|
||||||
if request is not None:
|
if request is not None:
|
||||||
request.session['unscoped_token'] = unscoped_token
|
request.session['unscoped_token'] = unscoped_token
|
||||||
|
|||||||
Reference in New Issue
Block a user