devstack/tools/upload_image.sh
Gary Kotton ffc1f8d426 Fix tools upload_image.sh utility
The utility would fail due to the fact that the GLANCE_SERVICE_PROTOCOL
was not set.

Change-Id: Iff0b59274fa909895abd70c3a6d1da63dbd70483
Closes-bug: #1396567
2014-12-04 04:59:26 -08:00

45 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# upload_image.sh - Retrieve and upload an image into Glance
#
# upload_image.sh <image-url>
#
# Assumes credentials are set via OS_* environment variables
function usage {
echo "$0 - Retrieve and upload an image into Glance"
echo ""
echo "Usage: $0 <image-url> [...]"
echo ""
echo "Assumes credentials are set via OS_* environment variables"
exit 1
}
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions
# Import configuration
source $TOP_DIR/openrc "" "" "" ""
# Find the cache dir
FILES=$TOP_DIR/files
if [[ -z "$1" ]]; then
usage
fi
# Get a token to authenticate to glance
TOKEN=$(keystone token-get | grep ' id ' | get_field 2)
die_if_not_set $LINENO TOKEN "Keystone fail to get token"
# Glance connection info. Note the port must be specified.
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$GLANCE_HOST:9292}
GLANCE_SERVICE_PROTOCOL=${GLANCE_SERVICE_PROTOCOL:-$SERVICE_PROTOCOL}
for IMAGE in "$*"; do
upload_image $IMAGE $TOKEN
done