2011-11-04 12:23:35 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2012-03-16 16:16:56 -05:00
|
|
|
# **swift.sh**
|
|
|
|
|
2013-10-05 12:11:07 +01:00
|
|
|
# Test swift via the ``swift`` command line from ``python-swiftclient``
|
2011-11-04 12:23:35 -04:00
|
|
|
|
2012-03-16 16:16:56 -05:00
|
|
|
echo "*********************************************************************"
|
2012-03-02 10:44:29 -06:00
|
|
|
echo "Begin DevStack Exercise: $0"
|
2012-03-16 16:16:56 -05:00
|
|
|
echo "*********************************************************************"
|
2012-03-02 10:44:29 -06:00
|
|
|
|
2011-11-04 12:23:35 -04:00
|
|
|
# This script exits on an error so that errors don't compound and you see
|
2013-06-30 04:32:27 -07:00
|
|
|
# only the first error that occurred.
|
2011-11-04 12:23:35 -04:00
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
# Print the commands being run so that we can see the command that triggers
|
|
|
|
# an error. It is also useful for following allowing as the install occurs.
|
|
|
|
set -o xtrace
|
|
|
|
|
|
|
|
|
|
|
|
# Settings
|
|
|
|
# ========
|
|
|
|
|
2012-03-09 22:21:59 -06:00
|
|
|
# Keep track of the current directory
|
|
|
|
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
|
|
|
|
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
|
2012-03-02 10:44:29 -06:00
|
|
|
|
|
|
|
# Import common functions
|
2012-03-09 22:21:59 -06:00
|
|
|
source $TOP_DIR/functions
|
2012-03-02 10:44:29 -06:00
|
|
|
|
|
|
|
# Import configuration
|
2012-03-09 22:21:59 -06:00
|
|
|
source $TOP_DIR/openrc
|
|
|
|
|
|
|
|
# Import exercise configuration
|
|
|
|
source $TOP_DIR/exerciserc
|
2012-03-02 10:44:29 -06:00
|
|
|
|
2012-03-15 23:21:55 +00:00
|
|
|
# If swift is not enabled we exit with exitcode 55 which mean
|
|
|
|
# exercise is skipped.
|
2013-03-06 10:58:33 +01:00
|
|
|
is_service_enabled s-proxy || exit 55
|
2011-11-04 12:23:35 -04:00
|
|
|
|
2013-02-15 11:07:14 -06:00
|
|
|
# Container name
|
|
|
|
CONTAINER=ex-swift
|
|
|
|
|
2012-06-27 22:04:40 -05:00
|
|
|
|
2011-11-04 12:23:35 -04:00
|
|
|
# Testing Swift
|
|
|
|
# =============
|
|
|
|
|
|
|
|
# Check if we have to swift via keystone
|
2013-02-26 12:38:18 -08:00
|
|
|
swift stat || die $LINENO "Failure geting status"
|
2011-11-04 12:23:35 -04:00
|
|
|
|
|
|
|
# We start by creating a test container
|
2013-02-26 12:38:18 -08:00
|
|
|
swift post $CONTAINER || die $LINENO "Failure creating container $CONTAINER"
|
2011-11-04 12:23:35 -04:00
|
|
|
|
|
|
|
# add some files into it.
|
2013-02-26 12:38:18 -08:00
|
|
|
swift upload $CONTAINER /etc/issue || die $LINENO "Failure uploading file to container $CONTAINER"
|
2011-11-04 12:23:35 -04:00
|
|
|
|
|
|
|
# list them
|
2013-02-26 12:38:18 -08:00
|
|
|
swift list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER"
|
2011-11-04 12:23:35 -04:00
|
|
|
|
|
|
|
# And we may want to delete them now that we have tested that
|
|
|
|
# everything works.
|
2013-02-26 12:38:18 -08:00
|
|
|
swift delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER"
|
2012-03-02 10:44:29 -06:00
|
|
|
|
|
|
|
set +o xtrace
|
2012-03-16 16:16:56 -05:00
|
|
|
echo "*********************************************************************"
|
|
|
|
echo "SUCCESS: End DevStack Exercise: $0"
|
|
|
|
echo "*********************************************************************"
|