Add OPENSTACK_ENDPOINT_TYPE to the connection

Pass interface to honor 'OPENSTACK_ENDPOINT_TYPE' so it can have multiple endpoints,
without this it only communicate with the public endpoint.

Closes-Bug: #1891230
Change-Id: I7caf9170d63eff388af5d690dd6b054188752381
This commit is contained in:
Michiel Piscaer 2020-08-12 15:05:17 +02:00
parent 567e3aed9b
commit 1dde9dc923
1 changed files with 3 additions and 0 deletions

View File

@ -34,6 +34,8 @@ MICROVERSION_FEATURES = {"recovery_workflow_details": ["1.1"]}
@memoized.memoized
def openstack_connection(request, version=None):
interface = getattr(settings, 'OPENSTACK_ENDPOINT_TYPE', 'publicURL')
auth = token.Token(
auth_url=getattr(settings, 'OPENSTACK_KEYSTONE_URL'),
token=request.user.token.id,
@ -41,6 +43,7 @@ def openstack_connection(request, version=None):
project_id=request.user.tenant_id)
session = ks_session.Session(auth=auth)
conn = connection.Connection(session=session,
interface=interface,
ha_api_version=version)
return conn.instance_ha