Ejemplo n.º 1
0
def _check_instance(args):
    (node, instances, instance_id) = args
    instance = [i for i in instances if i.name == instance_id][0]
    ip_addr = instance.public_ip[0]
    ssh_status = True  # _test_ssh(ip_addr)
    launch_date = parser.parse(instance.extra['launchdatetime']).utcnow()
    image_id = instance.extra['imageId']
    owner_id = instance.extra['ownerId']
    instance_info = {
        'ip': ip_addr,
        'ssh': ssh_status,
        'launch_date': launch_date,
        'image_id': image_id,
        'owner_id': owner_id,
        'instance_id': instance_id,
        'node_controller': node,
    }
    user = lookupUser(owner_id)
    if user:
        instance_info.update({
            'username': user['uid'],
            'email': user['mail'],
            'full_name': "%s %s" % (user['givenName'], user['sn'])
        })
    return instance_info
Ejemplo n.º 2
0
def _check_instance(args):
    (node, instances, instance_id) = args
    instance = [i for i in instances if i.name == instance_id][0]
    ip_addr = instance.public_ip[0]
    ssh_status = True  # _test_ssh(ip_addr)
    launch_date = parser.parse(instance.extra['launchdatetime']).utcnow()
    image_id = instance.extra['imageId']
    owner_id = instance.extra['ownerId']
    instance_info = {
        'ip': ip_addr,
        'ssh': ssh_status,
        'launch_date': launch_date,
        'image_id': image_id,
        'owner_id': owner_id,
        'instance_id': instance_id,
        'node_controller': node,
    }
    user = lookupUser(owner_id)
    if user:
        instance_info.update({
            'username':
            user['uid'],
            'email':
            user['mail'],
            'full_name':
            "%s %s" % (user['givenName'], user['sn'])
        })
    return instance_info
Ejemplo n.º 3
0
def user_email_info(username):
    logger.debug("user = %s" % username)
    ldap_attrs = lookupUser(username)
    user_email = ldap_attrs.get("mail", [None])[0]
    if not user_email:
        raise Exception("Could not locate email address for User:%s - Attrs: %s" % (username, ldap_attrs))
    user_name = ldap_attrs.get("cn", [""])[0]
    if not user_name:
        user_name = "%s %s" % (ldap_attrs.get("displayName", [""])[0], ldap_attrs.get("sn", [""])[0])
    if not user_name.strip(" "):
        user_name = username

    return (username, user_email, user_name)
Ejemplo n.º 4
0
def user_email_info(username):
    logger.debug("user = %s" % username)
    ldap_attrs = lookupUser(username)
    user_email = ldap_attrs.get('mail', [None])[0]
    if not user_email:
        raise Exception(
            "Could not locate email address for User:%s - Attrs: %s" %
            (username, ldap_attrs))
    user_name = ldap_attrs.get('cn', [""])[0]
    if not user_name:
        user_name = "%s %s" % (ldap_attrs.get(
            "displayName", [""])[0], ldap_attrs.get("sn", [""])[0])
    if not user_name.strip(' '):
        user_name = username

    return (username, user_email, user_name)
Ejemplo n.º 5
0
def ldap_get_email_info(username):
    """
    Use LDAP to query the e-mail, then
    Returns a 3-tuple of:
    ("username", "*****@*****.**", "My Name")
    """
    ldap_attrs = lookupUser(username)
    user_email = ldap_attrs.get('mail', [None])[0]
    if not user_email:
        raise Exception(
            "Could not locate email address for User:%s - Attrs: %s" %
            (username, ldap_attrs))
    user_name = ldap_attrs.get('cn', [""])[0]
    if not user_name:
        user_name = "%s %s" % (ldap_attrs.get("displayName", [""])[0],
                               ldap_attrs.get("sn", [""])[0])
    if not user_name.strip(' '):
        user_name = username
    return (username, user_email, user_name)