#NEWLINE# def _v3_client_init( self ) : #NEWLINE# #INDENT# kwargs = { #NEWLINE# #INDENT# 'auth_url' : self . endpoint , #NEWLINE# 'endpoint' : self . endpoint , #NEWLINE# #UNINDENT# } #NEWLINE# if ( self . context . trust_id is not None ) : #NEWLINE# #INDENT# kwargs . update ( self . _service_admin_creds ( ) ) #NEWLINE# kwargs [ 'trust_id' ] = self . context . trust_id #NEWLINE# kwargs . pop ( 'project_name' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . context . auth_token_info is not None ) : #NEWLINE# #INDENT# if ( 'access' in self . context . auth_token_info ) : #NEWLINE# #INDENT# kwargs [ 'auth_ref' ] = copy . deepcopy ( self . context . auth_token_info [ 'access' ] ) #NEWLINE# kwargs [ 'auth_ref' ] [ 'version' ] = 'v2.0' #NEWLINE# kwargs [ 'auth_ref' ] [ 'token' ] [ 'id' ] = self . context . auth_token #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'token' in self . context . auth_token_info ) : #NEWLINE# #INDENT# kwargs [ 'auth_ref' ] = copy . deepcopy ( self . context . auth_token_info [ 'token' ] ) #NEWLINE# kwargs [ 'auth_ref' ] [ 'version' ] = 'v3' #NEWLINE# kwargs [ 'auth_ref' ] [ 'auth_token' ] = self . context . auth_token #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . error ( 'Unknown version in auth_token_info' ) #NEWLINE# raise exception . AuthorizationFailure ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . context . auth_token is not None ) : #NEWLINE# #INDENT# kwargs [ 'token' ] = client . context . auth_token #NEWLINE# kwargs [ 'project_id' ] = self . context . tenant #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# LOG . error ( _ ( 'Keystone v3 API connection failed, no password trust or auth_token!' ) ) #NEWLINE# raise exception . AuthorizationFailure ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# client = kc_v3 . Client ( ** kwargs ) #NEWLINE# if ( 'auth_ref' not in kwargs ) : #NEWLINE# #INDENT# client . authenticate ( ) #NEWLINE# #UNINDENT# if ( 'trust_id' in kwargs ) : #NEWLINE# #INDENT# if ( not client . auth_ref . trust_scoped ) : #NEWLINE# #INDENT# LOG . error ( _ ( 'trust token re-scoping failed!' ) ) #NEWLINE# raise exception . AuthorizationFailure ( ) #NEWLINE# #UNINDENT# self . context . auth_token = client . auth_ref . auth_token #NEWLINE# self . context . auth_url = self . endpoint #NEWLINE# self . context . user = client . auth_ref . user_id #NEWLINE# self . context . tenant = client . auth_ref . project_id #NEWLINE# self . context . user_name = client . auth_ref . username #NEWLINE# #UNINDENT# return client