| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 1 | #!/usr/bin/env bash | 
|  | 2 |  | 
| Dean Troyer | ad10176 | 2012-06-27 22:04:40 -0500 | [diff] [blame] | 3 | **client-env.sh** | 
|  | 4 |  | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 5 | # Test OpenStack client enviroment variable handling | 
|  | 6 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 7 | echo "*********************************************************************" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 8 | echo "Begin DevStack Exercise: $0" | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 9 | echo "*********************************************************************" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 10 |  | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 11 |  | 
|  | 12 | # Settings | 
|  | 13 | # ======== | 
|  | 14 |  | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 15 | # Keep track of the current directory | 
|  | 16 | EXERCISE_DIR=$(cd $(dirname "$0") && pwd) | 
|  | 17 | TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 18 |  | 
|  | 19 | # Import common functions | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 20 | source $TOP_DIR/functions | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 21 |  | 
|  | 22 | # Import configuration | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 23 | source $TOP_DIR/openrc | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 24 |  | 
| Dean Troyer | 51fb454 | 2012-03-09 22:21:59 -0600 | [diff] [blame] | 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 | 10670d1 | 2012-01-24 11:26:15 -0600 | [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 |  | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 38 | for i in OS_TENANT_NAME OS_USERNAME OS_PASSWORD OS_AUTH_URL; do | 
|  | 39 | is_set $i | 
|  | 40 | if [[ $? -ne 0 ]]; then | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 41 | echo "$i expected to be set" | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 42 | ABORT=1 | 
|  | 43 | fi | 
|  | 44 | done | 
|  | 45 | if [[ -n "$ABORT" ]]; then | 
|  | 46 | exit 1 | 
|  | 47 | fi | 
|  | 48 |  | 
|  | 49 | # Set global return | 
|  | 50 | RETURN=0 | 
|  | 51 |  | 
|  | 52 | # Keystone client | 
|  | 53 | # --------------- | 
|  | 54 | if [[ "$ENABLED_SERVICES" =~ "key" ]]; then | 
|  | 55 | if [[ "$SKIP_EXERCISES" =~ "key" ]] ; then | 
|  | 56 | STATUS_KEYSTONE="Skipped" | 
|  | 57 | else | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 58 | echo -e "\nTest Keystone" | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 59 | if keystone catalog --service identity; then | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 60 | STATUS_KEYSTONE="Succeeded" | 
|  | 61 | else | 
|  | 62 | STATUS_KEYSTONE="Failed" | 
|  | 63 | RETURN=1 | 
|  | 64 | fi | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 65 | fi | 
|  | 66 | fi | 
|  | 67 |  | 
|  | 68 | # Nova client | 
|  | 69 | # ----------- | 
|  | 70 |  | 
|  | 71 | if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then | 
|  | 72 | if [[ "$SKIP_EXERCISES" =~ "n-api" ]] ; then | 
|  | 73 | STATUS_NOVA="Skipped" | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 74 | STATUS_EC2="Skipped" | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 75 | else | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 76 | # Test OSAPI | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 77 | echo -e "\nTest Nova" | 
|  | 78 | if nova flavor-list; then | 
|  | 79 | STATUS_NOVA="Succeeded" | 
|  | 80 | else | 
|  | 81 | STATUS_NOVA="Failed" | 
|  | 82 | RETURN=1 | 
|  | 83 | fi | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 84 |  | 
|  | 85 | # Test EC2 API | 
|  | 86 | echo -e "\nTest EC2" | 
|  | 87 | # Get EC2 creds | 
|  | 88 | source $TOP_DIR/eucarc | 
|  | 89 |  | 
|  | 90 | if euca-describe-images; then | 
|  | 91 | STATUS_EC2="Succeeded" | 
|  | 92 | else | 
|  | 93 | STATUS_EC2="Failed" | 
|  | 94 | RETURN=1 | 
|  | 95 | fi | 
|  | 96 |  | 
|  | 97 | # Clean up side effects | 
|  | 98 | unset NOVA_VERSION | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 99 | fi | 
|  | 100 | fi | 
|  | 101 |  | 
|  | 102 | # Glance client | 
|  | 103 | # ------------- | 
|  | 104 |  | 
|  | 105 | if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then | 
|  | 106 | if [[ "$SKIP_EXERCISES" =~ "g-api" ]] ; then | 
|  | 107 | STATUS_GLANCE="Skipped" | 
|  | 108 | else | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 109 | echo -e "\nTest Glance" | 
| Dean Troyer | 4549525 | 2012-04-13 13:16:38 -0500 | [diff] [blame] | 110 | if glance image-list; then | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 111 | STATUS_GLANCE="Succeeded" | 
|  | 112 | else | 
|  | 113 | STATUS_GLANCE="Failed" | 
|  | 114 | RETURN=1 | 
|  | 115 | fi | 
|  | 116 | fi | 
|  | 117 | fi | 
|  | 118 |  | 
|  | 119 | # Swift client | 
|  | 120 | # ------------ | 
|  | 121 |  | 
|  | 122 | if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then | 
|  | 123 | if [[ "$SKIP_EXERCISES" =~ "swift" ]] ; then | 
|  | 124 | STATUS_SWIFT="Skipped" | 
|  | 125 | else | 
|  | 126 | echo -e "\nTest Swift" | 
| Dean Troyer | 80756ea | 2012-02-01 18:01:01 -0600 | [diff] [blame] | 127 | if swift stat; then | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 128 | STATUS_SWIFT="Succeeded" | 
|  | 129 | else | 
|  | 130 | STATUS_SWIFT="Failed" | 
|  | 131 | RETURN=1 | 
|  | 132 | fi | 
|  | 133 | fi | 
|  | 134 | fi | 
|  | 135 |  | 
|  | 136 | # Results | 
|  | 137 | # ------- | 
|  | 138 |  | 
|  | 139 | function report() { | 
|  | 140 | if [[ -n "$2" ]]; then | 
|  | 141 | echo "$1: $2" | 
|  | 142 | fi | 
|  | 143 | } | 
|  | 144 |  | 
|  | 145 | echo -e "\n" | 
|  | 146 | report "Keystone" $STATUS_KEYSTONE | 
|  | 147 | report "Nova" $STATUS_NOVA | 
| Dean Troyer | 0bd2410 | 2012-03-08 00:33:54 -0600 | [diff] [blame] | 148 | report "EC2" $STATUS_EC2 | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 149 | report "Glance" $STATUS_GLANCE | 
|  | 150 | report "Swift" $STATUS_SWIFT | 
|  | 151 |  | 
| Dean Troyer | 27e3269 | 2012-03-16 16:16:56 -0500 | [diff] [blame] | 152 | echo "*********************************************************************" | 
|  | 153 | echo "SUCCESS: End DevStack Exercise: $0" | 
|  | 154 | echo "*********************************************************************" | 
| Dean Troyer | 489bd2a | 2012-03-02 10:44:29 -0600 | [diff] [blame] | 155 |  | 
| Dean Troyer | 10670d1 | 2012-01-24 11:26:15 -0600 | [diff] [blame] | 156 | exit $RETURN |