Merge pull request #128 from cloudbuilders/grub1

Remove GRUB 1 config
diff --git a/exercise.sh b/exercise.sh
index 61c7b08..ce69a93 100755
--- a/exercise.sh
+++ b/exercise.sh
@@ -82,8 +82,17 @@
 # Waiting for boot
 # ----------------
 
-# check that the status is active within 10 seconds
-if ! timeout 10 sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then
+# Max time to wait while vm goes from build to active state
+ACTIVE_TIMEOUT=${ACTIVE_TIMEOUT:-10}
+
+# Max time till the vm is bootable
+BOOT_TIMEOUT=${BOOT_TIMEOUT:-15}
+
+# Max time to wait for proper association and dis-association.
+ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10}
+
+# check that the status is active within ACTIVE_TIMEOUT seconds
+if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $NAME | grep status | grep -q ACTIVE; do sleep 1; done"; then
     echo "server didn't become active!"
     exit 1
 fi
@@ -95,12 +104,15 @@
 MULTI_HOST=${MULTI_HOST:-0}
 if [ "$MULTI_HOST" = "0" ]; then
     # sometimes the first ping fails (10 seconds isn't enough time for the VM's
-    # network to respond?), so let's ping for 15 seconds with a timeout
-    # of a second.
-    if ! timeout 15 sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
+    # network to respond?), so let's ping for a default of 15 seconds with a
+    # timeout of a second for each ping.
+    if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
         echo "Couldn't ping server"
         exit 1
     fi
+else
+    # On a multi-host system, without vm net access, do a sleep to wait for the boot
+    sleep $BOOT_TIMEOUT
 fi
 
 # Security Groups & Floating IPs
@@ -121,8 +133,8 @@
 # add floating ip to our server
 nova add-floating-ip $NAME $FLOATING_IP
 
-# test we can ping our floating ip within 10 seconds
-if ! timeout 10 sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
+# test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
     echo "Couldn't ping server with floating ip"
     exit 1
 fi
@@ -152,8 +164,8 @@
 # dis-allow icmp traffic (ping)
 nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0
 
-# test we can aren't able to ping our floating ip within 10 seconds
-if ! timeout 10 sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
+# test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds
+if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
     print "Security group failure - ping should not be allowed!"
     echo "Couldn't ping server with floating ip"
     exit 1
diff --git a/files/sources.list b/files/sources.list
index 96fab5f..a58eca3 100644
--- a/files/sources.list
+++ b/files/sources.list
@@ -1,9 +1,9 @@
-deb http://us.archive.ubuntu.com/ubuntu/ natty main restricted
-deb http://us.archive.ubuntu.com/ubuntu/ natty-updates main restricted
-deb http://us.archive.ubuntu.com/ubuntu/ natty universe
-deb http://us.archive.ubuntu.com/ubuntu/ natty-updates universe
-deb http://us.archive.ubuntu.com/ubuntu/ natty multiverse
-deb http://us.archive.ubuntu.com/ubuntu/ natty-updates multiverse
-deb http://security.ubuntu.com/ubuntu natty-security main restricted
-deb http://security.ubuntu.com/ubuntu natty-security universe
-deb http://security.ubuntu.com/ubuntu natty-security multiverse
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST% main restricted
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates main restricted
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST% universe
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates universe
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST% multiverse
+deb http://us.archive.ubuntu.com/ubuntu/ %DIST%-updates multiverse
+deb http://security.ubuntu.com/ubuntu %DIST%-security main restricted
+deb http://security.ubuntu.com/ubuntu %DIST%-security universe
+deb http://security.ubuntu.com/ubuntu %DIST%-security multiverse
diff --git a/stack.sh b/stack.sh
index 3365122..7511991 100755
--- a/stack.sh
+++ b/stack.sh
@@ -773,7 +773,7 @@
 screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume"
 screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
 screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
-screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf"
+screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py --flagfile $NOVA_DIR/bin/nova.conf --web . 6080"
 screen_it horizon "cd $HORIZON_DIR && sudo tail -f /var/log/apache2/error.log"
 
 # Install Images
diff --git a/tools/build_libvirt.sh b/tools/build_libvirt.sh
index 26437e0..f39f52d 100755
--- a/tools/build_libvirt.sh
+++ b/tools/build_libvirt.sh
@@ -329,12 +329,6 @@
 RC_LOCAL=$ROOTFS/etc/init.d/zlocal
 cat > $RC_LOCAL <<EOF
 #!/bin/sh -e
-# Reboot if this is our first run to enable console log on $DIST_NAME :(
-if [ ! -e /root/firstlaunch ]; then
-    touch /root/firstlaunch
-    reboot -f
-    exit 0
-fi
 # cloud-init overwrites the hostname with ubuntuhost
 echo $GUEST_NAME > /etc/hostname
 hostname $GUEST_NAME
diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh
index 526fb44..a7fb356 100755
--- a/tools/get_uec_image.sh
+++ b/tools/get_uec_image.sh
@@ -10,6 +10,10 @@
 ROOTSIZE=${ROOTSIZE:-2000}
 MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
 
+# Keep track of the current directory
+TOOLS_DIR=$(cd $(dirname "$0") && pwd)
+TOP_DIR=`cd $TOOLS_DIR/..; pwd`
+
 usage() {
     echo "Usage: $0 - Prepare Ubuntu images"
     echo ""
@@ -31,7 +35,7 @@
         m)  MINIMAL=1
             ;;
         r)  ROOTSIZE=$OPTARG
-            if $(( ROOTSIZE < 2000 )); then
+            if [[ $ROOTSIZE < 2000 ]]; then
                 echo "root size must be greater than 2000MB"
                 exit 1
             fi
@@ -108,7 +112,8 @@
     mount -t ext4 ${NBD}p1 $MNTDIR
 
     # Install our required packages
-    cp -p files/sources.list $MNTDIR/etc/apt/sources.list
+    cp -p $TOP_DIR/files/sources.list $MNTDIR/etc/apt/sources.list
+    sed -e "s,%DIST%,$DIST_NAME,g" -i $MNTDIR/etc/apt/sources.list
     cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
     chroot $MNTDIR apt-get update
     chroot $MNTDIR apt-get install -y $MIN_PKGS
diff --git a/tools/make_image.sh b/tools/make_image.sh
index e957c75..a69f5e3 100755
--- a/tools/make_image.sh
+++ b/tools/make_image.sh
@@ -138,6 +138,7 @@
       --addpkg=$MIN_PKGS \
 
     sudo cp -p files/sources.list $CHROOTDIR/etc/apt/sources.list
+    sed -e "s,%DIST%,$RELEASE,g" -i $CHROOTDIR/etc/apt/sources.list
     sudo chroot $CHROOTDIR apt-get update
 
     exit 0