Merge pull request #168 from cloudbuilders/uec-simple
Uec simple
diff --git a/stack.sh b/stack.sh
index ca8ab41..0950e64 100755
--- a/stack.sh
+++ b/stack.sh
@@ -174,6 +174,9 @@
HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
fi
+# Service startup timeout
+SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
+
# Generic helper to configure passwords
function read_password {
set +o xtrace
@@ -929,7 +932,7 @@
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
- if ! timeout 60 sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
+ if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
echo "g-api did not start"
exit 1
fi
@@ -939,7 +942,7 @@
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d"
echo "Waiting for keystone to start..."
- if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then
+ if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then
echo "keystone did not start"
exit 1
fi
@@ -949,7 +952,7 @@
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
echo "Waiting for nova-api to start..."
- if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
+ if ! timeout $SERVICE_TIMEOUT sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
echo "nova-api did not start"
exit 1
fi
diff --git a/tools/get_uec_image.sh b/tools/get_uec_image.sh
index cb59b9a..7b95aab 100755
--- a/tools/get_uec_image.sh
+++ b/tools/get_uec_image.sh
@@ -14,6 +14,9 @@
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
+# exit on error to stop unexpected errors
+set -o errexit
+
usage() {
echo "Usage: $0 - Prepare Ubuntu images"
echo ""
@@ -44,6 +47,14 @@
trap 2; kill -2 $$
}
+# apt-get wrapper to just get arguments set correctly
+function apt_get() {
+ local sudo="sudo"
+ [ "$(id -u)" = "0" ] && sudo="env"
+ $sudo DEBIAN_FRONTEND=noninteractive apt-get \
+ --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
+}
+
while getopts f:hmr: c; do
case $c in
f) FORMAT=$OPTARG
@@ -107,7 +118,14 @@
;;
esac
-trap cleanup SIGHUP SIGINT SIGTERM
+trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT
+
+# Check for dependencies
+
+if [ ! -x "`which qemu-img`" -o ! -x "`which qemu-nbd`" ]; then
+ # Missing KVM?
+ apt_get install qemu-kvm
+fi
# Prepare the base image
diff --git a/tools/xen/build_domU.sh b/tools/xen/build_domU.sh
index 65049af..6362849 100755
--- a/tools/xen/build_domU.sh
+++ b/tools/xen/build_domU.sh
@@ -226,16 +226,21 @@
SR_UUID=`xe sr-list --minimal name-label="Local storage"`
xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
-# Uninstall previous runs
-xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
-# Destroy any instances that were launched
-for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
- echo "Shutting down nova instance $uuid"
- xe vm-unpause uuid=$uuid || true
- xe vm-shutdown uuid=$uuid
- xe vm-destroy uuid=$uuid
-done
+# Shutdown previous runs
+DO_SHUTDOWN=${DO_SHUTDOWN:-1}
+if [ "$DO_SHUTDOWN" = "1" ]; then
+ # Shutdown all domU's that created previously
+ xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
+
+ # Destroy any instances that were launched
+ for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
+ echo "Shutting down nova instance $uuid"
+ xe vm-unpause uuid=$uuid || true
+ xe vm-shutdown uuid=$uuid
+ xe vm-destroy uuid=$uuid
+ done
+fi
# Path to head xva. By default keep overwriting the same one to save space
USE_SEPARATE_XVAS=${USE_SEPARATE_XVAS:-0}
diff --git a/tools/xen/build_domU_multi.sh b/tools/xen/build_domU_multi.sh
new file mode 100755
index 0000000..130bec5
--- /dev/null
+++ b/tools/xen/build_domU_multi.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+# Echo commands
+set -o xtrace
+
+# Head node host, which runs glance, api, keystone
+HEAD_PUB_IP=${HEAD_PUB_IP:-192.168.1.57}
+HEAD_MGT_IP=${HEAD_MGT_IP:-172.16.100.57}
+
+COMPUTE_PUB_IP=${COMPUTE_PUB_IP:-192.168.1.58}
+COMPUTE_MGT_IP=${COMPUTE_MGT_IP:-172.16.100.58}
+
+# Networking params
+FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30}
+
+# Variables common amongst all hosts in the cluster
+COMMON_VARS="$STACKSH_PARAMS MYSQL_HOST=$HEAD_MGT_IP RABBIT_HOST=$HEAD_MGT_IP GLANCE_HOSTPORT=$HEAD_MGT_IP:9292 FLOATING_RANGE=$FLOATING_RANGE"
+
+# Helper to launch containers
+function build_domU {
+ GUEST_NAME=$1 PUB_IP=$2 MGT_IP=$3 DO_SHUTDOWN=$4 TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $5" ./build_domU.sh
+}
+
+# Launch the head node - headnode uses a non-ip domain name,
+# because rabbit won't launch with an ip addr hostname :(
+build_domU HEADNODE $HEAD_PUB_IP $HEAD_MGT_IP 1 "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,horizon,mysql,rabbit"
+
+# Wait till the head node is up
+while ! curl -L http://$HEAD_PUB_IP | grep -q username; do
+ echo "Waiting for head node ($HEAD_PUB_IP) to start..."
+ sleep 5
+done
+
+# Build the HA compute host
+build_domU $COMPUTE_PUB_IP $COMPUTE_PUB_IP $COMPUTE_MGT_IP 0 "ENABLED_SERVICES=n-cpu,n-net,n-api"