Merge branch 'master' into roles
diff --git a/scripts/single-node-pod.sh b/scripts/single-node-pod.sh
index 1d9c2ee..57de0f8 100755
--- a/scripts/single-node-pod.sh
+++ b/scripts/single-node-pod.sh
@@ -39,14 +39,23 @@
 
 function setup_openstack() {
     # Run the playbook
-    ansible-playbook -i inventory/cord-cloudlab cord-single-playbook.yml
+    ansible-playbook -i $INVENTORY cord-single-playbook.yml
 }
 
-function build_xos_with_exampleservice() {
+function build_xos_docker_images() {
     echo ""
-    echo "Adding exampleservice to XOS"
+    echo "Checking out XOS branch $BUILD_BRANCH"
     ssh ubuntu@xos "cd xos; git config --global user.email 'ubuntu@localhost'; git config --global user.name 'XOS ExampleService'"
-    ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; git cherry-pick 775e00549e535803522fbcd70152e5e1b0629c83"
+    ssh ubuntu@xos "cd xos; git checkout $BUILD_BRANCH"
+    if [[ $EXAMPLESERVICE -eq 1 ]]
+    then
+      echo ""
+      echo "Adding exampleservice to XOS"
+      ssh ubuntu@xos "cd xos; git cherry-pick 775e00549e535803522fbcd70152e5e1b0629c83"
+    fi
+    echo ""
+    echo "Rebuilding XOS containers"
+    ssh ubuntu@xos "cd xos/xos/configurations/cord-pod; make local_containers"
 }
 
 function setup_xos() {
@@ -144,6 +153,8 @@
     source ~/admin-openrc.sh
 
     echo "*** Wait for exampleservice VM to come up."
+    echo "!!! NOTE that currently the VM will only be created after you login"
+    echo "!!! to XOS and manually create an ExampleService tenant."
     i=0
     until nova list --all-tenants|grep exampleservice.*ACTIVE > /dev/null
     do
@@ -180,20 +191,29 @@
 # Parse options
 RUN_TEST=0
 EXAMPLESERVICE=0
-while getopts ":eht" opt; do
+BUILD_BRANCH=""
+INVENTORY="inventory/single-localhost"
+
+while getopts "b:eht" opt; do
   case ${opt} in
-    h ) "echo Usage:"
-      echo "    $0            install OpenStack and prep XOS and ONOS VMs [default]"
-      echo "    $0 -e         add exampleservice to XOS"
-      echo "    $0 -h         display this help message"
-      echo "    $0 -t         do install, bring up cord-pod configuration, run E2E test"
-      exit 0
-      ;;
-    t ) RUN_TEST=1
+    b ) BUILD_BRANCH=$OPTARG
       ;;
     e ) EXAMPLESERVICE=1
       ;;
-    \? ) echo "Invalid option"
+    h ) echo "Usage:"
+      echo "    $0                install OpenStack and prep XOS and ONOS VMs [default]"
+      echo "    $0 -b <branch>    build XOS containers based on GitHub <branch> instead of pulling them from Docker Hub"
+      echo "    $0 -e             add exampleservice to XOS"
+      echo "    $0 -h             display this help message"
+      echo "    $0 -i <inv_file>  specify an inventory file (default is inventory/single-localhost)"
+      echo "    $0 -t             do install, bring up cord-pod configuration, run E2E test"
+      exit 0
+      ;;
+    i ) INVENTORY=$OPTARG
+      ;;
+    t ) RUN_TEST=1
+      ;;
+    \? ) echo "Invalid option: -$OPTARG"
       exit 1
       ;;
   esac
@@ -212,9 +232,9 @@
 
 if [[ $RUN_TEST -eq 1 ]]
 then
-  if [[ $EXAMPLESERVICE -eq 1 ]]
+  if [[ -n $BUILD_BRANCH || $EXAMPLESERVICE -eq 1 ]]
   then
-    build_xos_with_exampleservice
+    build_xos_docker_images
   fi
   setup_xos
   setup_test_client