Created
February 20, 2013 03:51
-
-
Save robertstarmer/4992723 to your computer and use it in GitHub Desktop.
A quick script to add a user and project to OpenStack (folsom)
This file contains 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 | |
source ~/openrc | |
echo Argv: $# | |
if [[ $# -lt 3 ]] | |
then | |
echo -e "Usage:\n${0} user password e-mail@address [tenant=openstack]" | |
else | |
user_id=`keystone user-list | grep ${1} | awk -F' ' '{print $2}'` | |
if [ ! -z ${user_id} ] | |
then | |
echo "error! username already exists" | |
exit 1 | |
fi | |
if [[ $# -eq 3 ]] | |
then | |
tenant_id=`keystone tenant-list | grep openstack | awk -F' ' '{print $2}'` | |
keystone user-create --name=${1} --pass=${2} --email=${3} --tenant-id=${tenant_id} | |
else | |
tenant_id=`keystone tenant-list | grep ${4} | awk -F' ' '{print $2}'` | |
if [ -z ${tenant_id} ]; then | |
keystone tenant-create --name=${4} | |
tenant_id=`keystone tenant-list | grep ${4} | awk -F' ' '{print $2}'` | |
fi | |
keystone user-create --name=${1} --pass=${2} --email=${3} --tenant-id=${tenant_id} | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment