blob: b72bedbea4671df5f4a34026b73baa04fb341be2 [file] [log] [blame]
Anthony Young6ab10d42011-10-20 10:24:50 -07001#!/usr/bin/env bash
Dean Troyer4807df82012-02-24 10:44:18 -06002#
Sean Dague7580a0c2016-02-17 06:23:36 -05003# source openrc [username] [projectname]
Dean Troyer4807df82012-02-24 10:44:18 -06004#
Sean Dague7580a0c2016-02-17 06:23:36 -05005# Configure a set of credentials for $PROJECT/$USERNAME:
6# Set OS_PROJECT_NAME to override the default project 'demo'
Russell Bryant08e07fb2012-03-28 15:23:58 -04007# Set OS_USERNAME to override the default user name 'demo'
Dean Troyer4807df82012-02-24 10:44:18 -06008# Set ADMIN_PASSWORD to set the password for 'admin' and 'demo'
9
Dean Troyer4807df82012-02-24 10:44:18 -060010if [[ -n "$1" ]]; then
Russell Bryant08e07fb2012-03-28 15:23:58 -040011 OS_USERNAME=$1
Dean Troyer4807df82012-02-24 10:44:18 -060012fi
13if [[ -n "$2" ]]; then
Sean Dague7580a0c2016-02-17 06:23:36 -050014 OS_PROJECT_NAME=$2
Dean Troyer4807df82012-02-24 10:44:18 -060015fi
Anthony Young6ab10d42011-10-20 10:24:50 -070016
Dean Troyer0bd24102012-03-08 00:33:54 -060017# Find the other rc files
Peter Feiner388e36c2013-10-24 18:51:44 -040018RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
Dean Troyer0bd24102012-03-08 00:33:54 -060019
Jeff Peelerebdd61d2013-06-01 00:54:47 -040020# Import common functions
21source $RC_DIR/functions
22
Anthony Young6ab10d42011-10-20 10:24:50 -070023# Load local configuration
Dean Troyer0bd24102012-03-08 00:33:54 -060024source $RC_DIR/stackrc
Anthony Young6ab10d42011-10-20 10:24:50 -070025
Dean Troyer33cb4302012-12-10 16:47:36 -060026# Load the last env variables if available
Dean Troyer3ac95352013-03-29 10:15:36 -050027if [[ -r $RC_DIR/.stackenv ]]; then
28 source $RC_DIR/.stackenv
Jens Harbott87c0de52018-04-03 15:16:30 +000029 export OS_CACERT
Dean Troyer33cb4302012-12-10 16:47:36 -060030fi
31
Dean Troyerc83a7e12012-11-29 11:47:58 -060032# Get some necessary configuration
33source $RC_DIR/lib/tls
34
Sean Dague7580a0c2016-02-17 06:23:36 -050035# The OpenStack ecosystem has standardized the term **project** as the
Stephen Finucane608489c2024-05-28 13:27:14 +010036# entity that owns resources.
Sean Dague7580a0c2016-02-17 06:23:36 -050037export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060038
Sean Dague7580a0c2016-02-17 06:23:36 -050039# In addition to the owning entity (project), nova stores the entity performing
Dean Troyer4807df82012-02-24 10:44:18 -060040# the action as the **user**.
Russell Bryant08e07fb2012-03-28 15:23:58 -040041export OS_USERNAME=${OS_USERNAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060042
43# With Keystone you pass the keystone password instead of an api key.
Balagopal7ed812c2016-03-01 04:43:31 +000044export OS_PASSWORD=${ADMIN_PASSWORD:-secret}
Dean Troyer4807df82012-02-24 10:44:18 -060045
Bartosz Górski0abde392014-02-28 14:15:19 +010046# Region
47export OS_REGION_NAME=${REGION_NAME:-RegionOne}
48
Brian Haley5d04db22015-06-16 13:14:31 -040049# 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.
55if [[ $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]}
59else
60 HOST_IP=${HOST_IP:-127.0.0.1}
61 SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
62 GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
63fi
64
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080065# Identity API version
Dr. Jens Harbott95555ba2021-11-10 06:22:52 +010066export OS_IDENTITY_API_VERSION=3
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080067
Mehdi Abaakouk807de8e2017-02-24 14:55:33 +010068# Ask keystoneauth1 to use keystone
69export OS_AUTH_TYPE=password
70
tanlin2b69f232014-02-12 16:11:32 +080071# Authenticating against an OpenStack cloud using Keystone returns a **Token**
Dean Troyer4807df82012-02-24 10:44:18 -060072# and **Service Catalog**. The catalog contains the endpoints for all services
Sean Dague7580a0c2016-02-17 06:23:36 -050073# the user/project has access to - including nova, glance, keystone, swift, ...
Paulo Ewerton75bf9722016-01-22 19:13:31 +000074# We currently recommend using the version 3 *identity api*.
Anthony Young6ab10d42011-10-20 10:24:50 -070075#
Sean Dague9bfabc62017-04-20 15:11:43 -040076
zhangbailin32608da2017-08-09 01:43:00 -070077# If you don't have a working .stackenv, this is the backup position
Abhishek Kekanef8dbfd32020-07-06 18:42:30 +000078KEYSTONE_BACKUP=$SERVICE_PROTOCOL://$SERVICE_HOST:5000
Jens Harbott32c00892019-04-10 10:33:39 +000079KEYSTONE_SERVICE_URI=${KEYSTONE_SERVICE_URI:-$KEYSTONE_BACKUP}
Sean Dague9bfabc62017-04-20 15:11:43 -040080
Jens Harbott32c00892019-04-10 10:33:39 +000081export OS_AUTH_URL=${OS_AUTH_URL:-$KEYSTONE_SERVICE_URI}
Dean Troyerc83a7e12012-11-29 11:47:58 -060082
Daniel Gonzalez336390f2016-04-01 10:53:13 +020083# Currently, in order to use openstackclient with Identity API v3,
84# we need to set the domain which the user and project belong to.
85if [ "$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"}
88fi
89
Clint Byrum52a3beb2015-05-05 15:00:03 -070090# Set OS_CACERT to a default CA certificate chain if it exists.
91if [[ ! -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
97fi
Anthony Young6ab10d42011-10-20 10:24:50 -070098
Mike Perezbd8ac012013-08-20 21:53:30 -070099# Currently cinderclient needs you to specify the *volume api* version. This
100# needs to match the config of your catalog returned by Keystone.
Matt Smithf774ecf2018-05-07 16:43:56 -0500101export CINDER_VERSION=${CINDER_VERSION:-3}
Mike Perezbd8ac012013-08-20 21:53:30 -0700102export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION}