-__version__=0.5
-image_name=nfvbenchvm_centos-$__version__
-
-# if image exists skip building
-if command -v gsutil >/dev/null; then
- if gsutil -q stat gs://$gs_url/$image_name.qcow2; then
- echo "Image already exists at http://$gs_url/$image_name.qcow2"
- exit 0
+__version__=0.15
+loopvm_image_name=nfvbenchvm_centos-$__version__
+generator_image_name=nfvbenchvm_centos-generator-$__version__
+
+
+# ----------------------------------------------------------------------------
+# Parse command line options and configure the script
+# ----------------------------------------------------------------------------
+
+usage() {
+ cat <<EOF
+$(basename $0) - build NFVbench VM images
+Usage:
+ $(basename $0) [OPTIONS]
+
+OPTIONS
+ -l: build NFVbench loop VM image
+ -g: build NFVbench generator image
+ -v: verify only (build but do not push to google storage)
+
+ -t: enable debug trace (set -x + DIB_DEBUG_TRACE=1)
+ -d: start debug shell in image chroot in case of build error
+ -h: show this help message
+EOF
+ exit 1
+}
+
+while getopts ":lgvtdh" opt; do
+ case $opt in
+ l)
+ loopvm_only=1
+ ;;
+ g)
+ generator_only=1
+ ;;
+ v)
+ verify_only=1
+ ;;
+ t)
+ set -x
+ export DIB_DEBUG_TRACE=1
+ ;;
+ d)
+ DEBUG=yes
+ ;;
+ h)
+ usage
+ exit 0
+ ;;
+ ?)
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+
+# ----------------------------------------------------------------------------
+# Configure and start the nfvbenchvm image build
+# ----------------------------------------------------------------------------
+
+function build_image {
+ # if image exists skip building
+ echo "Checking if image exists in google storage..."
+ if command -v gsutil >/dev/null; then
+ if gsutil -q stat gs://$gs_url/$1.qcow2; then
+ echo "Image already exists at http://$gs_url/$1.qcow2"
+ echo "Build is skipped"
+ exit 0
+ fi
+ echo "Image does not exist in google storage, starting build..."
+ echo
+ else
+ echo "Cannot check image availability in OPNFV artifact repository (gsutil not available)"