14
14
15
15
from keystoneauth1 import exceptions as ka_exceptions
16
16
from keystoneauth1 import loading as ka_loading
17
+ from keystoneclient .v3 import client as ks_client
17
18
from oslo_config import cfg
18
19
from oslo_log import log as logging
19
20
@@ -31,17 +32,17 @@ def __init__(self, user_plugin, user_project, user_roles):
31
32
# step 1: create trust to ensure that we can always update token
32
33
33
34
# trustor = user who made the request
34
- trustor_client = self ._load_session (user_plugin )
35
- trustor_id = trustor_client .get_user_id ()
35
+ trustor_client = self ._load_client (user_plugin )
36
+ trustor_id = trustor_client .session . get_user_id ()
36
37
37
38
# get trustee user client that impersonates main user
38
39
trustee_user_auth = ka_loading .load_auth_from_conf_options (
39
40
CONF , 'keystone_authtoken' )
40
41
# save service user client because we need new service token
41
42
# to refresh trust-scoped client later
42
- self .trustee_user_client = self ._load_session (trustee_user_auth )
43
+ self .trustee_user_client = self ._load_client (trustee_user_auth )
43
44
44
- trustee_id = self .trustee_user_client .get_user_id ()
45
+ trustee_id = self .trustee_user_client .session . get_user_id ()
45
46
46
47
self .trust_id = trustor_client .trusts .create (trustor_user = trustor_id ,
47
48
trustee_user = trustee_id ,
@@ -63,12 +64,12 @@ def refresh_token(self):
63
64
if self .trustee_client is None :
64
65
self .trustee_client = self ._refresh_trustee_client ()
65
66
try :
66
- return self .trustee_client .get_token ()
67
+ return self .trustee_client .session . get_token ()
67
68
except ka_exceptions .Unauthorized :
68
69
# in case of Unauthorized exceptions try to refresh client because
69
70
# service user token may expired
70
71
self .trustee_client = self ._refresh_trustee_client ()
71
- return self .trustee_client .get_token ()
72
+ return self .trustee_client .session . get_token ()
72
73
73
74
def release_resources (self ):
74
75
"""Release keystone resources required for refreshing"""
@@ -98,11 +99,11 @@ def _refresh_trustee_client(self):
98
99
trustee_auth = ka_loading .load_auth_from_conf_options (
99
100
CONF , 'keystone_authtoken' , ** kwargs )
100
101
101
- return self ._load_session (trustee_auth )
102
+ return self ._load_client (trustee_auth )
102
103
103
104
@staticmethod
104
- def _load_session (plugin ):
105
- # load ksa session from auth settings and user plugin
105
+ def _load_client (plugin ):
106
+ # load client from auth settings and user plugin
106
107
sess = ka_loading .load_session_from_conf_options (
107
108
CONF , 'keystone_authtoken' , auth = plugin )
108
- return sess
109
+ return ks_client . Client ( session = sess )
0 commit comments