blob: 2f85d98d8f93840cda37ef09e7a4c4d9234121b6 [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
Joe Gordon46400262013-06-30 04:32:27 -07005# Test OpenStack client authentication arguments handling
Dean Troyer4d883472012-03-13 23:56:49 -05006
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
Joe Gordon46400262013-06-30 04:32:27 -070012# only the first error that occurred.
Dean Troyerda85cda2013-02-15 11:07:14 -060013set -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
Dean Troyer526b79f2013-11-22 11:30:44 -060059TENANT_ARG="--os-tenant-name=$x_TENANT_NAME"
60ARGS="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
Dean Troyer4d883472012-03-13 23:56:49 -050061
62# Set global return
63RETURN=0
64
65# Keystone client
66# ---------------
67if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -050068 if [[ "$SKIP_EXERCISES" =~ "key" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -050069 STATUS_KEYSTONE="Skipped"
70 else
71 echo -e "\nTest Keystone"
Dean Troyer526b79f2013-11-22 11:30:44 -060072 if keystone $TENANT_ARG $ARGS catalog --service identity; then
Dean Troyer4d883472012-03-13 23:56:49 -050073 STATUS_KEYSTONE="Succeeded"
74 else
75 STATUS_KEYSTONE="Failed"
76 RETURN=1
77 fi
78 fi
79fi
80
81# Nova client
82# -----------
83
84if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -050085 if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -050086 STATUS_NOVA="Skipped"
87 STATUS_EC2="Skipped"
88 else
89 # Test OSAPI
90 echo -e "\nTest Nova"
Dean Troyer526b79f2013-11-22 11:30:44 -060091 if nova $TENANT_ARG $ARGS flavor-list; then
Dean Troyer4d883472012-03-13 23:56:49 -050092 STATUS_NOVA="Succeeded"
93 else
94 STATUS_NOVA="Failed"
95 RETURN=1
96 fi
97 fi
98fi
99
Dean Troyerda85cda2013-02-15 11:07:14 -0600100# Cinder client
101# -------------
102
103if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500104 if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600105 STATUS_CINDER="Skipped"
106 else
107 echo -e "\nTest Cinder"
Dean Troyer526b79f2013-11-22 11:30:44 -0600108 if cinder $TENANT_ARG $ARGS list; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600109 STATUS_CINDER="Succeeded"
110 else
111 STATUS_CINDER="Failed"
112 RETURN=1
113 fi
114 fi
115fi
116
Dean Troyer4d883472012-03-13 23:56:49 -0500117# Glance client
118# -------------
119
120if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500121 if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500122 STATUS_GLANCE="Skipped"
123 else
124 echo -e "\nTest Glance"
Steve Martinelli5c206c22014-08-02 20:32:31 -0400125 if openstack $TENANT_ARG $ARGS image list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500126 STATUS_GLANCE="Succeeded"
127 else
128 STATUS_GLANCE="Failed"
129 RETURN=1
130 fi
131 fi
132fi
133
134# Swift client
135# ------------
136
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100137if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500138 if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500139 STATUS_SWIFT="Skipped"
140 else
141 echo -e "\nTest Swift"
Dean Troyer526b79f2013-11-22 11:30:44 -0600142 if swift $TENANT_ARG $ARGS stat; then
Dean Troyer4d883472012-03-13 23:56:49 -0500143 STATUS_SWIFT="Succeeded"
144 else
145 STATUS_SWIFT="Failed"
146 RETURN=1
147 fi
148 fi
149fi
150
Dean Troyerda85cda2013-02-15 11:07:14 -0600151set +o xtrace
152
Dean Troyercc6b4432013-04-08 15:38:03 -0500153
Dean Troyer4d883472012-03-13 23:56:49 -0500154# Results
Dean Troyercc6b4432013-04-08 15:38:03 -0500155# =======
Dean Troyer4d883472012-03-13 23:56:49 -0500156
Ian Wienandaee18c72014-02-21 15:35:08 +1100157function report {
Dean Troyer4d883472012-03-13 23:56:49 -0500158 if [[ -n "$2" ]]; then
159 echo "$1: $2"
160 fi
161}
162
163echo -e "\n"
164report "Keystone" $STATUS_KEYSTONE
165report "Nova" $STATUS_NOVA
Dean Troyerda85cda2013-02-15 11:07:14 -0600166report "Cinder" $STATUS_CINDER
Dean Troyer4d883472012-03-13 23:56:49 -0500167report "Glance" $STATUS_GLANCE
168report "Swift" $STATUS_SWIFT
169
Dean Troyer83480532012-09-12 14:45:48 -0500170if (( $RETURN == 0 )); then
171 echo "*********************************************************************"
172 echo "SUCCESS: End DevStack Exercise: $0"
173 echo "*********************************************************************"
174fi
Dean Troyer4d883472012-03-13 23:56:49 -0500175
176exit $RETURN