exercises/swift.sh
3e6ec236
 #!/usr/bin/env bash
 
27e32699
 # **swift.sh**
 
bbe59edb
 # Test swift via the ``python-openstackclient`` command line
3e6ec236
 
27e32699
 echo "*********************************************************************"
489bd2a6
 echo "Begin DevStack Exercise: $0"
27e32699
 echo "*********************************************************************"
489bd2a6
 
3e6ec236
 # This script exits on an error so that errors don't compound and you see
4640026c
 # only the first error that occurred.
3e6ec236
 set -o errexit
 
 # Print the commands being run so that we can see the command that triggers
01acdabb
 # an error.  It is also useful for following as the install occurs.
3e6ec236
 set -o xtrace
 
 
 # Settings
 # ========
 
51fb454f
 # Keep track of the current directory
 EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
 TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
489bd2a6
 
 # Import common functions
51fb454f
 source $TOP_DIR/functions
489bd2a6
 
 # Import configuration
51fb454f
 source $TOP_DIR/openrc
 
 # Import exercise configuration
 source $TOP_DIR/exerciserc
489bd2a6
 
408b009c
 # If swift is not enabled we exit with exitcode 55 which mean
 # exercise is skipped.
0c3a5584
 is_service_enabled s-proxy || exit 55
3e6ec236
 
da85cdad
 # Container name
 CONTAINER=ex-swift
bbe59edb
 OBJECT=/etc/issue
da85cdad
 
ad101767
 
3e6ec236
 # Testing Swift
 # =============
 
 # Check if we have to swift via keystone
bbe59edb
 openstack object store account show || die $LINENO "Failure getting account status"
3e6ec236
 
 # We start by creating a test container
bf1b8ed4
 openstack container create $CONTAINER || die $LINENO "Failure creating container $CONTAINER"
3e6ec236
 
bbe59edb
 # add a file into it.
 openstack object create $CONTAINER $OBJECT || die $LINENO "Failure uploading file to container $CONTAINER"
3e6ec236
 
bbe59edb
 # list the objects
bf1b8ed4
 openstack object list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER"
3e6ec236
 
bbe59edb
 # delete the object first
 openstack object delete $CONTAINER $OBJECT || die $LINENO "Failure deleting object $OBJECT in container $CONTAINER"
 
 # delete the container
 openstack container delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER"
489bd2a6
 
 set +o xtrace
27e32699
 echo "*********************************************************************"
 echo "SUCCESS: End DevStack Exercise: $0"
 echo "*********************************************************************"