blob: dd21c9f2a8f6fa00c75bfb7eb62a14a7ab199162 [file] [log] [blame]
Dean Troyerca0e3d02012-04-13 15:58:37 -05001#!/usr/bin/env bash
2# upload_image.sh - Retrieve and upload an image into Glance
3#
4# upload_image.sh <image-url>
5#
6# Assumes credentials are set via OS_* environment variables
7
8function usage {
9 echo "$0 - Retrieve and upload an image into Glance"
10 echo ""
11 echo "Usage: $0 <image-url> [...]"
12 echo ""
13 echo "Assumes credentials are set via OS_* environment variables"
14 exit 1
15}
16
17# Keep track of the current directory
18TOOLS_DIR=$(cd $(dirname "$0") && pwd)
19TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
20
21# Import common functions
22source $TOP_DIR/functions
23
24# Import configuration
25source $TOP_DIR/openrc "" "" "" ""
26
27# Find the cache dir
28FILES=$TOP_DIR/files
29
30if [[ -z "$1" ]]; then
31 usage
32fi
33
34# Get a token to authenticate to glance
35TOKEN=$(keystone token-get | grep ' id ' | get_field 2)
36
37# Glance connection info. Note the port must be specified.
38GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_HOST:9292}
39
40for IMAGE in "$*"; do
41 upload_image $IMAGE $TOKEN
42done