#NEWLINE# def _get_chain_admin_context( self , plugin_context , tenant_id = None , provider_tenant_id = None , instance_id = None ) : #NEWLINE# #INDENT# ctx = plugin_context . elevated ( ) #NEWLINE# ctx . tenant_id = None #NEWLINE# if instance_id : #NEWLINE# #INDENT# cmap = self . _get_ptg_servicechain_mapping ( ctx . session , servicechain_instance_id = instance_id ) #NEWLINE# if cmap : #NEWLINE# #INDENT# ctx . tenant_id = cmap [ 0 ] . tenant_id #NEWLINE# #UNINDENT# #UNINDENT# if ( not ctx . tenant_id ) : #NEWLINE# #INDENT# ctx . tenant_id = ( tenant_id or self . chain_owner or provider_tenant_id ) #NEWLINE# #UNINDENT# if ( cmap . chain_owner == ctx . tenant_id ) : #NEWLINE# #INDENT# ctx . auth_token = self . chain_tenant_keystone_client ( ) . get_token ( self . chain_owner ) #NEWLINE# #UNINDENT# return ctx