Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 3 | # **swift.sh** |
| 4 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 5 | # Test swift via the ``swift`` command line from ``python-swiftclient` |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 6 | |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 7 | echo "*********************************************************************" |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 8 | echo "Begin DevStack Exercise: $0" |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 9 | echo "*********************************************************************" |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 10 | |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 11 | # This script exits on an error so that errors don't compound and you see |
| 12 | # only the first error that occured. |
| 13 | set -o errexit |
| 14 | |
| 15 | # Print the commands being run so that we can see the command that triggers |
| 16 | # an error. It is also useful for following allowing as the install occurs. |
| 17 | set -o xtrace |
| 18 | |
| 19 | |
| 20 | # Settings |
| 21 | # ======== |
| 22 | |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 23 | # Keep track of the current directory |
| 24 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) |
| 25 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 26 | |
| 27 | # Import common functions |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 28 | source $TOP_DIR/functions |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 29 | |
| 30 | # Import configuration |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 31 | source $TOP_DIR/openrc |
| 32 | |
| 33 | # Import exercise configuration |
| 34 | source $TOP_DIR/exerciserc |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 35 | |
Chmouel Boudjnah | 408b009 | 2012-03-15 23:21:55 +0000 | [diff] [blame] | 36 | # If swift is not enabled we exit with exitcode 55 which mean |
| 37 | # exercise is skipped. |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame^] | 38 | is_service_enabled s-proxy || exit 55 |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 39 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 40 | # Container name |
| 41 | CONTAINER=ex-swift |
| 42 | |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 43 | |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 44 | # Testing Swift |
| 45 | # ============= |
| 46 | |
| 47 | # Check if we have to swift via keystone |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 48 | swift stat || die $LINENO "Failure geting status" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 49 | |
| 50 | # We start by creating a test container |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 51 | swift post $CONTAINER || die $LINENO "Failure creating container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 52 | |
| 53 | # add some files into it. |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 54 | swift upload $CONTAINER /etc/issue || die $LINENO "Failure uploading file to container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 55 | |
| 56 | # list them |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 57 | swift list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER" |
Todd Willey | 3e6ec23 | 2011-11-04 12:23:35 -0400 | [diff] [blame] | 58 | |
| 59 | # And we may want to delete them now that we have tested that |
| 60 | # everything works. |
Nachi Ueno | 07115eb | 2013-02-26 12:38:18 -0800 | [diff] [blame] | 61 | swift delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER" |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 62 | |
| 63 | set +o xtrace |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 64 | echo "*********************************************************************" |
| 65 | echo "SUCCESS: End DevStack Exercise: $0" |
| 66 | echo "*********************************************************************" |