Support api-version when building client

Magnum service API is using micro versions and to get the correct
fuctions support, user or client have to initialize the correct
client with parameter 'api_version'. This patch is following the
same way as other OpenStack services to read the version from
OPENSTACK_API_VERSIONS of Horizon local_settings.py.

Change-Id: I85a3ed665dd6e5c9e9af933e0336d2be7998b928
This commit is contained in:
Feilong Wang 2018-09-25 14:37:22 +12:00 committed by Shu Muto
parent 3931063c35
commit 3a236a724e
1 changed files with 5 additions and 1 deletions

View File

@ -106,8 +106,9 @@ def _create_patches(old, new):
@memoized
def magnumclient(request):
magnum_url = ""
service_type = 'container-infra'
try:
magnum_url = base.url_for(request, 'container-infra')
magnum_url = base.url_for(request, service_type)
except exceptions.ServiceCatalogException:
LOG.debug('No Container Infrastructure Management service is '
'configured.')
@ -118,12 +119,15 @@ def magnumclient(request):
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
openstack_api_versions = getattr(settings, 'OPENSTACK_API_VERSIONS', {})
magnum_api_version = openstack_api_versions.get(service_type, 1.1)
c = magnum_client.Client(username=request.user.username,
project_id=request.user.tenant_id,
input_auth_token=request.user.token.id,
magnum_url=magnum_url,
insecure=insecure,
api_version=magnum_api_version,
cacert=cacert)
return c