blob: d4ba702e051ebdb16d6d33732dc3fc88fa795386 [file] [log] [blame]
Dean Troyer10670d12012-01-24 11:26:15 -06001#!/usr/bin/env bash
2
3# Test OpenStack client enviroment variable handling
4
Dean Troyer489bd2a2012-03-02 10:44:29 -06005echo "**************************************************"
6echo "Begin DevStack Exercise: $0"
7echo "**************************************************"
8
Dean Troyer10670d12012-01-24 11:26:15 -06009# Verify client workage
10VERIFY=${1:-""}
11
12# Settings
13# ========
14
Dean Troyer0bd24102012-03-08 00:33:54 -060015# Keep track of the current directory
16EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
17TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
Dean Troyer489bd2a2012-03-02 10:44:29 -060018
19# Import common functions
Dean Troyer0bd24102012-03-08 00:33:54 -060020source $TOP_DIR/functions
Dean Troyer489bd2a2012-03-02 10:44:29 -060021
22# Import configuration
Dean Troyer0bd24102012-03-08 00:33:54 -060023source $TOP_DIR/openrc
Dean Troyer10670d12012-01-24 11:26:15 -060024
25# Unset all of the known NOVA_ vars
26unset NOVA_API_KEY
27unset NOVA_ENDPOINT_NAME
28unset NOVA_PASSWORD
29unset NOVA_PROJECT_ID
30unset NOVA_REGION_NAME
31unset NOVA_URL
32unset NOVA_USERNAME
33unset NOVA_VERSION
34
Dean Troyer10670d12012-01-24 11:26:15 -060035for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do
36 is_set $i
37 if [[ $? -ne 0 ]]; then
Dean Troyer489bd2a2012-03-02 10:44:29 -060038 echo "$i expected to be set"
Dean Troyer10670d12012-01-24 11:26:15 -060039 ABORT=1
40 fi
41done
42if [[ -n "$ABORT" ]]; then
43 exit 1
44fi
45
46# Set global return
47RETURN=0
48
49# Keystone client
50# ---------------
51if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
52 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
53 STATUS_KEYSTONE="Skipped"
54 else
Dean Troyer10670d12012-01-24 11:26:15 -060055 echo -e "\nTest Keystone"
Dean Troyer0bd24102012-03-08 00:33:54 -060056 if keystone catalog --service identity; then
Dean Troyer10670d12012-01-24 11:26:15 -060057 STATUS_KEYSTONE="Succeeded"
58 else
59 STATUS_KEYSTONE="Failed"
60 RETURN=1
61 fi
Dean Troyer10670d12012-01-24 11:26:15 -060062 fi
63fi
64
65# Nova client
66# -----------
67
68if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
69 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
70 STATUS_NOVA="Skipped"
Dean Troyer0bd24102012-03-08 00:33:54 -060071 STATUS_EC2="Skipped"
Dean Troyer10670d12012-01-24 11:26:15 -060072 else
Dean Troyer0bd24102012-03-08 00:33:54 -060073 # Test OSAPI
Dean Troyer10670d12012-01-24 11:26:15 -060074 echo -e "\nTest Nova"
75 if nova flavor-list; then
76 STATUS_NOVA="Succeeded"
77 else
78 STATUS_NOVA="Failed"
79 RETURN=1
80 fi
Dean Troyer0bd24102012-03-08 00:33:54 -060081
82 # Test EC2 API
83 echo -e "\nTest EC2"
84 # Get EC2 creds
85 source $TOP_DIR/eucarc
86
87 if euca-describe-images; then
88 STATUS_EC2="Succeeded"
89 else
90 STATUS_EC2="Failed"
91 RETURN=1
92 fi
93
94 # Clean up side effects
95 unset NOVA_VERSION
Dean Troyer10670d12012-01-24 11:26:15 -060096 fi
97fi
98
99# Glance client
100# -------------
101
102if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
103 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
104 STATUS_GLANCE="Skipped"
105 else
Dean Troyer10670d12012-01-24 11:26:15 -0600106 echo -e "\nTest Glance"
107 if glance index; then
108 STATUS_GLANCE="Succeeded"
109 else
110 STATUS_GLANCE="Failed"
111 RETURN=1
112 fi
113 fi
114fi
115
116# Swift client
117# ------------
118
119if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
120 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
121 STATUS_SWIFT="Skipped"
122 else
123 echo -e "\nTest Swift"
Dean Troyer80756ea2012-02-01 18:01:01 -0600124 if swift stat; then
Dean Troyer10670d12012-01-24 11:26:15 -0600125 STATUS_SWIFT="Succeeded"
126 else
127 STATUS_SWIFT="Failed"
128 RETURN=1
129 fi
130 fi
131fi
132
133# Results
134# -------
135
136function report() {
137 if [[ -n "$2" ]]; then
138 echo "$1: $2"
139 fi
140}
141
142echo -e "\n"
143report "Keystone" $STATUS_KEYSTONE
144report "Nova" $STATUS_NOVA
Dean Troyer0bd24102012-03-08 00:33:54 -0600145report "EC2" $STATUS_EC2
Dean Troyer10670d12012-01-24 11:26:15 -0600146report "Glance" $STATUS_GLANCE
147report "Swift" $STATUS_SWIFT
148
Dean Troyer489bd2a2012-03-02 10:44:29 -0600149echo "**************************************************"
150echo "End DevStack Exercise: $0"
151echo "**************************************************"
152
Dean Troyer10670d12012-01-24 11:26:15 -0600153exit $RETURN