We've seen two different scenarios:
- Phenome and PI4 workshops: import a list of users based on email address
- ETK and ThinkChicago: generate accounts based on some common prefix (user1, team1)
PI4 ad-hoc script:
#!/bin/bash while IFS=, read role last first email do namespace=`echo $email | cut -f1 -d@` etcdctl mkdir /ndslabs/accounts/$namespace etcdctl set /ndslabs/accounts/$namespace/account "{\"id\":\"\",\"name\":\"$first $last\",\"description\":\"PI4 Bootcamp $role\",\"namespace\":\"$namespace\",\"email\":\"$email\",\"password\":\"\$apr1\$HJvTLe5b\$gHSl701dRVPybgpNSd85N1\",\"resourceLimits\":{\"cpuMax\":0,\"cpuDefault\":0,\"memMax\":0,\"memDefault\":0,\"storageQuota\":0},\"resourceUsage\":{\"cpu\":\"\",\"memory\":\"\",\"storage\":\"\",\"cpuPct\":\"\",\"memPct\":\"\"},\"status\":\"approved\",\"token\":\"6LY7_Ek63-E3kR0zOyu4CItmqtc\",\"organization\":\"UIUC\",\"lastLogin\":1495653926,\"inactiveTimeout\":1440}" done < users.csv
users.csv
Role,LastName,FirstName,Email Instructor,LeBauer,David,dlebauer@illinois.edu
ETK scripts
Here's the ad-hoc process used for the ETK workshop. Basically, given a template, generate 50 users all with the same password. It would be great if the solution you came up with could handle a few things:
etk.tmpl
{ "account": { "id": "", "name": "NAME", "description": "Pre-generated account for ETK2017", "namespace": "USER_ID", "email": "EMAIL", "password": "$apr1$pD1R2sQ/$nLnOoigwMTPiNtQ/rY9mY0", "resourceLimits": { "cpuMax": 0, "cpuDefault": 0, "memMax": 0, "memDefault": 0, "storageQuota": 0 }, "resourceUsage": { "cpu": "", "memory": "", "storage": "", "cpuPct": "", "memPct": "" }, "status": "approved", "token": "", "organization": "ETK2017", "lastLogin": 0, "inactiveTimeout": 1440 } }
users.sh: Create the JSON account file
for id in {1..50} do cat etk.tmpl | sed "s/NAME/User $id/g" | sed "s/USER_ID/user$id/g" | sed "s/EMAIL/user$id@ndslabs.org/g" > users/user$id.json done
import.sh: Import into Workbench
for id in {1..50} do ndslabsctl --server http://172.17.0.5:30001/api import -f users/user$id.json done
Requirements:
- Ability to either import users from CSV or to generate based on pattern (user1, team1)
- Pass the prefix into the process (e.g., -prefix user or -prefix team or similar)
- Eventually, it would be nice to specify different passwords – either randomly generated or via prefix (password, password2). The password we currently use is based on the Apache htpasswd apr1