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 |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 44 | |
| 45 | # Save the known variables for later |
| 46 | export x_TENANT_NAME=$OS_TENANT_NAME |
| 47 | export x_USERNAME=$OS_USERNAME |
| 48 | export x_PASSWORD=$OS_PASSWORD |
| 49 | export x_AUTH_URL=$OS_AUTH_URL |
| 50 | |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 51 | # Unset the usual variables to force argument processing |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 52 | unset OS_TENANT_NAME |
| 53 | unset OS_USERNAME |
| 54 | unset OS_PASSWORD |
| 55 | unset OS_AUTH_URL |
| 56 | |
| 57 | # Common authentication args |
Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 58 | TENANT_ARG="--os-tenant-name=$x_TENANT_NAME" |
| 59 | ARGS="--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] | 60 | |
| 61 | # Set global return |
| 62 | RETURN=0 |
| 63 | |
| 64 | # Keystone client |
| 65 | # --------------- |
| 66 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 67 | if [[ "$SKIP_EXERCISES" =~ "key" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 68 | STATUS_KEYSTONE="Skipped" |
| 69 | else |
| 70 | echo -e "\nTest Keystone" |
Peter Stachowski | 9a80892 | 2015-04-08 19:48:09 +0000 | [diff] [blame] | 71 | if openstack $TENANT_ARG $ARGS catalog show identity; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 72 | STATUS_KEYSTONE="Succeeded" |
| 73 | else |
| 74 | STATUS_KEYSTONE="Failed" |
| 75 | RETURN=1 |
| 76 | fi |
| 77 | fi |
| 78 | fi |
| 79 | |
| 80 | # Nova client |
| 81 | # ----------- |
| 82 | |
| 83 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 84 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 85 | STATUS_NOVA="Skipped" |
| 86 | STATUS_EC2="Skipped" |
| 87 | else |
| 88 | # Test OSAPI |
| 89 | echo -e "\nTest Nova" |
Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 90 | if nova $TENANT_ARG $ARGS flavor-list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 91 | STATUS_NOVA="Succeeded" |
| 92 | else |
| 93 | STATUS_NOVA="Failed" |
| 94 | RETURN=1 |
| 95 | fi |
| 96 | fi |
| 97 | fi |
| 98 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 99 | # Cinder client |
| 100 | # ------------- |
| 101 | |
| 102 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 103 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 104 | STATUS_CINDER="Skipped" |
| 105 | else |
| 106 | echo -e "\nTest Cinder" |
Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 107 | if cinder $TENANT_ARG $ARGS list; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 108 | STATUS_CINDER="Succeeded" |
| 109 | else |
| 110 | STATUS_CINDER="Failed" |
| 111 | RETURN=1 |
| 112 | fi |
| 113 | fi |
| 114 | fi |
| 115 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 116 | # Glance client |
| 117 | # ------------- |
| 118 | |
| 119 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 120 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 121 | STATUS_GLANCE="Skipped" |
| 122 | else |
| 123 | echo -e "\nTest Glance" |
Steve Martinelli | 5c206c2 | 2014-08-02 20:32:31 -0400 | [diff] [blame] | 124 | if openstack $TENANT_ARG $ARGS image list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 125 | STATUS_GLANCE="Succeeded" |
| 126 | else |
| 127 | STATUS_GLANCE="Failed" |
| 128 | RETURN=1 |
| 129 | fi |
| 130 | fi |
| 131 | fi |
| 132 | |
| 133 | # Swift client |
| 134 | # ------------ |
| 135 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 136 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 137 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 138 | STATUS_SWIFT="Skipped" |
| 139 | else |
| 140 | echo -e "\nTest Swift" |
Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 141 | if swift $TENANT_ARG $ARGS stat; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 142 | STATUS_SWIFT="Succeeded" |
| 143 | else |
| 144 | STATUS_SWIFT="Failed" |
| 145 | RETURN=1 |
| 146 | fi |
| 147 | fi |
| 148 | fi |
| 149 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 150 | set +o xtrace |
| 151 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 152 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 153 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 154 | # ======= |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 155 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 156 | function report { |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 157 | if [[ -n "$2" ]]; then |
| 158 | echo "$1: $2" |
| 159 | fi |
| 160 | } |
| 161 | |
| 162 | echo -e "\n" |
| 163 | report "Keystone" $STATUS_KEYSTONE |
| 164 | report "Nova" $STATUS_NOVA |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 165 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 166 | report "Glance" $STATUS_GLANCE |
| 167 | report "Swift" $STATUS_SWIFT |
| 168 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 169 | if (( $RETURN == 0 )); then |
| 170 | echo "*********************************************************************" |
| 171 | echo "SUCCESS: End DevStack Exercise: $0" |
| 172 | echo "*********************************************************************" |
| 173 | fi |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 174 | |
| 175 | exit $RETURN |