Exemplo n.º 1
0
    def main(conninfo, credentials, args):
        # Get the user object
        user_id = int(users.get_user_id(conninfo, credentials, args.id).data)

        response = users.list_user(conninfo, credentials, user_id)
        user_info, etag = response

        # Modify the user object according to specified arguments
        name = user_info['name']
        if args.name is not None:
            name = args.name

        primary_group = user_info['primary_group']
        if args.primary_group is not None:
            primary_group = str(
                groups.get_group_id(conninfo, credentials,
                                    args.primary_group).data)

        uid = user_info['uid']
        if args.uid is not None:
            uid = args.uid.strip()
            if uid.lower() == 'none':
                uid = ''

        home_directory = user_info['home_directory']
        if args.home_directory is not None:
            if args.home_directory.lower().strip() == "none":
                home_directory = None
            else:
                home_directory = args.home_directory

        # Set the user object, ignore output
        users.modify_user(conninfo, credentials, user_id, name, primary_group,
                          uid, home_directory, etag)

        # Add specified groups, ignore output
        if args.add_group:
            group_id = groups.get_group_id(conninfo, credentials,
                                           args.add_group)
            groups.group_add_member(conninfo, credentials, group_id.data,
                                    user_id)

        # Remove specified groups, ignore output
        if args.remove_group:
            group_id = groups.get_group_id(conninfo, credentials,
                                           args.remove_group)
            groups.group_remove_member(conninfo, credentials, group_id.data,
                                       user_id)

        # Get all related group info
        group_info_msg = get_user_group_info_msg(conninfo, credentials,
                                                 user_id)

        # Get all related IDs
        related_info_msg = get_expanded_identity_information_for_user(
            conninfo, credentials, user_id)

        print users.list_user(conninfo, credentials, user_id)
        print group_info_msg
        print related_info_msg
Exemplo n.º 2
0
    def main(conninfo, credentials, args):
        # Get the group object
        group_id = groups.get_group_id(conninfo, credentials, args.id)
        group_info, etag = groups.list_group(conninfo, credentials,
                                             group_id.data)

        # Modify the group object according to specified arguments
        name = group_info['name']
        if args.name is not None:
            name = args.name

        gid = group_info['gid']
        if args.gid is not None:
            gid = args.gid.strip()
            if gid.lower() == 'none':
                gid = ''

        # Set the group object, ignore output
        groups.modify_group(conninfo, credentials, group_id.data, name, gid,
                            etag)

        # Print out the new group object
        group_info_msg = get_group_members_msg(conninfo, credentials,
                                               group_id.data)

        related_info_msg = get_expanded_identity_information_for_group(
            conninfo, credentials, group_id.data)

        print group_info_msg
        print related_info_msg
Exemplo n.º 3
0
    def main(conninfo, credentials, args):
        group_id = int(
            groups.get_group_id(conninfo, credentials, args.id).data)

        group_info_msg = get_group_members_msg(conninfo, credentials, group_id)

        related_info_msg = get_expanded_identity_information_for_group(
            conninfo, credentials, group_id)

        print group_info_msg
        print related_info_msg
Exemplo n.º 4
0
    def main(conninfo, credentials, args):
        if args.password is True:
            password = qumulo.lib.opts.read_password(args.name)
        elif args.password is not None:
            password = args.password

        group_id = groups.get_group_id(conninfo, credentials,
                                       args.primary_group)

        res = users.add_user(conninfo, credentials, args.name, group_id.data,
                             args.uid, args.home_directory)

        # Set new user's password, ignoring output.
        if args.password is not None:
            user_id = int(res.lookup('id'))
            users.set_user_password(conninfo, credentials, user_id, password)

        # Get all related IDs
        related_info_msg = get_expanded_identity_information_for_user(
            conninfo, credentials, int(res.lookup('id')))

        print res
        print related_info_msg
Exemplo n.º 5
0
 def main(conninfo, credentials, args):
     group_id = groups.get_group_id(conninfo, credentials, args.id)
     groups.delete_group(conninfo, credentials, group_id.data)
     print "Group was deleted."