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 |
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" |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 81 | STATUS_EC2="Skipped" |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 82 | else |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 83 | # Test OSAPI |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 84 | echo -e "\nTest Nova" |
| 85 | if nova flavor-list; then |
| 86 | STATUS_NOVA="Succeeded" |
| 87 | else |
| 88 | STATUS_NOVA="Failed" |
| 89 | RETURN=1 |
| 90 | fi |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 91 | |
| 92 | # Test EC2 API |
| 93 | echo -e "\nTest EC2" |
| 94 | # Get EC2 creds |
| 95 | source $TOP_DIR/eucarc |
| 96 | |
| 97 | if euca-describe-images; then |
| 98 | STATUS_EC2="Succeeded" |
| 99 | else |
| 100 | STATUS_EC2="Failed" |
| 101 | RETURN=1 |
| 102 | fi |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 103 | fi |
| 104 | fi |
| 105 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 106 | # Cinder client |
| 107 | # ------------- |
| 108 | |
| 109 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 110 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 111 | STATUS_CINDER="Skipped" |
| 112 | else |
| 113 | echo -e "\nTest Cinder" |
| 114 | if cinder list; then |
| 115 | STATUS_CINDER="Succeeded" |
| 116 | else |
| 117 | STATUS_CINDER="Failed" |
| 118 | RETURN=1 |
| 119 | fi |
| 120 | fi |
| 121 | fi |
| 122 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 123 | # Glance client |
| 124 | # ------------- |
| 125 | |
| 126 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 127 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 128 | STATUS_GLANCE="Skipped" |
| 129 | else |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 130 | echo -e "\nTest Glance" |
Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 131 | if openstack image list; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 132 | STATUS_GLANCE="Succeeded" |
| 133 | else |
| 134 | STATUS_GLANCE="Failed" |
| 135 | RETURN=1 |
| 136 | fi |
| 137 | fi |
| 138 | fi |
| 139 | |
| 140 | # Swift client |
| 141 | # ------------ |
| 142 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 143 | |
| 144 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 145 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 146 | STATUS_SWIFT="Skipped" |
| 147 | else |
| 148 | echo -e "\nTest Swift" |
Dean Troyer | 80756ea | 2012-02-01 18:01:01 -0600 | [diff] [blame] | 149 | if swift stat; then |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 150 | STATUS_SWIFT="Succeeded" |
| 151 | else |
| 152 | STATUS_SWIFT="Failed" |
| 153 | RETURN=1 |
| 154 | fi |
| 155 | fi |
| 156 | fi |
| 157 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 158 | set +o xtrace |
| 159 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 160 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 161 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 162 | # ======= |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 163 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 164 | function report { |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 165 | if [[ -n "$2" ]]; then |
| 166 | echo "$1: $2" |
| 167 | fi |
| 168 | } |
| 169 | |
| 170 | echo -e "\n" |
| 171 | report "Keystone" $STATUS_KEYSTONE |
| 172 | report "Nova" $STATUS_NOVA |
Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 173 | report "EC2" $STATUS_EC2 |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 174 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 175 | report "Glance" $STATUS_GLANCE |
| 176 | report "Swift" $STATUS_SWIFT |
| 177 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 178 | if (( $RETURN == 0 )); then |
| 179 | echo "*********************************************************************" |
| 180 | echo "SUCCESS: End DevStack Exercise: $0" |
| 181 | echo "*********************************************************************" |
| 182 | fi |
Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 183 | |
Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 184 | exit $RETURN |