blob: af2c4c24891b6d8b6baffd8b1e32527c377032a4 [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 Troyer27e32692012-03-16 16:16:56 -05005echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -06006echo "Begin DevStack Exercise: $0"
Dean Troyer27e32692012-03-16 16:16:56 -05007echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -06008
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
Dean Troyer51fb4542012-03-09 22:21:59 -060025# Import exercise configuration
26source $TOP_DIR/exerciserc
27
Dean Troyer10670d12012-01-24 11:26:15 -060028# Unset all of the known NOVA_ vars
29unset NOVA_API_KEY
30unset NOVA_ENDPOINT_NAME
31unset NOVA_PASSWORD
32unset NOVA_PROJECT_ID
33unset NOVA_REGION_NAME
34unset NOVA_URL
35unset NOVA_USERNAME
36unset NOVA_VERSION
37
Dean Troyer10670d12012-01-24 11:26:15 -060038for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do
39 is_set $i
40 if [[ $? -ne 0 ]]; then
Dean Troyer489bd2a2012-03-02 10:44:29 -060041 echo "$i expected to be set"
Dean Troyer10670d12012-01-24 11:26:15 -060042 ABORT=1
43 fi
44done
45if [[ -n "$ABORT" ]]; then
46 exit 1
47fi
48
49# Set global return
50RETURN=0
51
52# Keystone client
53# ---------------
54if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
55 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
56 STATUS_KEYSTONE="Skipped"
57 else
Dean Troyer10670d12012-01-24 11:26:15 -060058 echo -e "\nTest Keystone"
Dean Troyer0bd24102012-03-08 00:33:54 -060059 if keystone catalog --service identity; then
Dean Troyer10670d12012-01-24 11:26:15 -060060 STATUS_KEYSTONE="Succeeded"
61 else
62 STATUS_KEYSTONE="Failed"
63 RETURN=1
64 fi
Dean Troyer10670d12012-01-24 11:26:15 -060065 fi
66fi
67
68# Nova client
69# -----------
70
71if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
72 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
73 STATUS_NOVA="Skipped"
Dean Troyer0bd24102012-03-08 00:33:54 -060074 STATUS_EC2="Skipped"
Dean Troyer10670d12012-01-24 11:26:15 -060075 else
Dean Troyer0bd24102012-03-08 00:33:54 -060076 # Test OSAPI
Dean Troyer10670d12012-01-24 11:26:15 -060077 echo -e "\nTest Nova"
78 if nova flavor-list; then
79 STATUS_NOVA="Succeeded"
80 else
81 STATUS_NOVA="Failed"
82 RETURN=1
83 fi
Dean Troyer0bd24102012-03-08 00:33:54 -060084
85 # Test EC2 API
86 echo -e "\nTest EC2"
87 # Get EC2 creds
88 source $TOP_DIR/eucarc
89
90 if euca-describe-images; then
91 STATUS_EC2="Succeeded"
92 else
93 STATUS_EC2="Failed"
94 RETURN=1
95 fi
96
97 # Clean up side effects
98 unset NOVA_VERSION
Dean Troyer10670d12012-01-24 11:26:15 -060099 fi
100fi
101
102# Glance client
103# -------------
104
105if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
106 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
107 STATUS_GLANCE="Skipped"
108 else
Dean Troyer10670d12012-01-24 11:26:15 -0600109 echo -e "\nTest Glance"
110 if glance index; then
111 STATUS_GLANCE="Succeeded"
112 else
113 STATUS_GLANCE="Failed"
114 RETURN=1
115 fi
116 fi
117fi
118
119# Swift client
120# ------------
121
122if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
123 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
124 STATUS_SWIFT="Skipped"
125 else
126 echo -e "\nTest Swift"
Dean Troyer80756ea2012-02-01 18:01:01 -0600127 if swift stat; then
Dean Troyer10670d12012-01-24 11:26:15 -0600128 STATUS_SWIFT="Succeeded"
129 else
130 STATUS_SWIFT="Failed"
131 RETURN=1
132 fi
133 fi
134fi
135
136# Results
137# -------
138
139function report() {
140 if [[ -n "$2" ]]; then
141 echo "$1: $2"
142 fi
143}
144
145echo -e "\n"
146report "Keystone" $STATUS_KEYSTONE
147report "Nova" $STATUS_NOVA
Dean Troyer0bd24102012-03-08 00:33:54 -0600148report "EC2" $STATUS_EC2
Dean Troyer10670d12012-01-24 11:26:15 -0600149report "Glance" $STATUS_GLANCE
150report "Swift" $STATUS_SWIFT
151
Dean Troyer27e32692012-03-16 16:16:56 -0500152echo "*********************************************************************"
153echo "SUCCESS: End DevStack Exercise: $0"
154echo "*********************************************************************"
Dean Troyer489bd2a2012-03-02 10:44:29 -0600155
Dean Troyer10670d12012-01-24 11:26:15 -0600156exit $RETURN