@@ -99,17 +99,19 @@ def list_domains(self, session, auth_plugin, auth_ref=None):
9999 msg = _ ('Unable to retrieve authorized domains.' )
100100 raise exceptions .KeystoneRetrieveDomainsException (msg )
101101
102- def get_access_info (self , keystone_auth ):
102+ def get_access_info (self , keystone_auth , session = None ):
103103 """Get the access info from an unscoped auth
104104
105105 This function provides the base functionality that the
106106 plugins will use to authenticate and get the access info object.
107107
108108 :param keystone_auth: keystoneauth1 identity plugin
109+ :param session: keystoneauth1 session to use otherwise gets one
109110 :raises: exceptions.KeystoneAuthException on auth failure
110111 :returns: keystoneclient.access.AccessInfo
111112 """
112- session = utils .get_session ()
113+ if session is None :
114+ session = utils .get_session ()
113115
114116 try :
115117 unscoped_auth_ref = keystone_auth .get_access (session )
@@ -140,7 +142,7 @@ def get_access_info(self, keystone_auth):
140142 return unscoped_auth_ref
141143
142144 def get_project_scoped_auth (self , unscoped_auth , unscoped_auth_ref ,
143- recent_project = None ):
145+ recent_project = None , session = None ):
144146 """Get the project scoped keystone auth and access info
145147
146148 This function returns a project scoped keystone token plugin
@@ -149,10 +151,13 @@ def get_project_scoped_auth(self, unscoped_auth, unscoped_auth_ref,
149151 :param unscoped_auth: keystone auth plugin
150152 :param unscoped_auth_ref: keystoneclient.access.AccessInfo` or None.
151153 :param recent_project: project that we should try to scope to
154+ :param session: keystoneauth1 session to use otherwise gets one
152155 :return: keystone token auth plugin, AccessInfo object
153156 """
157+ if session is None :
158+ session = utils .get_session ()
159+
154160 auth_url = unscoped_auth .auth_url
155- session = utils .get_session ()
156161
157162 projects = self .list_projects (
158163 session , unscoped_auth , unscoped_auth_ref )
@@ -187,7 +192,7 @@ def get_project_scoped_auth(self, unscoped_auth, unscoped_auth_ref,
187192 return scoped_auth , scoped_auth_ref
188193
189194 def get_domain_scoped_auth (self , unscoped_auth , unscoped_auth_ref ,
190- domain_name = None ):
195+ domain_name = None , session = None ):
191196 """Get the domain scoped keystone auth and access info
192197
193198 This function returns a domain scoped keystone token plugin
@@ -196,9 +201,12 @@ def get_domain_scoped_auth(self, unscoped_auth, unscoped_auth_ref,
196201 :param unscoped_auth: keystone auth plugin
197202 :param unscoped_auth_ref: keystoneclient.access.AccessInfo` or None.
198203 :param domain_name: domain that we should try to scope to
204+ :param session: keystoneauth1 session to use otherwise gets one
199205 :return: keystone token auth plugin, AccessInfo object
200206 """
201- session = utils .get_session ()
207+ if session is None :
208+ session = utils .get_session ()
209+
202210 auth_url = unscoped_auth .auth_url
203211
204212 if domain_name :
@@ -235,7 +243,7 @@ def get_domain_scoped_auth(self, unscoped_auth, unscoped_auth_ref,
235243 return domain_auth , domain_auth_ref
236244
237245 def get_system_scoped_auth (self , unscoped_auth , unscoped_auth_ref ,
238- system_scope ):
246+ system_scope , session = None ):
239247 """Get the system scoped keystone auth and access info
240248
241249 This function returns a system scoped keystone token plugin
@@ -244,9 +252,12 @@ def get_system_scoped_auth(self, unscoped_auth, unscoped_auth_ref,
244252 :param unscoped_auth: keystone auth plugin
245253 :param unscoped_auth_ref: keystoneclient.access.AccessInfo` or None.
246254 :param system_scope: system that we should try to scope to
255+ :param session: keystoneauth1 session to use otherwise gets one
247256 :return: keystone token auth plugin, AccessInfo object
248257 """
249- session = utils .get_session ()
258+ if session is None :
259+ session = utils .get_session ()
260+
250261 auth_url = unscoped_auth .auth_url
251262
252263 system_auth = None
0 commit comments