4d88347f |
#!/usr/bin/env bash
|
83480535 |
# **client-args.sh** |
ad101767 |
|
4d88347f |
# Test OpenStack client authentication aguemnts handling
|
27e32699 |
echo "*********************************************************************" |
4d88347f |
echo "Begin DevStack Exercise: $0" |
27e32699 |
echo "*********************************************************************" |
4d88347f |
|
da85cdad |
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
|
ad101767 |
|
4d88347f |
# Settings
# ========
# Keep track of the current directory
EXERCISE_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $EXERCISE_DIR/..; pwd)
# Import common functions
source $TOP_DIR/functions
# Import configuration
source $TOP_DIR/openrc
# Import exercise configuration
source $TOP_DIR/exerciserc
|
c5dfecd8 |
# Unset all of the known NOVA_* vars |
4d88347f |
unset NOVA_API_KEY
unset NOVA_ENDPOINT_NAME
unset NOVA_PASSWORD
unset NOVA_PROJECT_ID
unset NOVA_REGION_NAME
unset NOVA_URL
unset NOVA_USERNAME
unset NOVA_VERSION
# Save the known variables for later
export x_TENANT_NAME=$OS_TENANT_NAME
export x_USERNAME=$OS_USERNAME
export x_PASSWORD=$OS_PASSWORD
export x_AUTH_URL=$OS_AUTH_URL
|
ad101767 |
# Unset the usual variables to force argument processing |
4d88347f |
unset OS_TENANT_NAME
unset OS_USERNAME
unset OS_PASSWORD
unset OS_AUTH_URL
# Common authentication args
TENANT_ARG="--os_tenant_name=$x_TENANT_NAME" |
45495258 |
TENANT_ARG_DASH="--os-tenant-name=$x_TENANT_NAME" |
4d88347f |
ARGS="--os_username=$x_USERNAME --os_password=$x_PASSWORD --os_auth_url=$x_AUTH_URL" |
45495258 |
ARGS_DASH="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL" |
4d88347f |
# Set global return
RETURN=0
# Keystone client
# ---------------
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then |
cc6b4435 |
if [[ "$SKIP_EXERCISES" =~ "key" ]]; then |
4d88347f |
STATUS_KEYSTONE="Skipped"
else
echo -e "\nTest Keystone" |
da85cdad |
if keystone $TENANT_ARG_DASH $ARGS_DASH catalog --service identity; then |
4d88347f |
STATUS_KEYSTONE="Succeeded"
else
STATUS_KEYSTONE="Failed"
RETURN=1
fi
fi
fi
# Nova client
# -----------
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then |
cc6b4435 |
if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then |
4d88347f |
STATUS_NOVA="Skipped"
STATUS_EC2="Skipped"
else
# Test OSAPI
echo -e "\nTest Nova" |
da85cdad |
if nova $TENANT_ARG_DASH $ARGS_DASH flavor-list; then |
4d88347f |
STATUS_NOVA="Succeeded"
else
STATUS_NOVA="Failed"
RETURN=1
fi
fi
fi
|
da85cdad |
# Cinder client
# -------------
if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then |
cc6b4435 |
if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then |
da85cdad |
STATUS_CINDER="Skipped"
else
echo -e "\nTest Cinder"
if cinder $TENANT_ARG_DASH $ARGS_DASH list; then
STATUS_CINDER="Succeeded"
else
STATUS_CINDER="Failed"
RETURN=1
fi
fi
fi
|
4d88347f |
# Glance client
# -------------
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then |
cc6b4435 |
if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then |
4d88347f |
STATUS_GLANCE="Skipped"
else
echo -e "\nTest Glance" |
45495258 |
if glance $TENANT_ARG_DASH $ARGS_DASH image-list; then |
4d88347f |
STATUS_GLANCE="Succeeded"
else
STATUS_GLANCE="Failed"
RETURN=1
fi
fi
fi
# Swift client
# ------------
|
0c3a5584 |
if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then |
cc6b4435 |
if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then |
4d88347f |
STATUS_SWIFT="Skipped"
else
echo -e "\nTest Swift" |
da85cdad |
if swift $TENANT_ARG_DASH $ARGS_DASH stat; then |
4d88347f |
STATUS_SWIFT="Succeeded"
else
STATUS_SWIFT="Failed"
RETURN=1
fi
fi
fi
|
da85cdad |
set +o xtrace
|
cc6b4435 |
|
4d88347f |
# Results |
cc6b4435 |
# ======= |
4d88347f |
function report() {
if [[ -n "$2" ]]; then
echo "$1: $2"
fi
}
echo -e "\n"
report "Keystone" $STATUS_KEYSTONE
report "Nova" $STATUS_NOVA |
da85cdad |
report "Cinder" $STATUS_CINDER |
4d88347f |
report "Glance" $STATUS_GLANCE
report "Swift" $STATUS_SWIFT
|
83480535 |
if (( $RETURN == 0 )); then
echo "*********************************************************************"
echo "SUCCESS: End DevStack Exercise: $0"
echo "*********************************************************************"
fi |
4d88347f |
exit $RETURN |