swift.sh

swift.sh

# DIVIDER #!/usr/bin/env bash # DIVIDER echo "*********************************************************************" echo "Begin DevStack Exercise: $0" echo "*********************************************************************" # DIVIDER set -o errexit # DIVIDER set -o xtrace # DIVIDER # DIVIDER EXERCISE_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # DIVIDER source $TOP_DIR/functions # DIVIDER source $TOP_DIR/openrc # DIVIDER source $TOP_DIR/exerciserc # DIVIDER is_service_enabled s-proxy || exit 55 # DIVIDER CONTAINER=ex-swift OBJECT=/etc/issue # DIVIDER # DIVIDER openstack object store account show || die $LINENO "Failure getting account status" # DIVIDER openstack container create $CONTAINER || die $LINENO "Failure creating container $CONTAINER" # DIVIDER openstack object create $CONTAINER $OBJECT || die $LINENO "Failure uploading file to container $CONTAINER" # DIVIDER openstack object list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER" # DIVIDER openstack object delete $CONTAINER $OBJECT || die $LINENO "Failure deleting object $OBJECT in container $CONTAINER" # DIVIDER openstack container delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER" set +o xtrace echo "*********************************************************************" echo "SUCCESS: End DevStack Exercise: $0" echo "*********************************************************************" # DIVIDER

Test swift via the python-openstackclient command line

This script exits on an error so that errors don't compound and you see only the first error that occurred.

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.

Settings

Keep track of the current directory

Import common functions

Import configuration

Import exercise configuration

If swift is not enabled we exit with exitcode 55 which mean exercise is skipped.

Container name

Testing Swift

Check if we have to swift via keystone

We start by creating a test container

add a file into it.

list the objects

delete the object first

delete the container