There's no built in way to bulk add, but it's fairly easy to script. Assuming your user CSV looks like this:
- Code: Select all
bulk-user1,Albert,A.,bulk-groups,abc123
bulk-user2,Barbara,B.,bulk-groups,def456
then you can use the following code to add the users:
- Code: Select all
#!/usr/bin/env python
import omero
import omero.cli
import fileinput
with omero.cli.cli_login() as cli:
for line in fileinput.input():
line = line.strip()
parts = line.split(",")
assert len(parts) == 5
omeName, firstName, lastName, groupName, password = parts
cli.invoke(["-q", "user", "add", "--ignore-existing",
omeName, firstName, lastName, groupName,
"--userpassword", password],
strict=True)
For example,
- Code: Select all
$ bin/omero login root@localhost
Created session for root@localhost:4064. Idle timeout: 10 min. Current group: system
$ bin/omero group add bulk-groups
Added group bulk-groups (id=4) with permissions rw----
$ PYTHONPATH=lib/python ./bulk.py bulk.csv
Added user bulk-user1 (id=3) with password
Added user bulk-user2 (id=4) with password
The "--ignore-existing" flag means that if you update the CSV and re-run the code, you'll see that some users have already been added:
- Code: Select all
$ PYTHONPATH=lib/python ./bulk.py bulk.csv
User exists: bulk-user1 (id=3)
User exists: bulk-user2 (id=4)