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