#NEWLINE# def take_action( self , parsed_args ) : #NEWLINE# #INDENT# identity_client = self . app . client_manager . identity #NEWLINE# role = None #NEWLINE# if parsed_args . role : #NEWLINE# #INDENT# role = utils . find_resource ( identity_client . roles , parsed_args . role ) #NEWLINE# #UNINDENT# user = None #NEWLINE# if parsed_args . user : #NEWLINE# #INDENT# user = common . find_user ( identity_client , parsed_args . user , parsed_args . user_domain ) #NEWLINE# #UNINDENT# domain = None #NEWLINE# if parsed_args . domain : #NEWLINE# #INDENT# domain = common . find_domain ( identity_client , parsed_args . domain ) #NEWLINE# #UNINDENT# project = None #NEWLINE# if parsed_args . project : #NEWLINE# #INDENT# project = common . find_project ( identity_client , parsed_args . project , parsed_args . project_domain ) #NEWLINE# #UNINDENT# group = None #NEWLINE# if parsed_args . group : #NEWLINE# #INDENT# group = common . find_group ( identity_client , parsed_args . group , parsed_args . group_domain ) #NEWLINE# #UNINDENT# include_names = ( True if parsed_args . names else False ) #NEWLINE# effective = ( True if parsed_args . effective else False ) #NEWLINE# columns = ( 'Role' , 'User' , 'Group' , 'Project' , 'Domain' , 'Inherited' ) #NEWLINE# inherited_to = ( 'projects' if parsed_args . inherited else None ) #NEWLINE# data = identity_client . role_assignments . list ( domain = domain , user = user , group = group , project = project , role = role , effective = effective , os_inherit_extension_inherited_to = inherited_to , include_names = include_names ) #NEWLINE# data_parsed = [ ] #NEWLINE# for assignment in data : #NEWLINE# #INDENT# scope = assignment . scope #NEWLINE# if ( 'project' in scope ) : #NEWLINE# #INDENT# if include_names : #NEWLINE# #INDENT# prj = '@' . join ( [ scope [ 'project' ] [ 'name' ] , scope [ 'project' ] [ 'domain' ] [ 'name' ] ] ) #NEWLINE# setattr ( assignment , 'project' , prj ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( assignment , 'project' , scope [ 'project' ] [ 'id' ] ) #NEWLINE# #UNINDENT# assignment . domain = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'domain' in scope ) : #NEWLINE# #INDENT# if include_names : #NEWLINE# #INDENT# setattr ( assignment , 'domain' , scope [ 'domain' ] [ 'name' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( assignment , 'domain' , scope [ 'domain' ] [ 'id' ] ) #NEWLINE# #UNINDENT# assignment . project = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assignment . domain = '' #NEWLINE# assignment . project = '' #NEWLINE# #UNINDENT# #UNINDENT# inherited = ( scope . get ( 'OS-INHERIT:inherited_to' ) == 'projects' ) #NEWLINE# assignment . inherited = inherited #NEWLINE# del assignment . scope #NEWLINE# if hasattr ( assignment , 'user' ) : #NEWLINE# #INDENT# if include_names : #NEWLINE# #INDENT# usr = '@' . join ( [ assignment . user [ 'name' ] , assignment . user [ 'domain' ] [ 'name' ] ] ) #NEWLINE# setattr ( assignment , 'user' , usr ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( assignment , 'user' , assignment . user [ 'id' ] ) #NEWLINE# #UNINDENT# assignment . group = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if hasattr ( assignment , 'group' ) : #NEWLINE# #INDENT# if include_names : #NEWLINE# #INDENT# grp = '@' . join ( [ assignment . group [ 'name' ] , project . group [ 'domain' ] [ 'name' ] ] ) #NEWLINE# setattr ( assignment , 'group' , grp ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( assignment , 'group' , assignment . group [ 'id' ] ) #NEWLINE# #UNINDENT# assignment . user = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assignment . user = '' #NEWLINE# assignment . group = '' #NEWLINE# #UNINDENT# #UNINDENT# if hasattr ( assignment , 'role' ) : #NEWLINE# #INDENT# if include_names : #NEWLINE# #INDENT# setattr ( assignment , 'role' , assignment . role [ 'name' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setattr ( assignment , 'role' , assignment . role [ 'id' ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# assignment . role = '' #NEWLINE# #UNINDENT# data_parsed . append ( self . _as_tuple ( assignment ) ) #NEWLINE# #UNINDENT# return ( columns , tuple ( data_parsed ) )