+usage()
+{
+ cat <<EOF
+
+Yardstick NSB setup script.
+
+Usage: $0 [-h] [[-o] admin-openrc-for-openstack] [-i yardstick-docker-image]
+
+Options:
+ -h Show this message and exit
+ -o openrc Specify admin-openrc file with OpenStack credentials
+ Defaults to none
+ -i image Specify Yardstick Docker image, e.g. opnfv/yardstick:stable
+ Default value provided by ansible/nsb_setup.yml
+ See https://hub.docker.com/r/opnfv/yardstick/tags/
+
+EOF
+}
+
+OPTSTR=':ho:i:'
+openrc=
+image=
+
+# For backward compatibility reasons, accept openrc both as an argument
+# and as the -o option. Hence these two loops.
+while [ $# -ge 1 ]; do
+ OPTIND=1
+ while getopts ${OPTSTR} OPT; do
+ case $OPT in
+ h)
+ usage
+ exit 0
+ ;;
+ o)
+ openrc=${OPTARG}
+ ;;
+ i)
+ image=${OPTARG}
+ ;;
+ :)
+ usage
+ echo "ERROR: Missing value for -${OPTARG} option"
+ exit 1
+ ;;
+ *)
+ usage
+ echo "ERROR: Invalid -${OPTARG} option"
+ exit 1
+ ;;
+ esac
+ done
+
+ if [ ${OPTIND} -eq 1 ]; then
+ openrc=$1
+ shift
+ else
+ shift $((OPTIND - 1))
+ fi
+done
+