blob: 4a41e0f1edc0e0bd2036fd012a4889971cc50785 [file] [log] [blame]
Todd Willey3e6ec232011-11-04 12:23:35 -04001#!/usr/bin/env bash
2
Dean Troyer27e32692012-03-16 16:16:56 -05003# **swift.sh**
4
Steve Martinellibbe59ed2015-10-21 00:47:43 -04005# Test swift via the ``python-openstackclient`` command line
Todd Willey3e6ec232011-11-04 12:23:35 -04006
Dean Troyer27e32692012-03-16 16:16:56 -05007echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -06008echo "Begin DevStack Exercise: $0"
Dean Troyer27e32692012-03-16 16:16:56 -05009echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -060010
Todd Willey3e6ec232011-11-04 12:23:35 -040011# This script exits on an error so that errors don't compound and you see
Joe Gordon46400262013-06-30 04:32:27 -070012# only the first error that occurred.
Todd Willey3e6ec232011-11-04 12:23:35 -040013set -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.
17set -o xtrace
18
19
20# Settings
21# ========
22
Dean Troyer51fb4542012-03-09 22:21:59 -060023# Keep track of the current directory
24EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
25TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
Dean Troyer489bd2a2012-03-02 10:44:29 -060026
27# Import common functions
Dean Troyer51fb4542012-03-09 22:21:59 -060028source $TOP_DIR/functions
Dean Troyer489bd2a2012-03-02 10:44:29 -060029
30# Import configuration
Dean Troyer51fb4542012-03-09 22:21:59 -060031source $TOP_DIR/openrc
32
33# Import exercise configuration
34source $TOP_DIR/exerciserc
Dean Troyer489bd2a2012-03-02 10:44:29 -060035
Chmouel Boudjnah408b0092012-03-15 23:21:55 +000036# If swift is not enabled we exit with exitcode 55 which mean
37# exercise is skipped.
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +010038is_service_enabled s-proxy || exit 55
Todd Willey3e6ec232011-11-04 12:23:35 -040039
Dean Troyerda85cda2013-02-15 11:07:14 -060040# Container name
41CONTAINER=ex-swift
Steve Martinellibbe59ed2015-10-21 00:47:43 -040042OBJECT=/etc/issue
Dean Troyerda85cda2013-02-15 11:07:14 -060043
Dean Troyerad101762012-06-27 22:04:40 -050044
Todd Willey3e6ec232011-11-04 12:23:35 -040045# Testing Swift
46# =============
47
48# Check if we have to swift via keystone
Steve Martinellibbe59ed2015-10-21 00:47:43 -040049openstack object store account show || die $LINENO "Failure getting account status"
Todd Willey3e6ec232011-11-04 12:23:35 -040050
51# We start by creating a test container
Steve Martinellibf1b8ed2014-10-06 03:36:20 -040052openstack container create $CONTAINER || die $LINENO "Failure creating container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040053
Steve Martinellibbe59ed2015-10-21 00:47:43 -040054# add a file into it.
55openstack object create $CONTAINER $OBJECT || die $LINENO "Failure uploading file to container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040056
Steve Martinellibbe59ed2015-10-21 00:47:43 -040057# list the objects
Steve Martinellibf1b8ed2014-10-06 03:36:20 -040058openstack object list $CONTAINER || die $LINENO "Failure listing contents of container $CONTAINER"
Todd Willey3e6ec232011-11-04 12:23:35 -040059
Steve Martinellibbe59ed2015-10-21 00:47:43 -040060# delete the object first
61openstack object delete $CONTAINER $OBJECT || die $LINENO "Failure deleting object $OBJECT in container $CONTAINER"
62
63# delete the container
64openstack container delete $CONTAINER || die $LINENO "Failure deleting container $CONTAINER"
Dean Troyer489bd2a2012-03-02 10:44:29 -060065
66set +o xtrace
Dean Troyer27e32692012-03-16 16:16:56 -050067echo "*********************************************************************"
68echo "SUCCESS: End DevStack Exercise: $0"
69echo "*********************************************************************"