blob: 894da74263f679117faaae7a352b2b0b120b0cdd [file] [log] [blame]
Dean Troyer4d883472012-03-13 23:56:49 -05001#!/usr/bin/env bash
2
Dean Troyer83480532012-09-12 14:45:48 -05003# **client-args.sh**
Dean Troyerad101762012-06-27 22:04:40 -05004
Dean Troyer4d883472012-03-13 23:56:49 -05005# Test OpenStack client authentication aguemnts handling
6
Dean Troyer27e32692012-03-16 16:16:56 -05007echo "*********************************************************************"
Dean Troyer4d883472012-03-13 23:56:49 -05008echo "Begin DevStack Exercise: $0"
Dean Troyer27e32692012-03-16 16:16:56 -05009echo "*********************************************************************"
Dean Troyer4d883472012-03-13 23:56:49 -050010
Dean Troyerda85cda2013-02-15 11:07:14 -060011# This script exits on an error so that errors don't compound and you see
12# only the first error that occured.
13set -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
Dean Troyerad101762012-06-27 22:04:40 -050019
Dean Troyer4d883472012-03-13 23:56:49 -050020# Settings
21# ========
22
23# Keep track of the current directory
24EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
25TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
26
27# Import common functions
28source $TOP_DIR/functions
29
30# Import configuration
31source $TOP_DIR/openrc
32
33# Import exercise configuration
34source $TOP_DIR/exerciserc
35
Dean Troyerc5dfecd2012-09-08 14:20:43 -050036# Unset all of the known NOVA_* vars
Dean Troyer4d883472012-03-13 23:56:49 -050037unset NOVA_API_KEY
38unset NOVA_ENDPOINT_NAME
39unset NOVA_PASSWORD
40unset NOVA_PROJECT_ID
41unset NOVA_REGION_NAME
42unset NOVA_URL
43unset NOVA_USERNAME
44unset NOVA_VERSION
45
46# Save the known variables for later
47export x_TENANT_NAME=$OS_TENANT_NAME
48export x_USERNAME=$OS_USERNAME
49export x_PASSWORD=$OS_PASSWORD
50export x_AUTH_URL=$OS_AUTH_URL
51
Dean Troyerad101762012-06-27 22:04:40 -050052# Unset the usual variables to force argument processing
Dean Troyer4d883472012-03-13 23:56:49 -050053unset OS_TENANT_NAME
54unset OS_USERNAME
55unset OS_PASSWORD
56unset OS_AUTH_URL
57
58# Common authentication args
59TENANT_ARG="--os_tenant_name=$x_TENANT_NAME"
Dean Troyer45495252012-04-13 13:16:38 -050060TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME"
Dean Troyer4d883472012-03-13 23:56:49 -050061ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL"
Dean Troyer45495252012-04-13 13:16:38 -050062ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
Dean Troyer4d883472012-03-13 23:56:49 -050063
64# Set global return
65RETURN=0
66
67# Keystone client
68# ---------------
69if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
70 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
71 STATUS_KEYSTONE="Skipped"
72 else
73 echo -e "\nTest Keystone"
Dean Troyerda85cda2013-02-15 11:07:14 -060074 if keystone $TENANT_ARG_DASH $ARGS_DASH catalog --service identity; then
Dean Troyer4d883472012-03-13 23:56:49 -050075 STATUS_KEYSTONE="Succeeded"
76 else
77 STATUS_KEYSTONE="Failed"
78 RETURN=1
79 fi
80 fi
81fi
82
83# Nova client
84# -----------
85
86if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
87 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
88 STATUS_NOVA="Skipped"
89 STATUS_EC2="Skipped"
90 else
91 # Test OSAPI
92 echo -e "\nTest Nova"
Dean Troyerda85cda2013-02-15 11:07:14 -060093 if nova $TENANT_ARG_DASH $ARGS_DASH flavor-list; then
Dean Troyer4d883472012-03-13 23:56:49 -050094 STATUS_NOVA="Succeeded"
95 else
96 STATUS_NOVA="Failed"
97 RETURN=1
98 fi
99 fi
100fi
101
Dean Troyerda85cda2013-02-15 11:07:14 -0600102# Cinder client
103# -------------
104
105if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
106 if [[ "$SKIP_EXERCISES" =~ "c-api" ]] ; then
107 STATUS_CINDER="Skipped"
108 else
109 echo -e "\nTest Cinder"
110 if cinder $TENANT_ARG_DASH $ARGS_DASH list; then
111 STATUS_CINDER="Succeeded"
112 else
113 STATUS_CINDER="Failed"
114 RETURN=1
115 fi
116 fi
117fi
118
Dean Troyer4d883472012-03-13 23:56:49 -0500119# Glance client
120# -------------
121
122if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
123 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
124 STATUS_GLANCE="Skipped"
125 else
126 echo -e "\nTest Glance"
Dean Troyer45495252012-04-13 13:16:38 -0500127 if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500128 STATUS_GLANCE="Succeeded"
129 else
130 STATUS_GLANCE="Failed"
131 RETURN=1
132 fi
133 fi
134fi
135
136# Swift client
137# ------------
138
Sean Daguef3fd44c2013-03-04 17:33:35 -0500139if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500140 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
141 STATUS_SWIFT="Skipped"
142 else
143 echo -e "\nTest Swift"
Dean Troyerda85cda2013-02-15 11:07:14 -0600144 if swift $TENANT_ARG_DASH $ARGS_DASH stat; then
Dean Troyer4d883472012-03-13 23:56:49 -0500145 STATUS_SWIFT="Succeeded"
146 else
147 STATUS_SWIFT="Failed"
148 RETURN=1
149 fi
150 fi
151fi
152
Dean Troyerda85cda2013-02-15 11:07:14 -0600153set +o xtrace
154
Dean Troyer4d883472012-03-13 23:56:49 -0500155# Results
156# -------
157
158function report() {
159 if [[ -n "$2" ]]; then
160 echo "$1: $2"
161 fi
162}
163
164echo -e "\n"
165report "Keystone" $STATUS_KEYSTONE
166report "Nova" $STATUS_NOVA
Dean Troyerda85cda2013-02-15 11:07:14 -0600167report "Cinder" $STATUS_CINDER
Dean Troyer4d883472012-03-13 23:56:49 -0500168report "Glance" $STATUS_GLANCE
169report "Swift" $STATUS_SWIFT
170
Dean Troyer83480532012-09-12 14:45:48 -0500171if (( $RETURN == 0 )); then
172 echo "*********************************************************************"
173 echo "SUCCESS: End DevStack Exercise: $0"
174 echo "*********************************************************************"
175fi
Dean Troyer4d883472012-03-13 23:56:49 -0500176
177exit $RETURN