Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 3 | **client-args.sh** |
| 4 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 5 | # Test OpenStack client authentication aguemnts handling |
| 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 | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 11 | |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 12 | # Settings |
| 13 | # ======== |
| 14 | |
| 15 | # Keep track of the current directory |
| 16 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) |
| 17 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) |
| 18 | |
| 19 | # Import common functions |
| 20 | source $TOP_DIR/functions |
| 21 | |
| 22 | # Import configuration |
| 23 | source $TOP_DIR/openrc |
| 24 | |
| 25 | # Import exercise configuration |
| 26 | source $TOP_DIR/exerciserc |
| 27 | |
Dean Troyer | c5dfecd | 2012-09-08 14:20:43 -0500 | [diff] [blame^] | 28 | # Unset all of the known NOVA_* vars |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 29 | unset NOVA_API_KEY |
| 30 | unset NOVA_ENDPOINT_NAME |
| 31 | unset NOVA_PASSWORD |
| 32 | unset NOVA_PROJECT_ID |
| 33 | unset NOVA_REGION_NAME |
| 34 | unset NOVA_URL |
| 35 | unset NOVA_USERNAME |
| 36 | unset NOVA_VERSION |
| 37 | |
| 38 | # Save the known variables for later |
| 39 | export x_TENANT_NAME=$OS_TENANT_NAME |
| 40 | export x_USERNAME=$OS_USERNAME |
| 41 | export x_PASSWORD=$OS_PASSWORD |
| 42 | export x_AUTH_URL=$OS_AUTH_URL |
| 43 | |
Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 44 | # Unset the usual variables to force argument processing |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 45 | unset OS_TENANT_NAME |
| 46 | unset OS_USERNAME |
| 47 | unset OS_PASSWORD |
| 48 | unset OS_AUTH_URL |
| 49 | |
| 50 | # Common authentication args |
| 51 | TENANT_ARG="--os_tenant_name=$x_TENANT_NAME" |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 52 | TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 53 | 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] | 54 | 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] | 55 | |
| 56 | # Set global return |
| 57 | RETURN=0 |
| 58 | |
| 59 | # Keystone client |
| 60 | # --------------- |
| 61 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
| 62 | if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then |
| 63 | STATUS_KEYSTONE="Skipped" |
| 64 | else |
| 65 | echo -e "\nTest Keystone" |
| 66 | if keystone $TENANT_ARG $ARGS catalog --service identity; then |
| 67 | STATUS_KEYSTONE="Succeeded" |
| 68 | else |
| 69 | STATUS_KEYSTONE="Failed" |
| 70 | RETURN=1 |
| 71 | fi |
| 72 | fi |
| 73 | fi |
| 74 | |
| 75 | # Nova client |
| 76 | # ----------- |
| 77 | |
| 78 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
| 79 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then |
| 80 | STATUS_NOVA="Skipped" |
| 81 | STATUS_EC2="Skipped" |
| 82 | else |
| 83 | # Test OSAPI |
| 84 | echo -e "\nTest Nova" |
| 85 | if nova $TENANT_ARG $ARGS flavor-list; then |
| 86 | STATUS_NOVA="Succeeded" |
| 87 | else |
| 88 | STATUS_NOVA="Failed" |
| 89 | RETURN=1 |
| 90 | fi |
| 91 | fi |
| 92 | fi |
| 93 | |
| 94 | # Glance client |
| 95 | # ------------- |
| 96 | |
| 97 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
| 98 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then |
| 99 | STATUS_GLANCE="Skipped" |
| 100 | else |
| 101 | echo -e "\nTest Glance" |
Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 102 | if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 103 | STATUS_GLANCE="Succeeded" |
| 104 | else |
| 105 | STATUS_GLANCE="Failed" |
| 106 | RETURN=1 |
| 107 | fi |
| 108 | fi |
| 109 | fi |
| 110 | |
| 111 | # Swift client |
| 112 | # ------------ |
| 113 | |
| 114 | if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then |
| 115 | if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then |
| 116 | STATUS_SWIFT="Skipped" |
| 117 | else |
| 118 | echo -e "\nTest Swift" |
Armando Migliaccio | ea6b2d3 | 2012-07-04 16:24:47 +0100 | [diff] [blame] | 119 | if swift $TENANT_ARG $ARGS stat; then |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 120 | STATUS_SWIFT="Succeeded" |
| 121 | else |
| 122 | STATUS_SWIFT="Failed" |
| 123 | RETURN=1 |
| 124 | fi |
| 125 | fi |
| 126 | fi |
| 127 | |
| 128 | # Results |
| 129 | # ------- |
| 130 | |
| 131 | function report() { |
| 132 | if [[ -n "$2" ]]; then |
| 133 | echo "$1: $2" |
| 134 | fi |
| 135 | } |
| 136 | |
| 137 | echo -e "\n" |
| 138 | report "Keystone" $STATUS_KEYSTONE |
| 139 | report "Nova" $STATUS_NOVA |
| 140 | report "Glance" $STATUS_GLANCE |
| 141 | report "Swift" $STATUS_SWIFT |
| 142 | |
Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 143 | echo "*********************************************************************" |
| 144 | echo "SUCCESS: End DevStack Exercise: $0" |
| 145 | echo "*********************************************************************" |
Dean Troyer | 4d88347 | 2012-03-13 23:56:49 -0500 | [diff] [blame] | 146 | |
| 147 | exit $RETURN |