Skip to content

Instantly share code, notes, and snippets.

@robertstarmer
Created February 20, 2013 03:51
Show Gist options
  • Save robertstarmer/4992723 to your computer and use it in GitHub Desktop.
Save robertstarmer/4992723 to your computer and use it in GitHub Desktop.
A quick script to add a user and project to OpenStack (folsom)
#!/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