Support region_name option during connection
Attempt to determine the correct regions before making the initial connection to OpenStack to ensure that the proper endpoints are selected from the service catalog in a multi-region deployment. Without this change, the endpoint selected from the service catalog is based solely on the service type with no regard for region. This may lead to the wrong endpoint being selected from the catalog. Change-Id: Ie396b8239df080dcc225dd77204e5f3980cca2a6
This commit is contained in:
@@ -31,6 +31,12 @@ from masakaridashboard.handle_errors import handle_errors
|
||||
@memoized.memoized
|
||||
def openstack_connection(request, version=None):
|
||||
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'publicURL')
|
||||
region_name = request.COOKIES.get('services_region')
|
||||
if not region_name:
|
||||
default_service_regions = getattr(settings,
|
||||
'DEFAULT_SERVICE_REGIONS',
|
||||
{})
|
||||
region_name = default_service_regions.get('*')
|
||||
|
||||
auth = token.Token(
|
||||
auth_url=request.user.endpoint,
|
||||
@@ -41,6 +47,7 @@ def openstack_connection(request, version=None):
|
||||
session = ks_session.Session(auth=auth, verify=cacert or True)
|
||||
conn = connection.Connection(session=session,
|
||||
interface=interface,
|
||||
region_name=region_name,
|
||||
ha_api_version=version)
|
||||
|
||||
return conn.instance_ha
|
||||
|
Reference in New Issue
Block a user