Add version removal rule to stop discovery warning
Cinder recently added version discovery leveraging Keystone Client. For cases where the service catalog still contains version numbers, this can result in Keystone attempting to do discovery at the base url with the version number and giving warnings. This will set a version removal rule so Keystone can find the correct base url. Change-Id: I71432468fea8bf1e50f180ab7f6dd69ee9aaa7e6 Closes-Bug: #1448244
This commit is contained in:
parent
c82723660d
commit
4ea65b4409
cinderclient
@ -21,10 +21,12 @@ OpenStack Client interface. Handles the REST calls and responses.
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
from keystoneclient import adapter
|
from keystoneclient import adapter
|
||||||
from keystoneclient.auth.identity import base
|
from keystoneclient.auth.identity import base
|
||||||
|
from keystoneclient import discover
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from cinderclient import exceptions
|
from cinderclient import exceptions
|
||||||
@ -57,6 +59,12 @@ if not hasattr(urlparse, 'parse_qsl'):
|
|||||||
_VALID_VERSIONS = ['v1', 'v2']
|
_VALID_VERSIONS = ['v1', 'v2']
|
||||||
|
|
||||||
|
|
||||||
|
# tell keystoneclient that we can ignore the /v1|v2/{project_id} component of
|
||||||
|
# the service catalog when doing discovery lookups
|
||||||
|
for svc in ('volume', 'volumev2'):
|
||||||
|
discover.add_catalog_discover_hack(svc, re.compile('/v[12]/\w+/?$'), '/')
|
||||||
|
|
||||||
|
|
||||||
def get_volume_api_from_url(url):
|
def get_volume_api_from_url(url):
|
||||||
scheme, netloc, path, query, frag = urlparse.urlsplit(url)
|
scheme, netloc, path, query, frag = urlparse.urlsplit(url)
|
||||||
components = path.split("/")
|
components = path.split("/")
|
||||||
|
@ -127,7 +127,7 @@ class ShellTest(utils.TestCase):
|
|||||||
in the tenant_id for mocking purposes.
|
in the tenant_id for mocking purposes.
|
||||||
"""
|
"""
|
||||||
token = keystone_client_fixture.V2Token()
|
token = keystone_client_fixture.V2Token()
|
||||||
cinder_url = 'http://127.0.0.1:8776/v1/%s' % fixture_base.TENANT_ID
|
cinder_url = 'http://127.0.0.1:8776/'
|
||||||
|
|
||||||
volume_service = token.add_service('volume', 'Cinder v1')
|
volume_service = token.add_service('volume', 'Cinder v1')
|
||||||
volume_service.add_endpoint(public=cinder_url, region='RegionOne')
|
volume_service.add_endpoint(public=cinder_url, region='RegionOne')
|
||||||
@ -153,7 +153,7 @@ class ShellTest(utils.TestCase):
|
|||||||
in the tenant_id for mocking purposes.
|
in the tenant_id for mocking purposes.
|
||||||
"""
|
"""
|
||||||
token = keystone_client_fixture.V2Token()
|
token = keystone_client_fixture.V2Token()
|
||||||
cinder_url = 'http://127.0.0.1:8776/v1/%s' % fixture_base.TENANT_ID
|
cinder_url = 'http://127.0.0.1:8776/'
|
||||||
|
|
||||||
volume_service = token.add_service('volume', 'Cinder v1')
|
volume_service = token.add_service('volume', 'Cinder v1')
|
||||||
volume_service.add_endpoint(
|
volume_service.add_endpoint(
|
||||||
@ -182,7 +182,7 @@ class ShellTest(utils.TestCase):
|
|||||||
in the tenant_id for mocking purposes.
|
in the tenant_id for mocking purposes.
|
||||||
"""
|
"""
|
||||||
token = keystone_client_fixture.V2Token()
|
token = keystone_client_fixture.V2Token()
|
||||||
cinder_url = 'http://127.0.0.1:8776/v2/%s' % fixture_base.TENANT_ID
|
cinder_url = 'http://127.0.0.1:8776/'
|
||||||
|
|
||||||
volumev2_service = token.add_service('volumev2', 'Cinder v2')
|
volumev2_service = token.add_service('volumev2', 'Cinder v2')
|
||||||
volumev2_service.add_endpoint(
|
volumev2_service.add_endpoint(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user