blob: 7cfef1c807779476c3ec28dc4cf79b436ea0900d [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
Dean Troyer4d883472012-03-13 23:56:49 -050044
45# Save the known variables for later
46export x_TENANT_NAME=$OS_TENANT_NAME
47export x_USERNAME=$OS_USERNAME
48export x_PASSWORD=$OS_PASSWORD
49export x_AUTH_URL=$OS_AUTH_URL
50
Dean Troyerad101762012-06-27 22:04:40 -050051# Unset the usual variables to force argument processing
Dean Troyer4d883472012-03-13 23:56:49 -050052unset OS_TENANT_NAME
53unset OS_USERNAME
54unset OS_PASSWORD
55unset OS_AUTH_URL
56
57# Common authentication args
Dean Troyer526b79f2013-11-22 11:30:44 -060058TENANT_ARG="--os-tenant-name=$x_TENANT_NAME"
59ARGS="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
Dean Troyer4d883472012-03-13 23:56:49 -050060
61# Set global return
62RETURN=0
63
64# Keystone client
65# ---------------
66if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -050067 if [[ "$SKIP_EXERCISES" =~ "key" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -050068 STATUS_KEYSTONE="Skipped"
69 else
70 echo -e "\nTest Keystone"
Peter Stachowski9a808922015-04-08 19:48:09 +000071 if openstack $TENANT_ARG $ARGS catalog show identity; then
Dean Troyer4d883472012-03-13 23:56:49 -050072 STATUS_KEYSTONE="Succeeded"
73 else
74 STATUS_KEYSTONE="Failed"
75 RETURN=1
76 fi
77 fi
78fi
79
80# Nova client
81# -----------
82
83if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -050084 if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -050085 STATUS_NOVA="Skipped"
86 STATUS_EC2="Skipped"
87 else
88 # Test OSAPI
89 echo -e "\nTest Nova"
Dean Troyer526b79f2013-11-22 11:30:44 -060090 if nova $TENANT_ARG $ARGS flavor-list; then
Dean Troyer4d883472012-03-13 23:56:49 -050091 STATUS_NOVA="Succeeded"
92 else
93 STATUS_NOVA="Failed"
94 RETURN=1
95 fi
96 fi
97fi
98
Dean Troyerda85cda2013-02-15 11:07:14 -060099# Cinder client
100# -------------
101
102if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500103 if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600104 STATUS_CINDER="Skipped"
105 else
106 echo -e "\nTest Cinder"
Dean Troyer526b79f2013-11-22 11:30:44 -0600107 if cinder $TENANT_ARG $ARGS list; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600108 STATUS_CINDER="Succeeded"
109 else
110 STATUS_CINDER="Failed"
111 RETURN=1
112 fi
113 fi
114fi
115
Dean Troyer4d883472012-03-13 23:56:49 -0500116# Glance client
117# -------------
118
119if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500120 if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500121 STATUS_GLANCE="Skipped"
122 else
123 echo -e "\nTest Glance"
Steve Martinelli5c206c22014-08-02 20:32:31 -0400124 if openstack $TENANT_ARG $ARGS image list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500125 STATUS_GLANCE="Succeeded"
126 else
127 STATUS_GLANCE="Failed"
128 RETURN=1
129 fi
130 fi
131fi
132
133# Swift client
134# ------------
135
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100136if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500137 if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500138 STATUS_SWIFT="Skipped"
139 else
140 echo -e "\nTest Swift"
Dean Troyer526b79f2013-11-22 11:30:44 -0600141 if swift $TENANT_ARG $ARGS stat; then
Dean Troyer4d883472012-03-13 23:56:49 -0500142 STATUS_SWIFT="Succeeded"
143 else
144 STATUS_SWIFT="Failed"
145 RETURN=1
146 fi
147 fi
148fi
149
Dean Troyerda85cda2013-02-15 11:07:14 -0600150set +o xtrace
151
Dean Troyercc6b4432013-04-08 15:38:03 -0500152
Dean Troyer4d883472012-03-13 23:56:49 -0500153# Results
Dean Troyercc6b4432013-04-08 15:38:03 -0500154# =======
Dean Troyer4d883472012-03-13 23:56:49 -0500155
Ian Wienandaee18c72014-02-21 15:35:08 +1100156function report {
Dean Troyer4d883472012-03-13 23:56:49 -0500157 if [[ -n "$2" ]]; then
158 echo "$1: $2"
159 fi
160}
161
162echo -e "\n"
163report "Keystone" $STATUS_KEYSTONE
164report "Nova" $STATUS_NOVA
Dean Troyerda85cda2013-02-15 11:07:14 -0600165report "Cinder" $STATUS_CINDER
Dean Troyer4d883472012-03-13 23:56:49 -0500166report "Glance" $STATUS_GLANCE
167report "Swift" $STATUS_SWIFT
168
Dean Troyer83480532012-09-12 14:45:48 -0500169if (( $RETURN == 0 )); then
170 echo "*********************************************************************"
171 echo "SUCCESS: End DevStack Exercise: $0"
172 echo "*********************************************************************"
173fi
Dean Troyer4d883472012-03-13 23:56:49 -0500174
175exit $RETURN