Exemple #1
0
def collect_vo_ldap(active_users):
    """Determine which active users are in the same VO.

    @type active_users: list of strings

    @param active_users: the users for which there currently are jobs running

    Generates a mapping between each user that belongs to a VO for which a member has jobs running and the active users
    from that VO. If the user belongs to the default VO, he cannot see any information of the other users from this VO.

    @return: dict with vo IDs as keys (default VO members are their own VO) and dicts mapping uid to gecos as values.
    """
    LdapQuery(VscConfiguration())
    ldap_filter = (
        InstituteFilter("antwerpen") | InstituteFilter("brussel") | InstituteFilter("gent") | InstituteFilter("leuven")
    )

    vos = [g for g in VscLdapGroup.lookup(ldap_filter) if g.group_id.startswith("gvo")]
    members = dict([(u.user_id, u) for u in VscLdapUser.lookup(ldap_filter)])
    user_to_vo_map = dict([(u, vo) for vo in vos for u in vo.memberUid])

    user_maps_per_vo = {}
    found = set()
    for user in active_users:

        # If we already have a mapping for this user, we need not add him again
        if user in found:
            continue

        # find VO of this user
        vo = user_to_vo_map.get(user, None)
        if vo:
            if vo.group_id == DEFAULT_VO:
                logger.debug("user %s belongs to the default vo %s" % (user, vo.group_id))
                found.add(user)
                name = members[user].gecos
                user_maps_per_vo[user] = {user: name}
            else:
                user_map = dict([(uid, members[uid].gecos) for uid in vo.memberUid and uid in active_users])
                for uid in user_map:
                    found.add(uid)
                user_maps_per_vo[vo.group_id] = user_map
                logger.debug("added userMap for the vo %s" % (vo.group_id))
        # ignore users not in any VO (including default VO)

    return (found, user_maps_per_vo)
def get_user_with_status(status):
    """Get the users from the HPC LDAP that match the given status.

    @type ldap: vsc.ldap.utils.LdapQuery instance
    @type status: string represeting a valid status in the HPC LDAP

    @returns: list of VscLdapUser nametuples of matching users.
    """
    logger.info("Retrieving users from the HPC LDAP with status=%s." % (status))

    ldap_filter = LdapFilter("status=%s" % (status))
    users = VscLdapUser.lookup(ldap_filter)

    logger.info("Found %d users in the %s state." % (len(users), status))
    logger.debug("The following users are in the %s state: %s" % (status, [u.user_id for u in users]))

    return users
Exemple #3
0
def get_user_with_status(status):
    """Get the users from the HPC LDAP that match the given status.

    @type ldap: vsc.ldap.utils.LdapQuery instance
    @type status: string represeting a valid status in the HPC LDAP

    @returns: list of VscLdapUser nametuples of matching users.
    """
    logger.info("Retrieving users from the HPC LDAP with status=%s." %
                (status))

    ldap_filter = LdapFilter("status=%s" % (status))
    users = VscLdapUser.lookup(ldap_filter)

    logger.info("Found %d users in the %s state." % (len(users), status))
    logger.debug("The following users are in the %s state: %s" %
                 (status, [u.user_id for u in users]))

    return users