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 | |
Stephen Finucane | 9fff87f | 2024-05-28 13:33:32 +0100 | [diff] [blame] | 35 | # Minimal configuration |
| 36 | export OS_AUTH_TYPE=password |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 37 | export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo} |
Russell Bryant | 08e07fb | 2012-03-28 15:23:58 -0400 | [diff] [blame] | 38 | export OS_USERNAME=${OS_USERNAME:-demo} |
Balagopal | 7ed812c | 2016-03-01 04:43:31 +0000 | [diff] [blame] | 39 | export OS_PASSWORD=${ADMIN_PASSWORD:-secret} |
Bartosz Górski | 0abde39 | 2014-02-28 14:15:19 +0100 | [diff] [blame] | 40 | export OS_REGION_NAME=${REGION_NAME:-RegionOne} |
| 41 | |
Brian Haley | 5d04db2 | 2015-06-16 13:14:31 -0400 | [diff] [blame] | 42 | # Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION |
| 43 | # is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the |
| 44 | # endpoint, which is convenient for some localrc configurations. Additionally, |
| 45 | # some exercises call Glance directly. On a single-node installation, Glance |
| 46 | # should be listening on a local IP address, depending on the setting of |
| 47 | # SERVICE_IP_VERSION. If its running elsewhere, it can be set here. |
| 48 | if [[ $SERVICE_IP_VERSION == 6 ]]; then |
| 49 | HOST_IPV6=${HOST_IPV6:-::1} |
| 50 | SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]} |
| 51 | GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]} |
| 52 | else |
| 53 | HOST_IP=${HOST_IP:-127.0.0.1} |
| 54 | SERVICE_HOST=${SERVICE_HOST:-$HOST_IP} |
| 55 | GLANCE_HOST=${GLANCE_HOST:-$HOST_IP} |
| 56 | fi |
| 57 | |
zhangbailin | 32608da | 2017-08-09 01:43:00 -0700 | [diff] [blame] | 58 | # 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] | 59 | KEYSTONE_BACKUP=$SERVICE_PROTOCOL://$SERVICE_HOST:5000 |
Jens Harbott | 32c0089 | 2019-04-10 10:33:39 +0000 | [diff] [blame] | 60 | KEYSTONE_SERVICE_URI=${KEYSTONE_SERVICE_URI:-$KEYSTONE_BACKUP} |
Sean Dague | 9bfabc6 | 2017-04-20 15:11:43 -0400 | [diff] [blame] | 61 | |
Jens Harbott | 32c0089 | 2019-04-10 10:33:39 +0000 | [diff] [blame] | 62 | export OS_AUTH_URL=${OS_AUTH_URL:-$KEYSTONE_SERVICE_URI} |
Dean Troyer | c83a7e1 | 2012-11-29 11:47:58 -0600 | [diff] [blame] | 63 | |
Dr. Jens Harbott | eb0ac1d | 2024-07-08 18:02:25 +0200 | [diff] [blame] | 64 | export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"} |
| 65 | export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"} |
Daniel Gonzalez | 336390f | 2016-04-01 10:53:13 +0200 | [diff] [blame] | 66 | |
Clint Byrum | 52a3beb | 2015-05-05 15:00:03 -0700 | [diff] [blame] | 67 | # Set OS_CACERT to a default CA certificate chain if it exists. |
| 68 | if [[ ! -v OS_CACERT ]] ; then |
| 69 | DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem |
| 70 | # If the file does not exist, this may confuse preflight sanity checks |
| 71 | if [ -e $DEFAULT_OS_CACERT ] ; then |
| 72 | export OS_CACERT=$DEFAULT_OS_CACERT |
| 73 | fi |
| 74 | fi |