Avoid keystoneclient making yet another discovery call
Even with an endpoint_override set, keystoneclient will make one discovery call if the keystoneclient.client.Client constructor is used. Because we're not going to make that extra discovery call after we've already made a discovery call when we do ksa calls, directly instantiate the v2 or v3 objects ourselves. This lets us avoid the extra discovery call so that we can remove it from our test fixtures. The discovery call sequence now should be identical for ksa vs. ksc. There is still an inefficiency here due to our discovery not using ksa discovery. But we can optimize that later. Change-Id: If7f8625745f80334b9a78d742dc4a9250a4eb72c
This commit is contained in:
parent
96c24b1108
commit
5a1a3d813b
@ -92,8 +92,23 @@ class LegacyClientFactoryMixin(object):
|
||||
def keystone_client(self):
|
||||
# Trigger discovery from ksa
|
||||
self._identity_client
|
||||
|
||||
# Skip broken discovery in ksc. We're good thanks.
|
||||
from keystoneclient.v2_0 import client as v2_client
|
||||
from keystoneclient.v3 import client as v3_client
|
||||
if self.cloud_config.config['identity_api_version'] == '3':
|
||||
client_class = v3_client
|
||||
else:
|
||||
client_class = v2_client
|
||||
|
||||
return self._create_legacy_client(
|
||||
'keystone', 'identity', deprecated=False)
|
||||
'keystone', 'identity',
|
||||
client_class=client_class.Client,
|
||||
deprecated=False,
|
||||
endpoint=self.cloud_config.config[
|
||||
'identity_endpoint_override'],
|
||||
endpoint_override=self.cloud_config.config[
|
||||
'identity_endpoint_override'])
|
||||
|
||||
# Set the ironic API microversion to a known-good
|
||||
# supported/tested with the contents of shade.
|
||||
|
@ -419,7 +419,7 @@ class OpenStackCloud(
|
||||
identity_client.endpoint_override = identity_url
|
||||
self.cloud_config.config['identity_endpoint_override'] = \
|
||||
identity_url
|
||||
self._raw_clients['identity'] = self._get_raw_client('identity')
|
||||
self._raw_clients['identity'] = identity_client
|
||||
return self._raw_clients['identity']
|
||||
|
||||
@property
|
||||
|
@ -429,8 +429,6 @@ class RequestsMockTestCase(BaseTestCase):
|
||||
text=open(os.path.join(
|
||||
self.fixtures_directory, 'catalog-v2.json'), 'r').read()
|
||||
),
|
||||
dict(method='GET', uri='https://identity.example.com/v2.0',
|
||||
text=open(self.discovery_json, 'r').read()),
|
||||
])
|
||||
|
||||
self._make_test_cloud(cloud_name='_test_cloud_v2_',
|
||||
@ -445,8 +443,6 @@ class RequestsMockTestCase(BaseTestCase):
|
||||
self.__do_register_uris([
|
||||
dict(method='GET', uri='https://identity.example.com/',
|
||||
text=open(self.discovery_json, 'r').read()),
|
||||
dict(method='GET', uri='https://identity.example.com/v3/',
|
||||
text=open(self.discovery_json, 'r').read()),
|
||||
])
|
||||
|
||||
def _make_test_cloud(self, cloud_name='_test_cloud_', **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user