Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 2 | # |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 3 | # source openrc [username] [projectname] |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 4 | # |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 5 | # Configure a set of credentials for $PROJECT/$USERNAME: |
| 6 | # Set OS_PROJECT_NAME to override the default project 'demo' |
Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 7 | # Set OS_USERNAME to override the default user name 'demo' |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 8 | # Set ADMIN_PASSWORD to set the password for 'admin' and 'demo' |
| 9 | |
| 10 | # NOTE: support for the old NOVA_* novaclient environment variables has |
| 11 | # been removed. |
| 12 | |
| 13 | if [[ -n "$1" ]]; then |
Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 14 | OS_USERNAME=$1 |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 15 | fi |
| 16 | if [[ -n "$2" ]]; then |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 17 | OS_PROJECT_NAME=$2 |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 18 | fi |
Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 19 | |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 20 | # Find the other rc files |
Peter Feiner | 388e36c | 2013-10-24 18:51:44 -0400 | [diff] [blame] | 21 | RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd) |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 22 | |
Jeff Peeler | ebdd61d | 2013-06-01 00:54:47 -0400 | [diff] [blame] | 23 | # Import common functions |
| 24 | source $RC_DIR/functions |
| 25 | |
Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 26 | # Load local configuration |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 27 | source $RC_DIR/stackrc |
Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 28 | |
Dean Troyer | 33cb430 | 2012-12-10 16:47:36 -0600 | [diff] [blame] | 29 | # Load the last env variables if available |
Dean Troyer | 3ac9535 | 2013-03-29 10:15:36 -0500 | [diff] [blame] | 30 | if [[ -r $RC_DIR/.stackenv ]]; then |
| 31 | source $RC_DIR/.stackenv |
Dean Troyer | 33cb430 | 2012-12-10 16:47:36 -0600 | [diff] [blame] | 32 | fi |
| 33 | |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 34 | # Get some necessary configuration |
| 35 | source $RC_DIR/lib/tls |
| 36 | |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 37 | # The OpenStack ecosystem has standardized the term **project** as the |
| 38 | # entity that owns resources. In some places **tenant** remains |
| 39 | # referenced, but in all cases this just means **project**. We will |
| 40 | # warn if we need to turn on legacy **tenant** support to have a |
| 41 | # working environment. |
| 42 | export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo} |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 43 | |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 44 | echo "WARNING: setting legacy OS_TENANT_NAME to support cli tools." |
| 45 | export OS_TENANT_NAME=$OS_PROJECT_NAME |
| 46 | |
| 47 | # In addition to the owning entity (project), nova stores the entity performing |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 48 | # the action as the **user**. |
Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 49 | export OS_USERNAME=${OS_USERNAME:-demo} |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 50 | |
| 51 | # With Keystone you pass the keystone password instead of an api key. |
| 52 | # Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs |
| 53 | # or NOVA_PASSWORD. |
Balagopal | 7ed812c | 2016-03-01 04:43:31 +0000 | [diff] [blame] | 54 | export OS_PASSWORD=${ADMIN_PASSWORD:-secret} |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 55 | |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 56 | # Region |
| 57 | export OS_REGION_NAME=${REGION_NAME:-RegionOne} |
| 58 | |
Brian Haley | 5d04db2 | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 59 | # Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION |
| 60 | # is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the |
| 61 | # endpoint, which is convenient for some localrc configurations. Additionally, |
| 62 | # some exercises call Glance directly. On a single-node installation, Glance |
| 63 | # should be listening on a local IP address, depending on the setting of |
| 64 | # SERVICE_IP_VERSION. If its running elsewhere, it can be set here. |
| 65 | if [[ $SERVICE_IP_VERSION == 6 ]]; then |
| 66 | HOST_IPV6=${HOST_IPV6:-::1} |
| 67 | SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]} |
| 68 | GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]} |
| 69 | else |
| 70 | HOST_IP=${HOST_IP:-127.0.0.1} |
| 71 | SERVICE_HOST=${SERVICE_HOST:-$HOST_IP} |
| 72 | GLANCE_HOST=${GLANCE_HOST:-$HOST_IP} |
| 73 | fi |
| 74 | |
Yong Sheng Gong | 300e1bf | 2013-08-28 17:02:56 +0800 | [diff] [blame] | 75 | # Identity API version |
Paulo Ewerton | 75bf972 | 2016-01-22 19:13:31 +0000 | [diff] [blame] | 76 | export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-3} |
Yong Sheng Gong | 300e1bf | 2013-08-28 17:02:56 +0800 | [diff] [blame] | 77 | |
Mehdi Abaakouk | 807de8e | 2017-02-24 14:55:33 +0100 | [diff] [blame] | 78 | # Ask keystoneauth1 to use keystone |
| 79 | export OS_AUTH_TYPE=password |
| 80 | |
tanlin | 2b69f23 | 2014-02-12 16:11:32 +0800 | [diff] [blame] | 81 | # Authenticating against an OpenStack cloud using Keystone returns a **Token** |
Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 82 | # and **Service Catalog**. The catalog contains the endpoints for all services |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 83 | # the user/project has access to - including nova, glance, keystone, swift, ... |
Paulo Ewerton | 75bf972 | 2016-01-22 19:13:31 +0000 | [diff] [blame] | 84 | # We currently recommend using the version 3 *identity api*. |
Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 85 | # |
Sean Dague | 9bfabc6 | 2017-04-20 15:11:43 -0400 | [diff] [blame] | 86 | |
zhangbailin | 32608da | 2017-08-09 01:43:00 -0700 | [diff] [blame^] | 87 | # If you don't have a working .stackenv, this is the backup position |
Sean Dague | 9bfabc6 | 2017-04-20 15:11:43 -0400 | [diff] [blame] | 88 | KEYSTONE_BACKUP=$SERVICE_PROTOCOL://$SERVICE_HOST:5000 |
| 89 | KEYSTONE_AUTH_URI=${KEYSTONE_AUTH_URI:-$KEYSTONE_BACKUP} |
| 90 | |
| 91 | export OS_AUTH_URL=${OS_AUTH_URL:-$KEYSTONE_AUTH_URI} |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 92 | |
Daniel Gonzalez | 336390f | 2016-04-01 10:53:13 +0200 | [diff] [blame] | 93 | # Currently, in order to use openstackclient with Identity API v3, |
| 94 | # we need to set the domain which the user and project belong to. |
| 95 | if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then |
| 96 | export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"} |
| 97 | export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"} |
| 98 | fi |
| 99 | |
Clint Byrum | 52a3beb | 2015-05-05 15:00:03 -0700 | [diff] [blame] | 100 | # Set OS_CACERT to a default CA certificate chain if it exists. |
| 101 | if [[ ! -v OS_CACERT ]] ; then |
| 102 | DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem |
| 103 | # If the file does not exist, this may confuse preflight sanity checks |
| 104 | if [ -e $DEFAULT_OS_CACERT ] ; then |
| 105 | export OS_CACERT=$DEFAULT_OS_CACERT |
| 106 | fi |
| 107 | fi |
Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 108 | |
Mike Perez | bd8ac01 | 2013-08-20 21:53:30 -0700 | [diff] [blame] | 109 | # Currently cinderclient needs you to specify the *volume api* version. This |
| 110 | # needs to match the config of your catalog returned by Keystone. |
| 111 | export CINDER_VERSION=${CINDER_VERSION:-2} |
| 112 | export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION} |