Support keystone v3 authentification
modify sahara-client to work correctly with latest keystone v3 authentication. Change-Id: If119d184d90636327f88cad77c793b99ac6ba58a
This commit is contained in:
parent
acba4b2a41
commit
f99bcca1c1
|
@ -31,7 +31,7 @@ SAHARA_GROUP = 'sahara'
|
|||
|
||||
sahara_opts = [
|
||||
cfg.StrOpt('auth_url',
|
||||
default='http://localhost:5000/v2.0',
|
||||
default='http://localhost/identity/v3',
|
||||
help='Identity service URL.',
|
||||
deprecated_group='DEFAULT')
|
||||
]
|
||||
|
@ -53,11 +53,17 @@ def saharaclient(context):
|
|||
'token': context.auth_token,
|
||||
'tenant_id': context.tenant,
|
||||
}
|
||||
opts_for_v3 = {
|
||||
'auth_url': CONF.sahara.auth_url,
|
||||
'token': context.auth_token,
|
||||
'project_id': context.tenant,
|
||||
}
|
||||
AUTH_OBJ = client_auth.AuthClientLoader(
|
||||
client_class=sahara_client.Client,
|
||||
exception_module=sahara_exception,
|
||||
cfg_group=SAHARA_GROUP,
|
||||
deprecated_opts_for_v2=deprecated_opts_for_v2,
|
||||
opts_for_v3=opts_for_v3,
|
||||
url=CONF.sahara.auth_url,
|
||||
token=context.auth_token)
|
||||
return AUTH_OBJ.get_client(context)
|
||||
|
|
|
@ -17,6 +17,7 @@ import copy
|
|||
|
||||
from keystoneauth1 import loading as ks_loading
|
||||
from keystoneauth1.loading._plugins.identity import v2
|
||||
from keystoneauth1.loading._plugins.identity import v3
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
|
||||
|
@ -39,7 +40,8 @@ needed to load all needed parameters dynamically.
|
|||
class AuthClientLoader(object):
|
||||
|
||||
def __init__(self, client_class, exception_module, cfg_group,
|
||||
deprecated_opts_for_v2=None, url=None, token=None):
|
||||
deprecated_opts_for_v2=None, opts_for_v3=None,
|
||||
url=None, token=None):
|
||||
self.client_class = client_class
|
||||
self.exception_module = exception_module
|
||||
self.group = cfg_group
|
||||
|
@ -48,6 +50,7 @@ class AuthClientLoader(object):
|
|||
self.session = None
|
||||
self.auth_plugin = None
|
||||
self.deprecated_opts_for_v2 = deprecated_opts_for_v2
|
||||
self.opts_for_v3 = opts_for_v3
|
||||
self.url = url
|
||||
self.token = token
|
||||
|
||||
|
@ -80,8 +83,12 @@ class AuthClientLoader(object):
|
|||
self.auth_plugin = ks_loading.load_auth_from_conf_options(
|
||||
CONF, self.group)
|
||||
|
||||
self.auth_plugin = v2.Token().load_from_options(
|
||||
**self.deprecated_opts_for_v2)
|
||||
if self.url.find('v2') > -1:
|
||||
self.auth_plugin = v2.Token().load_from_options(
|
||||
**self.deprecated_opts_for_v2)
|
||||
else:
|
||||
self.auth_plugin = v3.Token().load_from_options(
|
||||
**self.opts_for_v3)
|
||||
|
||||
if self.auth_plugin:
|
||||
return self.auth_plugin
|
||||
|
|
Loading…
Reference in New Issue