blob: b3e2ad8d4ab50e79886b8d42f68f02fe423a38d9 [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 Troyerad101762012-06-27 22:04:40 -050011
Dean Troyer4d883472012-03-13 23:56:49 -050012# Settings
13# ========
14
15# Keep track of the current directory
16EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
17TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
18
19# Import common functions
20source $TOP_DIR/functions
21
22# Import configuration
23source $TOP_DIR/openrc
24
25# Import exercise configuration
26source $TOP_DIR/exerciserc
27
Dean Troyerc5dfecd2012-09-08 14:20:43 -050028# Unset all of the known NOVA_* vars
Dean Troyer4d883472012-03-13 23:56:49 -050029unset 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
38# Save the known variables for later
39export x_TENANT_NAME=$OS_TENANT_NAME
40export x_USERNAME=$OS_USERNAME
41export x_PASSWORD=$OS_PASSWORD
42export x_AUTH_URL=$OS_AUTH_URL
43
Dean Troyerad101762012-06-27 22:04:40 -050044# Unset the usual variables to force argument processing
Dean Troyer4d883472012-03-13 23:56:49 -050045unset OS_TENANT_NAME
46unset OS_USERNAME
47unset OS_PASSWORD
48unset OS_AUTH_URL
49
50# Common authentication args
51TENANT_ARG="--os_tenant_name=$x_TENANT_NAME"
Dean Troyer45495252012-04-13 13:16:38 -050052TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME"
Dean Troyer4d883472012-03-13 23:56:49 -050053ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL"
Dean Troyer45495252012-04-13 13:16:38 -050054ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
Dean Troyer4d883472012-03-13 23:56:49 -050055
56# Set global return
57RETURN=0
58
59# Keystone client
60# ---------------
61if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
62 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
63 STATUS_KEYSTONE="Skipped"
64 else
65 echo -e "\nTest Keystone"
66 if keystone $TENANT_ARG $ARGS catalog --service identity; then
67 STATUS_KEYSTONE="Succeeded"
68 else
69 STATUS_KEYSTONE="Failed"
70 RETURN=1
71 fi
72 fi
73fi
74
75# Nova client
76# -----------
77
78if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
79 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
80 STATUS_NOVA="Skipped"
81 STATUS_EC2="Skipped"
82 else
83 # Test OSAPI
84 echo -e "\nTest Nova"
85 if nova $TENANT_ARG $ARGS flavor-list; then
86 STATUS_NOVA="Succeeded"
87 else
88 STATUS_NOVA="Failed"
89 RETURN=1
90 fi
91 fi
92fi
93
94# Glance client
95# -------------
96
97if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
98 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
99 STATUS_GLANCE="Skipped"
100 else
101 echo -e "\nTest Glance"
Dean Troyer45495252012-04-13 13:16:38 -0500102 if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500103 STATUS_GLANCE="Succeeded"
104 else
105 STATUS_GLANCE="Failed"
106 RETURN=1
107 fi
108 fi
109fi
110
111# Swift client
112# ------------
113
114if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
115 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
116 STATUS_SWIFT="Skipped"
117 else
118 echo -e "\nTest Swift"
Armando Migliaccioea6b2d32012-07-04 16:24:47 +0100119 if swift $TENANT_ARG $ARGS stat; then
Dean Troyer4d883472012-03-13 23:56:49 -0500120 STATUS_SWIFT="Succeeded"
121 else
122 STATUS_SWIFT="Failed"
123 RETURN=1
124 fi
125 fi
126fi
127
128# Results
129# -------
130
131function report() {
132 if [[ -n "$2" ]]; then
133 echo "$1: $2"
134 fi
135}
136
137echo -e "\n"
138report "Keystone" $STATUS_KEYSTONE
139report "Nova" $STATUS_NOVA
140report "Glance" $STATUS_GLANCE
141report "Swift" $STATUS_SWIFT
142
Dean Troyer83480532012-09-12 14:45:48 -0500143if (( $RETURN == 0 )); then
144 echo "*********************************************************************"
145 echo "SUCCESS: End DevStack Exercise: $0"
146 echo "*********************************************************************"
147fi
Dean Troyer4d883472012-03-13 23:56:49 -0500148
149exit $RETURN