blob: 1e672bd932fba9a3d5e7b93ce763b2a58e27970e [file] [log] [blame]
Dean Troyer0bd24102012-03-08 00:33:54 -06001#!/usr/bin/env bash
2#
3# source eucarc [username] [tenantname]
4#
5# Create EC2 credentials for the current user as defined by OS_TENANT_NAME:OS_USERNAME
6# Optionally set the tenant/username via openrc
7
8if [[ -n "$1" ]]; then
9 USERNAME=$1
10fi
11if [[ -n "$2" ]]; then
12 TENANT=$2
13fi
14
15# Find the other rc files
Peter Feiner388e36c2013-10-24 18:51:44 -040016RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
Dean Troyer0bd24102012-03-08 00:33:54 -060017
18# Get user configuration
19source $RC_DIR/openrc
20
21# Set the ec2 url so euca2ools works
Peter Stachowski9a808922015-04-08 19:48:09 +000022export EC2_URL=$(openstack catalog show ec2 | awk '/ publicURL: / { print $4 }')
Dean Troyer0bd24102012-03-08 00:33:54 -060023
24# Create EC2 credentials for the current user
Steve Martinelli1e94eb12014-03-13 23:22:39 -050025CREDS=$(openstack ec2 credentials create)
Dean Troyer0bd24102012-03-08 00:33:54 -060026export EC2_ACCESS_KEY=$(echo "$CREDS" | awk '/ access / { print $4 }')
27export EC2_SECRET_KEY=$(echo "$CREDS" | awk '/ secret / { print $4 }')
28
29# Euca2ools Certificate stuff for uploading bundles
30# See exercises/bundle.sh to see how to get certs using nova cli
31NOVA_KEY_DIR=${NOVA_KEY_DIR:-$RC_DIR}
Peter Stachowski9a808922015-04-08 19:48:09 +000032export S3_URL=$(openstack catalog show s3 | awk '/ publicURL: / { print $4 }')
Dean Troyer0bd24102012-03-08 00:33:54 -060033export EC2_USER_ID=42 # nova does not use user id, but bundling requires it
34export EC2_PRIVATE_KEY=${NOVA_KEY_DIR}/pk.pem
35export EC2_CERT=${NOVA_KEY_DIR}/cert.pem
36export NOVA_CERT=${NOVA_KEY_DIR}/cacert.pem
37export EUCALYPTUS_CERT=${NOVA_CERT} # euca-bundle-image seems to require this set
38alias ec2-bundle-image="ec2-bundle-image --cert ${EC2_CERT} --privatekey ${EC2_PRIVATE_KEY} --user ${EC2_USER_ID} --ec2cert ${NOVA_CERT}"
39alias ec2-upload-bundle="ec2-upload-bundle -a ${EC2_ACCESS_KEY} -s ${EC2_SECRET_KEY} --url ${S3_URL} --ec2cert ${NOVA_CERT}"
40