Select AuthProvider type from credentials type
auth_version is used to get defaul credentials as well as to select the AuthProvider class. If credentials of an API version different from the configured one are used, a mismatch happens. Instantiating the AuthProvider class that corresponds to the version of API represented by the credentials object. Closes-Bug: #1369557 Change-Id: I1ed6da90ce0abed805cf39190cb1ac3baa3f63b6
This commit is contained in:
parent
905d3c9f67
commit
1781188e1a
|
@ -51,17 +51,17 @@ class Manager(object):
|
|||
self.client_attr_names = []
|
||||
|
||||
@classmethod
|
||||
def get_auth_provider_class(cls, auth_version):
|
||||
if auth_version == 'v2':
|
||||
return auth.KeystoneV2AuthProvider
|
||||
else:
|
||||
def get_auth_provider_class(cls, credentials):
|
||||
if isinstance(credentials, auth.KeystoneV3Credentials):
|
||||
return auth.KeystoneV3AuthProvider
|
||||
else:
|
||||
return auth.KeystoneV2AuthProvider
|
||||
|
||||
def get_auth_provider(self, credentials):
|
||||
if credentials is None:
|
||||
raise exceptions.InvalidCredentials(
|
||||
'Credentials must be specified')
|
||||
auth_provider_class = self.get_auth_provider_class(self.auth_version)
|
||||
auth_provider_class = self.get_auth_provider_class(credentials)
|
||||
return auth_provider_class(
|
||||
client_type=getattr(self, 'client_type', None),
|
||||
interface=getattr(self, 'interface', None),
|
||||
|
|
Loading…
Reference in New Issue