Beispiel #1
0
def show_info():
    """Handle 'mruser info'."""

    user = User(client, args.user)
    user.loadInfo()

    if user.middle_name:
        realname = "%s %s %s" % (user.first_name, user.middle_name, user.last_name)
    else:
        realname = "%s %s" % (user.first_name, user.last_name)

    common.section_header( "Information about user %s" % common.emph_text(user.name) )
    common.show_fields(
        ('Login name', user.name),
        ('Real name', realname),
        ('Status', format_user_status(user)),
        ('User ID', user.uid),
        ('MIT ID', user.mit_id),
        ('Class', user.user_class),
        ('Shell (Unix)', user.shell),
        ('Shell (Windows)', user.windows_shell),
        ('Comments', user.comments) if user.comments else None,
        ('Sponsor', str(user.sponsor) if user.sponsor else 'None'),
        ('Expires', user.expiration) if user.expiration else None,
        ('Alternate email', user.alternate_email) if user.alternate_email else None,
        ('Alternate phone', user.alternate_phone) if user.alternate_phone else None,
        ('Created', "%s by %s" % (common.last_modified_date(user.created_date), user.created_by)),
        ('Last modified', "%s by %s using %s" % (common.last_modified_date(user.lastmod_datetime), user.lastmod_by, user.lastmod_with)),
    )
Beispiel #2
0
def show_inverse():
    """Handle 'mrlist inverse'."""

    member = resolve_member(args.member, False)
    if not member:
        print "Impossible to determine the type of a member. Please specify it explicitly by prefixing the member with type, seperated by colon, like this: string:[email protected]"
        return

    memberships = list( member.getMemberships(recursive = args.recursive) )
    memberships.sort()
    common.section_header( "Memberships of %s" % common.emph_text( str(member) ) )
    for mlist in memberships:
        print "* %s" % mlist.name
Beispiel #3
0
def show_info():
    """Handle 'mrlist info'."""

    mlist = List(common.client, args.list)
    mlist.loadInfo()

    common.section_header("Information about list %s" % common.emph_text(mlist.name) )
    common.show_fields(
        ('Description', mlist.description),
        ('Active', mlist.active),
        ('Public', mlist.public),
        ('Visible', not mlist.hidden),
        ('Mailing list', mlist.is_mailing),
        ('AFS group', "GID #%s" % mlist.gid if mlist.is_afsgroup else mlist.is_afsgroup),
        ('Unix group', mlist.is_nfsgroup) if mlist.is_afsgroup else None,
        ('Mailman list', "On server %s" % mlist.mailman_server if mlist.is_mailman_list else mlist.is_mailman_list),
        ('Owner', str(mlist.owner) ),
        ('Membership ACL', str(mlist.memacl) if mlist.memacl else 'None' ),
        ('Last modified', "%s ago by %s using %s" % (common.last_modified_date(mlist.lastmod_datetime), mlist.lastmod_by, mlist.lastmod_with)),
    )
Beispiel #4
0
def show_ownerships(client, args, owner):
    owned = list(owner.getOwnedObjects(recursive = args.recursive))
    type_headers = (
        (pymoira.Container, 'Windows machine containers'),
        (pymoira.ContainerMembershipACL, 'Windows machine containers ACL'),
        (pymoira.Filesys, 'Lockers'),
        (pymoira.List, 'Lists'),
        (pymoira.Host, 'Machines'),
        (pymoira.Query, 'Queries'),
        (pymoira.Quota, 'Quotas'),
        (pymoira.Service, 'Service'),
        (pymoira.ZephyrClass, 'Zephyr classes'),
    )

    for object_type, header in type_headers:
        displayed = [obj for obj in owned if type(obj) == object_type]
        displayed.sort()
        if displayed:
            common.section_header(header)
            for member in displayed:
                print "* %s" % member.name
            print    # FIXME: this should not be done in case of last entry
Beispiel #5
0
def output_member_list(members, hook = None):
    """Output the list of list members."""
    
    members = list(members)
    members.sort()
    type_headers = (
        ('USER', 'Users'),
        ('KERBEROS', 'Kerberos principals'),
        ('LIST', 'Sublists'),
        ('STRING', 'String entries (includes non-MIT emails)'),
        ('MACHINE', 'Machines'),
    )
    for list_type, header in type_headers:
        displayed = [member for member in members if member.mtype == list_type]
        if displayed:
            common.section_header(header)
            for member in displayed:
                if hasattr(member, 'tag') and member.tag:
                    print "* %s [%s]" % (member.name, member.tag)
                else:
                    print "* %s" % member.name
                if hook:
                    hook(member)
            print    # FIXME: this should not be done in case of last entry