#!/bin/bash

# Nova original used project_id as the *account* that owned resources (servers,
# ip address, ...)   With the addition of Keystone we have standardized on the
# term **tenant** as the entity that owns the resources.  **novaclient** still
# uses the old deprecated terms project_id.  Note that this field should now be
# set to tenant_name, not tenant_id.
export NOVA_PROJECT_ID={{ tenant_id }}

# In addition to the owning entity (tenant), nova stores the entity performing
# the action as the **user**.
export NOVA_USERNAME={{ user.username }}

# With Keystone you pass the keystone password instead of an api key.
# The most recent versions of novaclient use NOVA_PASSWORD instead of NOVA_API_KEY
echo "Please enter your Nova Password: "
read -s NOVA_PASSWORD_INPUT
export NOVA_PASSWORD=$NOVA_PASSWORD_INPUT

# With the addition of Keystone, to use an openstack cloud you should
# authenticate against keystone, which returns a **Token** and **Service
# Catalog**.  The catalog contains the endpoint for all services the user/tenant
# has access to - including nova, glance, keystone, swift, ...  We currently
# recommend using the 2.0 *auth api*.
#
# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0.  We
# will use the 1.1 *compute api*
export NOVA_URL={{ auth_url }}

# Currently novaclient needs you to specify the *compute api* version.  This
# needs to match the config of your catalog returned by Keystone.
export NOVA_VERSION=1.1

# FIXME - why does this need to be specified?
export NOVA_REGION_NAME=RegionOne

# Set Glance API variables as well
export OS_AUTH_USER={{ user.username }}
export OS_AUTH_KEY=$NOVA_PASSWORD_INPUT
export OS_AUTH_TENANT={{ tenant_id }}
export OS_AUTH_URL={{ auth_url }}
export OS_AUTH_STRATEGY=keystone
