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 |
| 16 | # an error. It is also useful for following allowing as the install occurs. |
| 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 |
| 44 | unset NOVA_VERSION |
| 45 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 46 | for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do |
| 47 | is_set $i |
| 48 | if [[ $? -ne 0 ]]; then |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 49 | echo "$i expected to be set" |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 50 | ABORT=1 |
| 51 | fi |
| 52 | done |
| 53 | if [[ -n "$ABORT" ]]; then |
| 54 | exit 1 |
| 55 | fi |
| 56 | |
| 57 | # Set global return |
| 58 | RETURN=0 |
| 59 | |
| 60 | # Keystone client |
| 61 | # --------------- |
| 62 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 63 | if [[ "$SKIP_EXERCISES" =~ "key" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 64 | STATUS_KEYSTONE="Skipped" |
| 65 | else |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 66 | echo -e "\nTest Keystone" |
Steve Martinelli | 2f6c30b | 2014-03-13 23:32:46 -0500 | [diff] [blame] | 67 | if openstack endpoint show identity; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 68 | STATUS_KEYSTONE="Succeeded" |
| 69 | else |
| 70 | STATUS_KEYSTONE="Failed" |
| 71 | RETURN=1 |
| 72 | fi |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 73 | fi |
| 74 | fi |
| 75 | |
| 76 | # Nova client |
| 77 | # ----------- |
| 78 | |
| 79 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 80 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 81 | STATUS_NOVA="Skipped" |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 82 | STATUS_EC2="Skipped" |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 83 | else |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 84 | # Test OSAPI |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 85 | echo -e "\nTest Nova" |
| 86 | if nova flavor-list; then |
| 87 | STATUS_NOVA="Succeeded" |
| 88 | else |
| 89 | STATUS_NOVA="Failed" |
| 90 | RETURN=1 |
| 91 | fi |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 92 | |
| 93 | # Test EC2 API |
| 94 | echo -e "\nTest EC2" |
| 95 | # Get EC2 creds |
| 96 | source $TOP_DIR/eucarc |
| 97 | |
| 98 | if euca-describe-images; then |
| 99 | STATUS_EC2="Succeeded" |
| 100 | else |
| 101 | STATUS_EC2="Failed" |
| 102 | RETURN=1 |
| 103 | fi |
| 104 | |
| 105 | # Clean up side effects |
| 106 | unset NOVA_VERSION |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 107 | fi |
| 108 | fi |
| 109 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 110 | # Cinder client |
| 111 | # ------------- |
| 112 | |
| 113 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 114 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 115 | STATUS_CINDER="Skipped" |
| 116 | else |
| 117 | echo -e "\nTest Cinder" |
| 118 | if cinder list; then |
| 119 | STATUS_CINDER="Succeeded" |
| 120 | else |
| 121 | STATUS_CINDER="Failed" |
| 122 | RETURN=1 |
| 123 | fi |
| 124 | fi |
| 125 | fi |
| 126 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 127 | # Glance client |
| 128 | # ------------- |
| 129 | |
| 130 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 131 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 132 | STATUS_GLANCE="Skipped" |
| 133 | else |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 134 | echo -e "\nTest Glance" |
Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 135 | if openstack image list; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 136 | STATUS_GLANCE="Succeeded" |
| 137 | else |
| 138 | STATUS_GLANCE="Failed" |
| 139 | RETURN=1 |
| 140 | fi |
| 141 | fi |
| 142 | fi |
| 143 | |
| 144 | # Swift client |
| 145 | # ------------ |
| 146 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 147 | |
| 148 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 149 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 150 | STATUS_SWIFT="Skipped" |
| 151 | else |
| 152 | echo -e "\nTest Swift" |
Dean Troyer | 80756ea | 2012-02-01 18:01:01 -0600 | [diff] [blame] | 153 | if swift stat; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 154 | STATUS_SWIFT="Succeeded" |
| 155 | else |
| 156 | STATUS_SWIFT="Failed" |
| 157 | RETURN=1 |
| 158 | fi |
| 159 | fi |
| 160 | fi |
| 161 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 162 | set +o xtrace |
| 163 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 164 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 165 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 166 | # ======= |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 167 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 168 | function report { |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 169 | if [[ -n "$2" ]]; then |
| 170 | echo "$1: $2" |
| 171 | fi |
| 172 | } |
| 173 | |
| 174 | echo -e "\n" |
| 175 | report "Keystone" $STATUS_KEYSTONE |
| 176 | report "Nova" $STATUS_NOVA |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 177 | report "EC2" $STATUS_EC2 |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 178 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 179 | report "Glance" $STATUS_GLANCE |
| 180 | report "Swift" $STATUS_SWIFT |
| 181 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 182 | if (( $RETURN == 0 )); then |
| 183 | echo "*********************************************************************" |
| 184 | echo "SUCCESS: End DevStack Exercise: $0" |
| 185 | echo "*********************************************************************" |
| 186 | fi |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 187 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 188 | exit $RETURN |