blob: d1c61297a135cfedbb916b91fd8f9f0f68b87200 [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
Dean Troyer33cb4302012-12-10 16:47:36 -060032fi
33
Dean Troyerc83a7e12012-11-29 11:47:58 -060034# Get some necessary configuration
35source $RC_DIR/lib/tls
36
Sean Dague7580a0c2016-02-17 06:23:36 -050037# The OpenStack ecosystem has standardized the term **project** as the
38# entity that owns resources. In some places **tenant** remains
39# referenced, but in all cases this just means **project**. We will
40# warn if we need to turn on legacy **tenant** support to have a
41# working environment.
42export OS_PROJECT_NAME=${OS_PROJECT_NAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060043
Sean Dague7580a0c2016-02-17 06:23:36 -050044echo "WARNING: setting legacy OS_TENANT_NAME to support cli tools."
45export OS_TENANT_NAME=$OS_PROJECT_NAME
46
47# In addition to the owning entity (project), nova stores the entity performing
Dean Troyer4807df82012-02-24 10:44:18 -060048# the action as the **user**.
Russell Bryant08e07fb2012-03-28 15:23:58 -040049export OS_USERNAME=${OS_USERNAME:-demo}
Dean Troyer4807df82012-02-24 10:44:18 -060050
51# With Keystone you pass the keystone password instead of an api key.
52# Recent versions of novaclient use OS_PASSWORD instead of NOVA_API_KEYs
53# or NOVA_PASSWORD.
Balagopal7ed812c2016-03-01 04:43:31 +000054export OS_PASSWORD=${ADMIN_PASSWORD:-secret}
Dean Troyer4807df82012-02-24 10:44:18 -060055
Vishvananda Ishaya7b0f0022012-08-10 22:31:19 +000056# Don't put the key into a keyring by default. Testing for development is much
57# easier with this off.
58export OS_NO_CACHE=${OS_NO_CACHE:-1}
59
Bartosz Górski0abde392014-02-28 14:15:19 +010060# Region
61export OS_REGION_NAME=${REGION_NAME:-RegionOne}
62
Brian Haley5d04db22015-06-16 13:14:31 -040063# Set the host API endpoint. This will default to HOST_IP if SERVICE_IP_VERSION
64# is 4, else HOST_IPV6 if it's 6. SERVICE_HOST may also be used to specify the
65# endpoint, which is convenient for some localrc configurations. Additionally,
66# some exercises call Glance directly. On a single-node installation, Glance
67# should be listening on a local IP address, depending on the setting of
68# SERVICE_IP_VERSION. If its running elsewhere, it can be set here.
69if [[ $SERVICE_IP_VERSION == 6 ]]; then
70 HOST_IPV6=${HOST_IPV6:-::1}
71 SERVICE_HOST=${SERVICE_HOST:-[$HOST_IPV6]}
72 GLANCE_HOST=${GLANCE_HOST:-[$HOST_IPV6]}
73else
74 HOST_IP=${HOST_IP:-127.0.0.1}
75 SERVICE_HOST=${SERVICE_HOST:-$HOST_IP}
76 GLANCE_HOST=${GLANCE_HOST:-$HOST_IP}
77fi
78
Dean Troyerc83a7e12012-11-29 11:47:58 -060079SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
Jamie Lennoxbd24a8d2013-09-20 16:26:42 +100080KEYSTONE_AUTH_PROTOCOL=${KEYSTONE_AUTH_PROTOCOL:-$SERVICE_PROTOCOL}
Bartosz Górski0abde392014-02-28 14:15:19 +010081KEYSTONE_AUTH_HOST=${KEYSTONE_AUTH_HOST:-$SERVICE_HOST}
Anthony Young6ab10d42011-10-20 10:24:50 -070082
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080083# Identity API version
Paulo Ewerton75bf9722016-01-22 19:13:31 +000084export OS_IDENTITY_API_VERSION=${IDENTITY_API_VERSION:-3}
Yong Sheng Gong300e1bf2013-08-28 17:02:56 +080085
tanlin2b69f232014-02-12 16:11:32 +080086# Authenticating against an OpenStack cloud using Keystone returns a **Token**
Dean Troyer4807df82012-02-24 10:44:18 -060087# and **Service Catalog**. The catalog contains the endpoints for all services
Sean Dague7580a0c2016-02-17 06:23:36 -050088# the user/project has access to - including nova, glance, keystone, swift, ...
Paulo Ewerton75bf9722016-01-22 19:13:31 +000089# We currently recommend using the version 3 *identity api*.
Anthony Young6ab10d42011-10-20 10:24:50 -070090#
Bartosz Górski0abde392014-02-28 14:15:19 +010091export OS_AUTH_URL=$KEYSTONE_AUTH_PROTOCOL://$KEYSTONE_AUTH_HOST:5000/v${OS_IDENTITY_API_VERSION}
Dean Troyerc83a7e12012-11-29 11:47:58 -060092
Daniel Gonzalez336390f2016-04-01 10:53:13 +020093# Currently, in order to use openstackclient with Identity API v3,
94# we need to set the domain which the user and project belong to.
95if [ "$OS_IDENTITY_API_VERSION" = "3" ]; then
96 export OS_USER_DOMAIN_ID=${OS_USER_DOMAIN_ID:-"default"}
97 export OS_PROJECT_DOMAIN_ID=${OS_PROJECT_DOMAIN_ID:-"default"}
98fi
99
Clint Byrum52a3beb2015-05-05 15:00:03 -0700100# Set OS_CACERT to a default CA certificate chain if it exists.
101if [[ ! -v OS_CACERT ]] ; then
102 DEFAULT_OS_CACERT=$INT_CA_DIR/ca-chain.pem
103 # If the file does not exist, this may confuse preflight sanity checks
104 if [ -e $DEFAULT_OS_CACERT ] ; then
105 export OS_CACERT=$DEFAULT_OS_CACERT
106 fi
107fi
Anthony Young6ab10d42011-10-20 10:24:50 -0700108
Mike Perezbd8ac012013-08-20 21:53:30 -0700109# Currently cinderclient needs you to specify the *volume api* version. This
110# needs to match the config of your catalog returned by Keystone.
111export CINDER_VERSION=${CINDER_VERSION:-2}
112export OS_VOLUME_API_VERSION=${OS_VOLUME_API_VERSION:-$CINDER_VERSION}