blob: 2b0f7dd1437e7cba343b4ee108234f9cca335924 [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
16RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
17
18# Get user configuration
19source $RC_DIR/openrc
20
21# Set the ec2 url so euca2ools works
22export EC2_URL=$(keystone catalog --service ec2 | awk '/ publicURL / { print $4 }')
23
24# Create EC2 credentials for the current user
25CREDS=$(keystone ec2-credentials-create)
26export 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}
32export S3_URL=$(keystone catalog --service s3 | awk '/ publicURL / { print $4 }')
33export 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