| 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 | # | 
|  | 3 | # source openrc [username] [tenantname] | 
|  | 4 | # | 
|  | 5 | # Configure a set of credentials for $TENANT/$USERNAME: | 
| Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 6 | #   Set OS_TENANT_NAME to override the default tenant 'demo' | 
|  | 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 | 
| Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 17 | OS_TENANT_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 |  | 
| Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 37 | # The introduction of Keystone to the OpenStack ecosystem has standardized the | 
|  | 38 | # term **tenant** as the entity that owns resources.  In some places references | 
|  | 39 | # still exist to the original Nova term **project** for this use.  Also, | 
| Joe Gordon | 4640026 | 2013-06-30 04:32:27 -0700 | [diff] [blame] | 40 | # **tenant_name** is preferred to **tenant_id**. | 
| Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 41 | export OS_TENANT_NAME=${OS_TENANT_NAME:-demo} | 
| Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 42 |  | 
|  | 43 | # In addition to the owning entity (tenant), nova stores the entity performing | 
|  | 44 | # the action as the **user**. | 
| Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 45 | export OS_USERNAME=${OS_USERNAME:-demo} | 
| Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 46 |  | 
|  | 47 | # With Keystone you pass the keystone password instead of an api key. | 
|  | 48 | # Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs | 
|  | 49 | # or NOVA_PASSWORD. | 
|  | 50 | export OS_PASSWORD=${ADMIN_PASSWORD:-secrete} | 
|  | 51 |  | 
| Vishvananda Ishaya | 7b0f002 | 2012-08-10 22:31:19 +0000 | [diff] [blame] | 52 | # Don't put the key into a keyring by default. Testing for development is much | 
|  | 53 | # easier with this off. | 
|  | 54 | export OS_NO_CACHE=${OS_NO_CACHE:-1} | 
|  | 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 |  | 
| Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 59 | # Set api HOST_IP endpoint.  SERVICE_HOST may also be used to specify the endpoint, | 
|  | 60 | # which is convenient for some localrc configurations. | 
| Jesse Andrews | f75d848 | 2011-10-24 13:38:52 -0700 | [diff] [blame] | 61 | HOST_IP=${HOST_IP:-127.0.0.1} | 
| Anthony Young | 1097c7c | 2011-12-27 23:22:14 -0800 | [diff] [blame] | 62 | SERVICE_HOST=${SERVICE_HOST:-$HOST_IP} | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 63 | SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http} | 
| Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 64 | KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-$SERVICE_PROTOCOL} | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 65 | KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST} | 
| Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 66 |  | 
| Adam Gandelman | ce05e03 | 2012-01-30 14:43:14 -0800 | [diff] [blame] | 67 | # Some exercises call glance directly.  On a single-node installation, Glance | 
|  | 68 | # should be listening on HOST_IP.  If its running elsewhere, it can be set here | 
|  | 69 | GLANCE_HOST=${GLANCE_HOST:-$HOST_IP} | 
|  | 70 |  | 
| Yong Sheng Gong | 300e1bf | 2013-08-28 17:02:56 +0800 | [diff] [blame] | 71 | # Identity API version | 
|  | 72 | export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-2.0} | 
|  | 73 |  | 
| tanlin | 2b69f23 | 2014-02-12 16:11:32 +0800 | [diff] [blame] | 74 | # Authenticating against an OpenStack cloud using Keystone returns a **Token** | 
| Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 75 | # and **Service Catalog**.  The catalog contains the endpoints for all services | 
|  | 76 | # the user/tenant has access to - including nova, glance, keystone, swift, ... | 
|  | 77 | # We currently recommend using the 2.0 *identity api*. | 
| Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 78 | # | 
| Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 79 | export OS_AUTH_URL=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:5000/v${OS_IDENTITY_API_VERSION} | 
| Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 80 |  | 
|  | 81 | # Set the pointer to our CA certificate chain.  Harmless if TLS is not used. | 
| Jamie Lennox | bd24a8d | 2013-09-20 16:26:42 +1000 | [diff] [blame] | 82 | export OS_CACERT=${OS_CACERT:-$INT_CA_DIR/ca-chain.pem} | 
| Anthony Young | 6ab10d4 | 2011-10-20 10:24:50 -0700 | [diff] [blame] | 83 |  | 
|  | 84 | # Currently novaclient needs you to specify the *compute api* version.  This | 
|  | 85 | # needs to match the config of your catalog returned by Keystone. | 
| Anthony Young | d81ed03 | 2011-10-20 13:09:39 -0700 | [diff] [blame] | 86 | export NOVA_VERSION=${NOVA_VERSION:-1.1} | 
| Dean Troyer | 4807df8 | 2012-02-24 10:44:18 -0600 | [diff] [blame] | 87 | # In the future this will change names: | 
|  | 88 | export COMPUTE_API_VERSION=${COMPUTE_API_VERSION:-$NOVA_VERSION} | 
| Mike Perez | bd8ac01 | 2013-08-20 21:53:30 -0700 | [diff] [blame] | 89 |  | 
|  | 90 | # Currently cinderclient needs you to specify the *volume api* version. This | 
|  | 91 | # needs to match the config of your catalog returned by Keystone. | 
|  | 92 | export CINDER_VERSION=${CINDER_VERSION:-2} | 
|  | 93 | export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION} |