Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 3 | # **client-args.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 authentication arguments handling |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 6 | |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 7 | echo "*********************************************************************" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 8 | echo "Begin DevStack Exercise: $0" |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 9 | echo "*********************************************************************" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [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 | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 19 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 20 | # Settings |
| 21 | # ======== |
| 22 | |
| 23 | # Keep track of the current directory |
| 24 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) |
| 25 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
| 26 | |
| 27 | # Import common functions |
| 28 | source $TOP_DIR/functions |
| 29 | |
| 30 | # Import configuration |
| 31 | source $TOP_DIR/openrc |
| 32 | |
| 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 | 4d88347 | 2012-03-13 23:56:49 -0500 | [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 | |
| 46 | # Save the known variables for later |
| 47 | export x_TENANT_NAME=$OS_TENANT_NAME |
| 48 | export x_USERNAME=$OS_USERNAME |
| 49 | export x_PASSWORD=$OS_PASSWORD |
| 50 | export x_AUTH_URL=$OS_AUTH_URL |
| 51 | |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 52 | # Unset the usual variables to force argument processing |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 53 | unset OS_TENANT_NAME |
| 54 | unset OS_USERNAME |
| 55 | unset OS_PASSWORD |
| 56 | unset OS_AUTH_URL |
| 57 | |
| 58 | # Common authentication args |
| 59 | TENANT_ARG="--os_tenant_name=$x_TENANT_NAME" |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 60 | TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 61 | ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL" |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 62 | ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 63 | |
| 64 | # Set global return |
| 65 | RETURN=0 |
| 66 | |
| 67 | # Keystone client |
| 68 | # --------------- |
| 69 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 70 | if [[ "$SKIP_EXERCISES" =~ "key" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 71 | STATUS_KEYSTONE="Skipped" |
| 72 | else |
| 73 | echo -e "\nTest Keystone" |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 74 | if keystone $TENANT_ARG_DASH $ARGS_DASH catalog --service identity; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 75 | STATUS_KEYSTONE="Succeeded" |
| 76 | else |
| 77 | STATUS_KEYSTONE="Failed" |
| 78 | RETURN=1 |
| 79 | fi |
| 80 | fi |
| 81 | fi |
| 82 | |
| 83 | # Nova client |
| 84 | # ----------- |
| 85 | |
| 86 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 87 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 88 | STATUS_NOVA="Skipped" |
| 89 | STATUS_EC2="Skipped" |
| 90 | else |
| 91 | # Test OSAPI |
| 92 | echo -e "\nTest Nova" |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 93 | if nova $TENANT_ARG_DASH $ARGS_DASH flavor-list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 94 | STATUS_NOVA="Succeeded" |
| 95 | else |
| 96 | STATUS_NOVA="Failed" |
| 97 | RETURN=1 |
| 98 | fi |
| 99 | fi |
| 100 | fi |
| 101 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 102 | # Cinder client |
| 103 | # ------------- |
| 104 | |
| 105 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 106 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 107 | STATUS_CINDER="Skipped" |
| 108 | else |
| 109 | echo -e "\nTest Cinder" |
| 110 | if cinder $TENANT_ARG_DASH $ARGS_DASH list; then |
| 111 | STATUS_CINDER="Succeeded" |
| 112 | else |
| 113 | STATUS_CINDER="Failed" |
| 114 | RETURN=1 |
| 115 | fi |
| 116 | fi |
| 117 | fi |
| 118 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 119 | # Glance client |
| 120 | # ------------- |
| 121 | |
| 122 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 123 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 124 | STATUS_GLANCE="Skipped" |
| 125 | else |
| 126 | echo -e "\nTest Glance" |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 127 | if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 128 | STATUS_GLANCE="Succeeded" |
| 129 | else |
| 130 | STATUS_GLANCE="Failed" |
| 131 | RETURN=1 |
| 132 | fi |
| 133 | fi |
| 134 | fi |
| 135 | |
| 136 | # Swift client |
| 137 | # ------------ |
| 138 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 139 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 140 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 141 | STATUS_SWIFT="Skipped" |
| 142 | else |
| 143 | echo -e "\nTest Swift" |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 144 | if swift $TENANT_ARG_DASH $ARGS_DASH stat; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 145 | STATUS_SWIFT="Succeeded" |
| 146 | else |
| 147 | STATUS_SWIFT="Failed" |
| 148 | RETURN=1 |
| 149 | fi |
| 150 | fi |
| 151 | fi |
| 152 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 153 | set +o xtrace |
| 154 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 155 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 156 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 157 | # ======= |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 158 | |
| 159 | function report() { |
| 160 | if [[ -n "$2" ]]; then |
| 161 | echo "$1: $2" |
| 162 | fi |
| 163 | } |
| 164 | |
| 165 | echo -e "\n" |
| 166 | report "Keystone" $STATUS_KEYSTONE |
| 167 | report "Nova" $STATUS_NOVA |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 168 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 169 | report "Glance" $STATUS_GLANCE |
| 170 | report "Swift" $STATUS_SWIFT |
| 171 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 172 | if (( $RETURN == 0 )); then |
| 173 | echo "*********************************************************************" |
| 174 | echo "SUCCESS: End DevStack Exercise: $0" |
| 175 | echo "*********************************************************************" |
| 176 | fi |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 177 | |
| 178 | exit $RETURN |