openrc
6ab10d46
 #!/usr/bin/env bash
4807df8e
 #
7580a0c3
 # source openrc [username] [projectname]
4807df8e
 #
7580a0c3
 # Configure a set of credentials for $PROJECT/$USERNAME:
 #   Set OS_PROJECT_NAME to override the default project 'demo'
08e07fb4
 #   Set OS_USERNAME to override the default user name 'demo'
4807df8e
 #   Set ADMIN_PASSWORD to set the password for 'admin' and 'demo'
 
 # NOTE: support for the old NOVA_* novaclient environment variables has
 # been removed.
 
 if [[ -n "$1" ]]; then
08e07fb4
     OS_USERNAME=$1
4807df8e
 fi
 if [[ -n "$2" ]]; then
7580a0c3
     OS_PROJECT_NAME=$2
4807df8e
 fi
6ab10d46
 
0bd2410d
 # Find the other rc files
388e36c9
 RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
0bd2410d
 
ebdd61d1
 # Import common functions
 source $RC_DIR/functions
 
6ab10d46
 # Load local configuration
0bd2410d
 source $RC_DIR/stackrc
6ab10d46
 
33cb4303
 # Load the last env variables if available
3ac95355
 if [[ -r $RC_DIR/.stackenv ]]; then
     source $RC_DIR/.stackenv
87c0de52
     export OS_CACERT
33cb4303
 fi
 
c83a7e12
 # Get some necessary configuration
 source $RC_DIR/lib/tls
 
7580a0c3
 # The OpenStack ecosystem has standardized the term **project** as the
 # entity that owns resources.  In some places **tenant** remains
 # referenced, but in all cases this just means **project**.  We will
 # warn if we need to turn on legacy **tenant** support to have a
 # working environment.
 export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}
4807df8e
 
7580a0c3
 echo "WARNING: setting legacy OS_TENANT_NAME to support cli tools."
 export OS_TENANT_NAME=$OS_PROJECT_NAME
 
 # In addition to the owning entity (project), nova stores the entity performing
4807df8e
 # the action as the **user**.
08e07fb4
 export OS_USERNAME=${OS_USERNAME:-demo}
4807df8e
 
 # With Keystone you pass the keystone password instead of an api key.
 # Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs
 # or NOVA_PASSWORD.
7ed812c6
 export OS_PASSWORD=${ADMIN_PASSWORD:-secret}
4807df8e
 
0abde393
 # Region
 export OS_REGION_NAME=${REGION_NAME:-RegionOne}
 
5d04db20
 # Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION
 # is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the
 # endpoint, which is convenient for some localrc configurations. Additionally,
 # some exercises call Glance directly. On a single-node installation, Glance
 # should be listening on a local IP address, depending on the setting of
 # SERVICE_IP_VERSION. If its running elsewhere, it can be set here.
 if [[ $SERVICE_IP_VERSION == 6 ]]; then
     HOST_IPV6=${HOST_IPV6:-::1}
     SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]}
     GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]}
 else
     HOST_IP=${HOST_IP:-127.0.0.1}
     SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
     GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
 fi
 
300e1bf2
 # Identity API version
75bf9722
 export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-3}
300e1bf2
 
807de8e5
 # Ask keystoneauth1 to use keystone
 export OS_AUTH_TYPE=password
 
2b69f236
 # Authenticating against an OpenStack cloud using Keystone returns a **Token**
4807df8e
 # and **Service Catalog**.  The catalog contains the endpoints for all services
7580a0c3
 # the user/project has access to - including nova, glance, keystone, swift, ...
75bf9722
 # We currently recommend using the version 3 *identity api*.
6ab10d46
 #
9bfabc68
 
32608da2
 # If you don't have a working .stackenv, this is the backup position
f8dbfd39
 KEYSTONE_BACKUP=$SERVICE_PROTOCOL://$SERVICE_HOST:5000
32c00890
 KEYSTONE_SERVICE_URI=${KEYSTONE_SERVICE_URI:-$KEYSTONE_BACKUP}
9bfabc68
 
32c00890
 export OS_AUTH_URL=${OS_AUTH_URL:-$KEYSTONE_SERVICE_URI}
c83a7e12
 
336390f9
 # Currently, in order to use openstackclient with Identity API v3,
 # we need to set the domain which the user and project belong to.
 if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then
     export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"}
     export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"}
 fi
 
52a3bebc
 # Set OS_CACERT to a default CA certificate chain if it exists.
 if [[ ! -v OS_CACERT ]] ; then
     DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem
     # If the file does not exist, this may confuse preflight sanity checks
     if [ -e $DEFAULT_OS_CACERT ] ; then
         export OS_CACERT=$DEFAULT_OS_CACERT
     fi
 fi
6ab10d46
 
bd8ac01b
 # Currently cinderclient needs you to specify the *volume api* version. This
 # needs to match the config of your catalog returned by Keystone.
f774ecf4
 export CINDER_VERSION=${CINDER_VERSION:-3}
bd8ac01b
 export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION}