blob: 19c6b719769e8e72e536c1be2f874b611285996f [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
Peter Stachowski9a808922015-04-08 19:48:09 +000035TOKEN=$(openstack token issue -c id -f value)
DennyZhangacb52e52013-10-11 00:08:29 -050036die_if_not_set $LINENO TOKEN "Keystone fail to get token"
Dean Troyerca0e3d02012-04-13 15:58:37 -050037
38# Glance connection info. Note the port must be specified.
39GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_HOST:9292}
Gary Kottonffc1f8d2014-11-26 04:00:33 -080040GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
Dean Troyerca0e3d02012-04-13 15:58:37 -050041
42for IMAGE in "$*"; do
43 upload_image $IMAGE $TOKEN
44done