blob: b380968da8dcdb33a755d552f2954fe20178de1c [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
igor01acdab2016-07-29 13:11:53 +020016# an error. It is also useful for following as the install occurs.
Dean Troyerda85cda2013-02-15 11:07:14 -060017set -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
Sean Dague7580a0c2016-02-17 06:23:36 -050046export x_PROJECT_NAME=$OS_PROJECT_NAME
Dean Troyer4d883472012-03-13 23:56:49 -050047export 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
Sean Dague7580a0c2016-02-17 06:23:36 -050052unset OS_PROJECT_NAME
Dean Troyer4d883472012-03-13 23:56:49 -050053unset OS_USERNAME
54unset OS_PASSWORD
55unset OS_AUTH_URL
56
57# Common authentication args
Sean Dague7580a0c2016-02-17 06:23:36 -050058PROJECT_ARG="--os-project-name=$x_PROJECT_NAME"
Dean Troyer526b79f2013-11-22 11:30:44 -060059ARGS="--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"
Sean Dague7580a0c2016-02-17 06:23:36 -050071 if openstack $PROJECT_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"
Dean Troyer4d883472012-03-13 23:56:49 -050086 else
87 # Test OSAPI
88 echo -e "\nTest Nova"
Sean Dague7580a0c2016-02-17 06:23:36 -050089 if nova $PROJECT_ARG $ARGS flavor-list; then
Dean Troyer4d883472012-03-13 23:56:49 -050090 STATUS_NOVA="Succeeded"
91 else
92 STATUS_NOVA="Failed"
93 RETURN=1
94 fi
95 fi
96fi
97
Dean Troyerda85cda2013-02-15 11:07:14 -060098# Cinder client
99# -------------
100
101if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500102 if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600103 STATUS_CINDER="Skipped"
104 else
105 echo -e "\nTest Cinder"
Sean Dague7580a0c2016-02-17 06:23:36 -0500106 if cinder $PROJECT_ARG $ARGS list; then
Dean Troyerda85cda2013-02-15 11:07:14 -0600107 STATUS_CINDER="Succeeded"
108 else
109 STATUS_CINDER="Failed"
110 RETURN=1
111 fi
112 fi
113fi
114
Dean Troyer4d883472012-03-13 23:56:49 -0500115# Glance client
116# -------------
117
118if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500119 if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500120 STATUS_GLANCE="Skipped"
121 else
122 echo -e "\nTest Glance"
Sean Dague7580a0c2016-02-17 06:23:36 -0500123 if openstack $PROJECT_ARG $ARGS image list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500124 STATUS_GLANCE="Succeeded"
125 else
126 STATUS_GLANCE="Failed"
127 RETURN=1
128 fi
129 fi
130fi
131
132# Swift client
133# ------------
134
Chmouel Boudjnah0c3a5582013-03-06 10:58:33 +0100135if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then
Dean Troyercc6b4432013-04-08 15:38:03 -0500136 if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then
Dean Troyer4d883472012-03-13 23:56:49 -0500137 STATUS_SWIFT="Skipped"
138 else
139 echo -e "\nTest Swift"
Sean Dague7580a0c2016-02-17 06:23:36 -0500140 if swift $PROJECT_ARG $ARGS stat; then
Dean Troyer4d883472012-03-13 23:56:49 -0500141 STATUS_SWIFT="Succeeded"
142 else
143 STATUS_SWIFT="Failed"
144 RETURN=1
145 fi
146 fi
147fi
148
Dean Troyerda85cda2013-02-15 11:07:14 -0600149set +o xtrace
150
Dean Troyercc6b4432013-04-08 15:38:03 -0500151
Dean Troyer4d883472012-03-13 23:56:49 -0500152# Results
Dean Troyercc6b4432013-04-08 15:38:03 -0500153# =======
Dean Troyer4d883472012-03-13 23:56:49 -0500154
Ian Wienandaee18c72014-02-21 15:35:08 +1100155function report {
Dean Troyer4d883472012-03-13 23:56:49 -0500156 if [[ -n "$2" ]]; then
157 echo "$1: $2"
158 fi
159}
160
161echo -e "\n"
162report "Keystone" $STATUS_KEYSTONE
163report "Nova" $STATUS_NOVA
Dean Troyerda85cda2013-02-15 11:07:14 -0600164report "Cinder" $STATUS_CINDER
Dean Troyer4d883472012-03-13 23:56:49 -0500165report "Glance" $STATUS_GLANCE
166report "Swift" $STATUS_SWIFT
167
Dean Troyer83480532012-09-12 14:45:48 -0500168if (( $RETURN == 0 )); then
169 echo "*********************************************************************"
170 echo "SUCCESS: End DevStack Exercise: $0"
171 echo "*********************************************************************"
172fi
Dean Troyer4d883472012-03-13 23:56:49 -0500173
174exit $RETURN