Created
May 20, 2013 14:40
-
-
Save chmouel/5612648 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
SWIFT_OPERATOR_ROLE=${SWIFT_OPERATOR_ROLE:-Member} | |
PASSWORD=ADMIN | |
function get_id () { | |
echo `"$@" | awk '/ id / { print $4 }'` | |
} | |
function create_user { | |
USER_NAME=$1 | |
TENANT_NAME=${1:-$USER_NAME} | |
ROLE_ID=$(keystone role-list|awk "/${SWIFT_OPERATOR_ROLE}/ {print \$2}") | |
TENANT_ID=$(get_id keystone tenant-create --name=${TENANT_NAME}) | |
USER_ID=$(get_id keystone user-create --name=${USER_NAME} \ | |
--pass=${PASSWORD} \ | |
--email=${USER_NAME}@example.com) | |
keystone user-role-add --user_id $USER_ID --role_id $ROLE_ID --tenant_id $TENANT_ID | |
} | |
COUNT=1 | |
if [[ -z $1 ]];then | |
NAME=testing | |
else | |
NAME=$1 | |
fi | |
if [[ -n ${2} ]];then | |
COUNT=${2} | |
fi | |
for i in $(seq ${COUNT});do | |
[[ ${COUNT} > 1 ]] && thename=${NAME}${i} || thename=${NAME} | |
create_user ${thename} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment