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