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