blob: 99d3351d53947e8bb6cd27f9acc40319d40e983b [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
10# NOTE: support for the old NOVA_* novaclient environment variables has
11# been removed.
12
13if [[ -n "$1" ]]; then
Russell Bryant08e07fb2012-03-28 15:23:58 -040014 OS_USERNAME=$1
Dean Troyer4807df82012-02-24 10:44:18 -060015fi
16if [[ -n "$2" ]]; then
Sean Dague7580a0c2016-02-17 06:23:36 -050017 OS_PROJECT_NAME=$2
Dean Troyer4807df82012-02-24 10:44:18 -060018fi
Anthony Young6ab10d42011-10-20 10:24:50 -070019
Dean Troyer0bd24102012-03-08 00:33:54 -060020# Find the other rc files
Peter Feiner388e36c2013-10-24 18:51:44 -040021RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
Dean Troyer0bd24102012-03-08 00:33:54 -060022
Jeff Peelerebdd61d2013-06-01 00:54:47 -040023# Import common functions
24source $RC_DIR/functions
25
Anthony Young6ab10d42011-10-20 10:24:50 -070026# Load local configuration
Dean Troyer0bd24102012-03-08 00:33:54 -060027source $RC_DIR/stackrc
Anthony Young6ab10d42011-10-20 10:24:50 -070028
Dean Troyer33cb4302012-12-10 16:47:36 -060029# Load the last env variables if available
Dean Troyer3ac95352013-03-29 10:15:36 -050030if [[ -r $RC_DIR/.stackenv ]]; then
31 source $RC_DIR/.stackenv
Jens Harbott87c0de52018-04-03 15:16:30 +000032 export OS_CACERT
Dean Troyer33cb4302012-12-10 16:47:36 -060033fi
34
Dean Troyerc83a7e12012-11-29 11:47:58 -060035# Get some necessary configuration
36source $RC_DIR/lib/tls
37
Sean Dague7580a0c2016-02-17 06:23:36 -050038# The OpenStack ecosystem has standardized the term **project** as the
39# entity that owns resources. In some places **tenant** remains
40# referenced, but in all cases this just means **project**. We will
41# warn if we need to turn on legacy **tenant** support to have a
42# working environment.
43export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060044
Sean Dague7580a0c2016-02-17 06:23:36 -050045echo "WARNING: setting legacy OS_TENANT_NAME to support cli tools."
46export OS_TENANT_NAME=$OS_PROJECT_NAME
47
48# In addition to the owning entity (project), nova stores the entity performing
Dean Troyer4807df82012-02-24 10:44:18 -060049# the action as the **user**.
Russell Bryant08e07fb2012-03-28 15:23:58 -040050export OS_USERNAME=${OS_USERNAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060051
52# With Keystone you pass the keystone password instead of an api key.
53# Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs
54# or NOVA_PASSWORD.
Balagopal7ed812c2016-03-01 04:43:31 +000055export OS_PASSWORD=${ADMIN_PASSWORD:-secret}
Dean Troyer4807df82012-02-24 10:44:18 -060056
Bartosz Górski0abde392014-02-28 14:15:19 +010057# Region
58export OS_REGION_NAME=${REGION_NAME:-RegionOne}
59
Brian Haley5d04db22015-06-16 13:14:31 -040060# Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION
61# is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the
62# endpoint, which is convenient for some localrc configurations. Additionally,
63# some exercises call Glance directly. On a single-node installation, Glance
64# should be listening on a local IP address, depending on the setting of
65# SERVICE_IP_VERSION. If its running elsewhere, it can be set here.
66if [[ $SERVICE_IP_VERSION == 6 ]]; then
67 HOST_IPV6=${HOST_IPV6:-::1}
68 SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]}
69 GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]}
70else
71 HOST_IP=${HOST_IP:-127.0.0.1}
72 SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
73 GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
74fi
75
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080076# Identity API version
Paulo Ewerton75bf9722016-01-22 19:13:31 +000077export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-3}
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080078
Mehdi Abaakouk807de8e2017-02-24 14:55:33 +010079# Ask keystoneauth1 to use keystone
80export OS_AUTH_TYPE=password
81
tanlin2b69f232014-02-12 16:11:32 +080082# Authenticating against an OpenStack cloud using Keystone returns a **Token**
Dean Troyer4807df82012-02-24 10:44:18 -060083# and **Service Catalog**. The catalog contains the endpoints for all services
Sean Dague7580a0c2016-02-17 06:23:36 -050084# the user/project has access to - including nova, glance, keystone, swift, ...
Paulo Ewerton75bf9722016-01-22 19:13:31 +000085# We currently recommend using the version 3 *identity api*.
Anthony Young6ab10d42011-10-20 10:24:50 -070086#
Sean Dague9bfabc62017-04-20 15:11:43 -040087
zhangbailin32608da2017-08-09 01:43:00 -070088# If you don't have a working .stackenv, this is the backup position
Sean Dague9bfabc62017-04-20 15:11:43 -040089KEYSTONE_BACKUP=$SERVICE_PROTOCOL://$SERVICE_HOST:5000
90KEYSTONE_AUTH_URI=${KEYSTONE_AUTH_URI:-$KEYSTONE_BACKUP}
91
92export OS_AUTH_URL=${OS_AUTH_URL:-$KEYSTONE_AUTH_URI}
Dean Troyerc83a7e12012-11-29 11:47:58 -060093
Daniel Gonzalez336390f2016-04-01 10:53:13 +020094# Currently, in order to use openstackclient with Identity API v3,
95# we need to set the domain which the user and project belong to.
96if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then
97 export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"}
98 export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"}
99fi
100
Clint Byrum52a3beb2015-05-05 15:00:03 -0700101# Set OS_CACERT to a default CA certificate chain if it exists.
102if [[ ! -v OS_CACERT ]] ; then
103 DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem
104 # If the file does not exist, this may confuse preflight sanity checks
105 if [ -e $DEFAULT_OS_CACERT ] ; then
106 export OS_CACERT=$DEFAULT_OS_CACERT
107 fi
108fi
Anthony Young6ab10d42011-10-20 10:24:50 -0700109
Mike Perezbd8ac012013-08-20 21:53:30 -0700110# Currently cinderclient needs you to specify the *volume api* version. This
111# needs to match the config of your catalog returned by Keystone.
Matt Smithf774ecf2018-05-07 16:43:56 -0500112export CINDER_VERSION=${CINDER_VERSION:-3}
Mike Perezbd8ac012013-08-20 21:53:30 -0700113export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION}