def get_default_role(request):
 global DEFAULT_ROLE
 default = getattr(settings, 'OPENSTACK_KEYSTONE_DEFAULT_ROLE', None)
 if (default and (DEFAULT_ROLE is None)):
  try:
   roles = keystoneclient(request, admin=True).roles.list()
  except Exception:
   roles = []
   exceptions.handle(request)
  for role in roles:
   if ((role.id == default) or (role.name == default)):
    DEFAULT_ROLE = role
    break
 return DEFAULT_ROLE

def get_default_role ( request ) : global DEFAULT_ROLE default = getattr ( settings , 'OPENSTACK_KEYSTONE_DEFAULT_ROLE' , None ) if ( default and ( DEFAULT_ROLE is None ) ) : try : roles = keystoneclient ( request , admin = True ) . roles . list ( ) except Exception : roles = [ ] exceptions . handle ( request ) for role in roles : if ( ( role . id == default ) or ( role . name == default ) ) : DEFAULT_ROLE = role break return DEFAULT_ROLE
gets the default role object from keystone and saves it as a global .