#NEWLINE# def get_default_role( request ) : #NEWLINE# #INDENT# '\n    Gets the default role object from Keystone and saves it as a global\n    since this is configured in settings and should not change from request\n    to request. Supports lookup by name or id.\n    ' #NEWLINE# global DEFAULT_ROLE #NEWLINE# default = getattr ( settings , 'OPENSTACK_KEYSTONE_DEFAULT_ROLE' , None ) #NEWLINE# if ( default and ( DEFAULT_ROLE is None ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# roles = keystoneclient ( request , admin = True ) . roles . list ( ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# roles = [ ] #NEWLINE# exceptions . handle ( request ) #NEWLINE# #UNINDENT# for role in roles : #NEWLINE# #INDENT# if ( ( role . id == default ) or ( role . name == default ) ) : #NEWLINE# #INDENT# DEFAULT_ROLE = role #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return DEFAULT_ROLE