def user_has_role(user_db, role):
 assert isinstance(role, six.string_types)
 if (not cfg.CONF.rbac.enable):
  return True
 user_role_dbs = rbac_services.get_roles_for_user(user_db=user_db)
 user_role_names = [role_db.name for role_db in user_role_dbs]
 return (role in user_role_names)

def user_has_role ( user_db , role ) : assert isinstance ( role , six . string_types ) if ( not cfg . CONF . rbac . enable ) : return True user_role_dbs = rbac_services . get_roles_for_user ( user_db = user_db ) user_role_names = [ role_db . name for role_db in user_role_dbs ] return ( role in user_role_names )
check whether this user has access to this role .