Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash |
2 | |||||
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 3 | # **client-env.sh** |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 4 | |
Joe Gordon | 4640026 | 2013-06-30 04:32:27 -0700 | [diff] [blame] | 5 | # Test OpenStack client environment variable handling |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 6 | |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 7 | echo "*********************************************************************" |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 8 | echo "Begin DevStack Exercise: $0" |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 9 | echo "*********************************************************************" |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 10 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 11 | # This script exits on an error so that errors don't compound and you see |
Joe Gordon | 4640026 | 2013-06-30 04:32:27 -0700 | [diff] [blame] | 12 | # only the first error that occurred. |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 13 | set -o errexit |
14 | |||||
15 | # Print the commands being run so that we can see the command that triggers | ||||
igor | 01acdab | 2016-07-29 13:11:53 +0200 | [diff] [blame] | 16 | # an error. It is also useful for following as the install occurs. |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 17 | set -o xtrace |
18 | |||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 19 | |
20 | # Settings | ||||
21 | # ======== | ||||
22 | |||||
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 23 | # Keep track of the current directory |
24 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) | ||||
25 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) | ||||
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 26 | |
27 | # Import common functions | ||||
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 28 | source $TOP_DIR/functions |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 29 | |
30 | # Import configuration | ||||
Bob Ball | 8901245 | 2014-05-08 13:35:28 +0100 | [diff] [blame] | 31 | source $TOP_DIR/openrc admin |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 32 | |
Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 33 | # Import exercise configuration |
34 | source $TOP_DIR/exerciserc | ||||
35 | |||||
Dean Troyer | c5dfecd | 2012-09-08 14:20:43 -0500 | [diff] [blame] | 36 | # Unset all of the known NOVA_* vars |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 37 | unset NOVA_API_KEY |
38 | unset NOVA_ENDPOINT_NAME | ||||
39 | unset NOVA_PASSWORD | ||||
40 | unset NOVA_PROJECT_ID | ||||
41 | unset NOVA_REGION_NAME | ||||
42 | unset NOVA_URL | ||||
43 | unset NOVA_USERNAME | ||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 44 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 45 | for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do |
46 | is_set $i | ||||
47 | if [[ $? -ne 0 ]]; then | ||||
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 48 | echo "$i expected to be set" |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 49 | ABORT=1 |
50 | fi | ||||
51 | done | ||||
52 | if [[ -n "$ABORT" ]]; then | ||||
53 | exit 1 | ||||
54 | fi | ||||
55 | |||||
56 | # Set global return | ||||
57 | RETURN=0 | ||||
58 | |||||
59 | # Keystone client | ||||
60 | # --------------- | ||||
61 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then | ||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 62 | if [[ "$SKIP_EXERCISES" =~ "key" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 63 | STATUS_KEYSTONE="Skipped" |
64 | else | ||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 65 | echo -e "\nTest Keystone" |
Steve Martinelli | 2f6c30b | 2014-03-13 23:32:46 -0500 | [diff] [blame] | 66 | if openstack endpoint show identity; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 67 | STATUS_KEYSTONE="Succeeded" |
68 | else | ||||
69 | STATUS_KEYSTONE="Failed" | ||||
70 | RETURN=1 | ||||
71 | fi | ||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 72 | fi |
73 | fi | ||||
74 | |||||
75 | # Nova client | ||||
76 | # ----------- | ||||
77 | |||||
78 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then | ||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 79 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 80 | STATUS_NOVA="Skipped" |
81 | else | ||||
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 82 | # Test OSAPI |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 83 | echo -e "\nTest Nova" |
84 | if nova flavor-list; then | ||||
85 | STATUS_NOVA="Succeeded" | ||||
86 | else | ||||
87 | STATUS_NOVA="Failed" | ||||
88 | RETURN=1 | ||||
89 | fi | ||||
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 90 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 91 | fi |
92 | fi | ||||
93 | |||||
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 94 | # Cinder client |
95 | # ------------- | ||||
96 | |||||
97 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then | ||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 98 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 99 | STATUS_CINDER="Skipped" |
100 | else | ||||
101 | echo -e "\nTest Cinder" | ||||
102 | if cinder list; then | ||||
103 | STATUS_CINDER="Succeeded" | ||||
104 | else | ||||
105 | STATUS_CINDER="Failed" | ||||
106 | RETURN=1 | ||||
107 | fi | ||||
108 | fi | ||||
109 | fi | ||||
110 | |||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 111 | # Glance client |
112 | # ------------- | ||||
113 | |||||
114 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then | ||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 115 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 116 | STATUS_GLANCE="Skipped" |
117 | else | ||||
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 118 | echo -e "\nTest Glance" |
Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 119 | if openstack image list; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 120 | STATUS_GLANCE="Succeeded" |
121 | else | ||||
122 | STATUS_GLANCE="Failed" | ||||
123 | RETURN=1 | ||||
124 | fi | ||||
125 | fi | ||||
126 | fi | ||||
127 | |||||
128 | # Swift client | ||||
129 | # ------------ | ||||
130 | |||||
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 131 | |
132 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then | ||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 133 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 134 | STATUS_SWIFT="Skipped" |
135 | else | ||||
136 | echo -e "\nTest Swift" | ||||
Dean Troyer | 80756ea | 2012-02-01 18:01:01 -0600 | [diff] [blame] | 137 | if swift stat; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 138 | STATUS_SWIFT="Succeeded" |
139 | else | ||||
140 | STATUS_SWIFT="Failed" | ||||
141 | RETURN=1 | ||||
142 | fi | ||||
143 | fi | ||||
144 | fi | ||||
145 | |||||
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 146 | set +o xtrace |
147 | |||||
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 148 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 149 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 150 | # ======= |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 151 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 152 | function report { |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 153 | if [[ -n "$2" ]]; then |
154 | echo "$1: $2" | ||||
155 | fi | ||||
156 | } | ||||
157 | |||||
158 | echo -e "\n" | ||||
159 | report "Keystone" $STATUS_KEYSTONE | ||||
160 | report "Nova" $STATUS_NOVA | ||||
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 161 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 162 | report "Glance" $STATUS_GLANCE |
163 | report "Swift" $STATUS_SWIFT | ||||
164 | |||||
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 165 | if (( $RETURN == 0 )); then |
166 | echo "*********************************************************************" | ||||
167 | echo "SUCCESS: End DevStack Exercise: $0" | ||||
168 | echo "*********************************************************************" | ||||
169 | fi | ||||
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 170 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 171 | exit $RETURN |