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 |
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 | 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 |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 46 | export x_PROJECT_NAME=$OS_PROJECT_NAME |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 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 |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 52 | unset OS_PROJECT_NAME |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 53 | unset OS_USERNAME |
| 54 | unset OS_PASSWORD |
| 55 | unset OS_AUTH_URL |
| 56 | |
| 57 | # Common authentication args |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 58 | PROJECT_ARG="--os-project-name=$x_PROJECT_NAME" |
Dean Troyer | 526b79f | 2013-11-22 11:30:44 -0600 | [diff] [blame] | 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" |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 71 | if openstack $PROJECT_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" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 86 | else |
| 87 | # Test OSAPI |
| 88 | echo -e "\nTest Nova" |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 89 | if nova $PROJECT_ARG $ARGS flavor-list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 90 | STATUS_NOVA="Succeeded" |
| 91 | else |
| 92 | STATUS_NOVA="Failed" |
| 93 | RETURN=1 |
| 94 | fi |
| 95 | fi |
| 96 | fi |
| 97 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 98 | # Cinder client |
| 99 | # ------------- |
| 100 | |
| 101 | if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 102 | if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 103 | STATUS_CINDER="Skipped" |
| 104 | else |
| 105 | echo -e "\nTest Cinder" |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 106 | if cinder $PROJECT_ARG $ARGS list; then |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 107 | STATUS_CINDER="Succeeded" |
| 108 | else |
| 109 | STATUS_CINDER="Failed" |
| 110 | RETURN=1 |
| 111 | fi |
| 112 | fi |
| 113 | fi |
| 114 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 115 | # Glance client |
| 116 | # ------------- |
| 117 | |
| 118 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 119 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 120 | STATUS_GLANCE="Skipped" |
| 121 | else |
| 122 | echo -e "\nTest Glance" |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 123 | if openstack $PROJECT_ARG $ARGS image list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 124 | STATUS_GLANCE="Succeeded" |
| 125 | else |
| 126 | STATUS_GLANCE="Failed" |
| 127 | RETURN=1 |
| 128 | fi |
| 129 | fi |
| 130 | fi |
| 131 | |
| 132 | # Swift client |
| 133 | # ------------ |
| 134 | |
Chmouel Boudjnah | 0c3a558 | 2013-03-06 10:58:33 +0100 | [diff] [blame] | 135 | if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 136 | if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 137 | STATUS_SWIFT="Skipped" |
| 138 | else |
| 139 | echo -e "\nTest Swift" |
Sean Dague | 7580a0c | 2016-02-17 06:23:36 -0500 | [diff] [blame] | 140 | if swift $PROJECT_ARG $ARGS stat; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 141 | STATUS_SWIFT="Succeeded" |
| 142 | else |
| 143 | STATUS_SWIFT="Failed" |
| 144 | RETURN=1 |
| 145 | fi |
| 146 | fi |
| 147 | fi |
| 148 | |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 149 | set +o xtrace |
| 150 | |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 151 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 152 | # Results |
Dean Troyer | cc6b443 | 2013-04-08 15:38:03 -0500 | [diff] [blame] | 153 | # ======= |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 154 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 155 | function report { |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 156 | if [[ -n "$2" ]]; then |
| 157 | echo "$1: $2" |
| 158 | fi |
| 159 | } |
| 160 | |
| 161 | echo -e "\n" |
| 162 | report "Keystone" $STATUS_KEYSTONE |
| 163 | report "Nova" $STATUS_NOVA |
Dean Troyer | da85cda | 2013-02-15 11:07:14 -0600 | [diff] [blame] | 164 | report "Cinder" $STATUS_CINDER |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 165 | report "Glance" $STATUS_GLANCE |
| 166 | report "Swift" $STATUS_SWIFT |
| 167 | |
Dean Troyer | 8348053 | 2012-09-12 14:45:48 -0500 | [diff] [blame] | 168 | if (( $RETURN == 0 )); then |
| 169 | echo "*********************************************************************" |
| 170 | echo "SUCCESS: End DevStack Exercise: $0" |
| 171 | echo "*********************************************************************" |
| 172 | fi |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 173 | |
| 174 | exit $RETURN |