Skip to content

Optimize imports of users and groups #1

Description

@obscurerichard

When I asked @rcritten for permission to publish this derived work, he gave some excellent advice on optimizing the imports:

@rcritten:
As an aside, adding group members one at a time may bring with it a big
performance penalty if you have a group with a lot of members.

@obscurerichard:
Thanks! I had it the other way (group members comma separated) initially but I got
an error code from the "ipa group-member-add" when I first tried it that way so I
fell back to this simpler but slower method. I may take a 2nd pass at doing it that
way to see if it worked anyway.

@rcritten:
You should be able to pass them in with multiple --users options (or the
API equivalent).

The batch command is another alternative. You can do the single-user
adds as one batch command and execute them all at once without all the
round-trips. I've tended to batch up the commands in groups of 50 or 100.

It looks something like this:

batch = []
args = [groupname]
kw = {'users': user}
batch.append({'method': 'group_add_member', 'params': [args, kw]})

When you've collected all the users you want, execute the command with

api.Command.batch(batch)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions