client-args.sh

client-args.sh

# DIVIDER #!/usr/bin/env bash # DIVIDER echo "*********************************************************************" echo "Begin DevStack Exercise: $0" echo "*********************************************************************" # DIVIDER set -o errexit # DIVIDER set -o xtrace # DIVIDER # DIVIDER EXERCISE_DIR=$(cd $(dirname "$0") && pwd) TOP_DIR=$(cd $EXERCISE_DIR/..; pwd) # DIVIDER source $TOP_DIR/functions # DIVIDER source $TOP_DIR/openrc # DIVIDER source $TOP_DIR/exerciserc # DIVIDER 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 # DIVIDER export x_TENANT_NAME=$OS_TENANT_NAME export x_USERNAME=$OS_USERNAME export x_PASSWORD=$OS_PASSWORD export x_AUTH_URL=$OS_AUTH_URL # DIVIDER unset OS_TENANT_NAME unset OS_USERNAME unset OS_PASSWORD unset OS_AUTH_URL # DIVIDER TENANT_ARG="--os-tenant-name=$x_TENANT_NAME" ARGS="--os-username=$x_USERNAME --os-password=$x_PASSWORD --os-auth-url=$x_AUTH_URL" # DIVIDER RETURN=0 # DIVIDER if [[ "$ENABLED_SERVICES" =~ "key" ]]; then if [[ "$SKIP_EXERCISES" =~ "key" ]]; then STATUS_KEYSTONE="Skipped" else echo -e "\nTest Keystone" if openstack $TENANT_ARG $ARGS catalog show identity; then STATUS_KEYSTONE="Succeeded" else STATUS_KEYSTONE="Failed" RETURN=1 fi fi fi # DIVIDER if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then if [[ "$SKIP_EXERCISES" =~ "n-api" ]]; then STATUS_NOVA="Skipped" STATUS_EC2="Skipped" else # DIVIDER echo -e "\nTest Nova" if nova $TENANT_ARG $ARGS flavor-list; then STATUS_NOVA="Succeeded" else STATUS_NOVA="Failed" RETURN=1 fi fi fi # DIVIDER if [[ "$ENABLED_SERVICES" =~ "c-api" ]]; then if [[ "$SKIP_EXERCISES" =~ "c-api" ]]; then STATUS_CINDER="Skipped" else echo -e "\nTest Cinder" if cinder $TENANT_ARG $ARGS list; then STATUS_CINDER="Succeeded" else STATUS_CINDER="Failed" RETURN=1 fi fi fi # DIVIDER if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then if [[ "$SKIP_EXERCISES" =~ "g-api" ]]; then STATUS_GLANCE="Skipped" else echo -e "\nTest Glance" if openstack $TENANT_ARG $ARGS image list; then STATUS_GLANCE="Succeeded" else STATUS_GLANCE="Failed" RETURN=1 fi fi fi # DIVIDER if [[ "$ENABLED_SERVICES" =~ "swift" || "$ENABLED_SERVICES" =~ "s-proxy" ]]; then if [[ "$SKIP_EXERCISES" =~ "swift" ]]; then STATUS_SWIFT="Skipped" else echo -e "\nTest Swift" if swift $TENANT_ARG $ARGS stat; then STATUS_SWIFT="Succeeded" else STATUS_SWIFT="Failed" RETURN=1 fi fi fi set +o xtrace # DIVIDER function report { if [[ -n "$2" ]]; then echo "$1: $2" fi } echo -e "\n" report "Keystone" $STATUS_KEYSTONE report "Nova" $STATUS_NOVA report "Cinder" $STATUS_CINDER report "Glance" $STATUS_GLANCE report "Swift" $STATUS_SWIFT if (( $RETURN == 0 )); then echo "*********************************************************************" echo "SUCCESS: End DevStack Exercise: $0" echo "*********************************************************************" fi exit $RETURN # DIVIDER

Test OpenStack client authentication arguments handling

This script exits on an error so that errors don't compound and you see only the first error that occurred.

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.

Settings

Keep track of the current directory

Import common functions

Import configuration

Import exercise configuration

Unset all of the known NOVA_* vars

Save the known variables for later

Unset the usual variables to force argument processing

Common authentication args

Set global return

Keystone client

Nova client

Test OSAPI

Cinder client

Glance client

Swift client

Results