60 lines
1.4 KiB
Bash
60 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# source openrc
|
|
#
|
|
# Configure a set of credentials for $PROJECT/$USERNAME:
|
|
# set OS_AUTH_URL to Keystone end point
|
|
# Set OS_PROJECT_NAME to openstack project name
|
|
# Set OS_USERNAME to openstack user name
|
|
# Set ADMIN_PASSWORD to openstack password
|
|
|
|
# If using devstack:
|
|
# set both OS_USERNAME and OS_TENANT_NAME to 'admin' or 'demo'
|
|
# Example config for devstack:
|
|
# export OS_AUTH_URL="http://192.168.56.101:5000"
|
|
# export OS_TENANT_NAME="admin"
|
|
# export OS_USERNAME="admin"
|
|
# export OS_PASSWORD="ubuntu"
|
|
|
|
#
|
|
# set Keystone endpoint
|
|
#
|
|
export OS_AUTH_URL="<keystone endpoint>:5000"
|
|
|
|
|
|
#
|
|
# set openstack credentials
|
|
#
|
|
if [[ $# -ne 3 ]]; then
|
|
echo "wrong number of arguments!"
|
|
echo "enter openstack credentials in the following order:"
|
|
echo "source openrc <project_name> <user_name> <user_password>"
|
|
return
|
|
else
|
|
|
|
if [[ -n "$1" ]]; then
|
|
OS_PROJECT_NAME=$1
|
|
else
|
|
echo "Openstack project name cannot be an empty string"
|
|
return
|
|
fi
|
|
|
|
if [[ -n "$2" ]]; then
|
|
OS_USERNAME=$2
|
|
else
|
|
echo "Openstack user name cannot be an empty string"
|
|
return
|
|
fi
|
|
|
|
if [[ -n "$3" ]]; then
|
|
OS_PASSWORD=$3
|
|
else
|
|
echo "Openstack password cannot be an empty string"
|
|
return
|
|
fi
|
|
|
|
export OS_TENANT_NAME=${OS_PROJECT_NAME}
|
|
export OS_USERNAME=${OS_USERNAME}
|
|
export OS_PASSWORD=${OS_PASSWORD}
|
|
fi
|