blob: 1d7d5b6cc8fabb0a81aa3179d4443fded21e5073 [file] [log] [blame]
Dean Troyer4d883472012-03-13 23:56:49 -05001#!/usr/bin/env bash
2
3# Test OpenStack client authentication aguemnts handling
4
Dean Troyer27e32692012-03-16 16:16:56 -05005echo "*********************************************************************"
Dean Troyer4d883472012-03-13 23:56:49 -05006echo "Begin DevStack Exercise: $0"
Dean Troyer27e32692012-03-16 16:16:56 -05007echo "*********************************************************************"
Dean Troyer4d883472012-03-13 23:56:49 -05008
9# Settings
10# ========
11
12# Keep track of the current directory
13EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
14TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
15
16# Import common functions
17source $TOP_DIR/functions
18
19# Import configuration
20source $TOP_DIR/openrc
21
22# Import exercise configuration
23source $TOP_DIR/exerciserc
24
25# Unset all of the known NOVA_ vars
26unset NOVA_API_KEY
27unset NOVA_ENDPOINT_NAME
28unset NOVA_PASSWORD
29unset NOVA_PROJECT_ID
30unset NOVA_REGION_NAME
31unset NOVA_URL
32unset NOVA_USERNAME
33unset NOVA_VERSION
34
35# Save the known variables for later
36export x_TENANT_NAME=$OS_TENANT_NAME
37export x_USERNAME=$OS_USERNAME
38export x_PASSWORD=$OS_PASSWORD
39export x_AUTH_URL=$OS_AUTH_URL
40
41#Unset the usual variables to force argument processing
42unset OS_TENANT_NAME
43unset OS_USERNAME
44unset OS_PASSWORD
45unset OS_AUTH_URL
46
47# Common authentication args
48TENANT_ARG="--os_tenant_name=$x_TENANT_NAME"
Dean Troyer45495252012-04-13 13:16:38 -050049TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME"
Dean Troyer4d883472012-03-13 23:56:49 -050050ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL"
Dean Troyer45495252012-04-13 13:16:38 -050051ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL"
Dean Troyer4d883472012-03-13 23:56:49 -050052
53# Set global return
54RETURN=0
55
56# Keystone client
57# ---------------
58if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
59 if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then
60 STATUS_KEYSTONE="Skipped"
61 else
62 echo -e "\nTest Keystone"
63 if keystone $TENANT_ARG $ARGS catalog --service identity; then
64 STATUS_KEYSTONE="Succeeded"
65 else
66 STATUS_KEYSTONE="Failed"
67 RETURN=1
68 fi
69 fi
70fi
71
72# Nova client
73# -----------
74
75if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
76 if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then
77 STATUS_NOVA="Skipped"
78 STATUS_EC2="Skipped"
79 else
80 # Test OSAPI
81 echo -e "\nTest Nova"
82 if nova $TENANT_ARG $ARGS flavor-list; then
83 STATUS_NOVA="Succeeded"
84 else
85 STATUS_NOVA="Failed"
86 RETURN=1
87 fi
88 fi
89fi
90
91# Glance client
92# -------------
93
94if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
95 if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then
96 STATUS_GLANCE="Skipped"
97 else
98 echo -e "\nTest Glance"
Dean Troyer45495252012-04-13 13:16:38 -050099 if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then
Dean Troyer4d883472012-03-13 23:56:49 -0500100 STATUS_GLANCE="Succeeded"
101 else
102 STATUS_GLANCE="Failed"
103 RETURN=1
104 fi
105 fi
106fi
107
108# Swift client
109# ------------
110
111if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then
112 if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then
113 STATUS_SWIFT="Skipped"
114 else
115 echo -e "\nTest Swift"
116 if swift $ARGS stat; then
117 STATUS_SWIFT="Succeeded"
118 else
119 STATUS_SWIFT="Failed"
120 RETURN=1
121 fi
122 fi
123fi
124
125# Results
126# -------
127
128function report() {
129 if [[ -n "$2" ]]; then
130 echo "$1: $2"
131 fi
132}
133
134echo -e "\n"
135report "Keystone" $STATUS_KEYSTONE
136report "Nova" $STATUS_NOVA
137report "Glance" $STATUS_GLANCE
138report "Swift" $STATUS_SWIFT
139
Dean Troyer27e32692012-03-16 16:16:56 -0500140echo "*********************************************************************"
141echo "SUCCESS: End DevStack Exercise: $0"
142echo "*********************************************************************"
Dean Troyer4d883472012-03-13 23:56:49 -0500143
144exit $RETURN