Browse code

Merge remote-tracking branch 'upstream/master'

Dean Troyer authored on 2011/09/17 07:22:35
Showing 3 changed files
... ...
@@ -69,6 +69,11 @@ fi
69 69
 # Destroy the old container
70 70
 lxc-destroy -n $CONTAINER
71 71
 
72
+# If this call is to TERMINATE the container then exit
73
+if [ "$TERMINATE" = "1" ]; then
74
+    exit
75
+fi
76
+
72 77
 # Create the container
73 78
 lxc-create -n $CONTAINER -t natty -f $LXC_CONF
74 79
 
... ...
@@ -4,16 +4,21 @@ HEAD_HOST=${HEAD_HOST:-192.168.1.52}
4 4
 COMPUTE_HOSTS=${COMPUTE_HOSTS:-192.168.1.53,192.168.1.54}
5 5
 
6 6
 # Networking params
7
-NAMESERVER=${NAMESERVER:-192.168.2.1}
7
+NAMESERVER=${NAMESERVER:-192.168.1.1}
8 8
 GATEWAY=${GATEWAY:-192.168.1.1}
9
+NETMASK=${NETMASK:-255.255.255.0}
10
+FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30}
11
+
12
+# Setting this to 1 shuts down and destroys our containers without relaunching.
13
+TERMINATE=${TERMINATE:-0}
9 14
 
10 15
 # Variables common amongst all hosts in the cluster
11
-COMMON_VARS="MYSQL_HOST=$HEAD_HOST RABBIT_HOST=$HEAD_HOST GLANCE_HOSTPORT=$HEAD_HOST:9292 NET_MAN=FlatDHCPManager FLAT_INTERFACE=eth0"
16
+COMMON_VARS="MYSQL_HOST=$HEAD_HOST RABBIT_HOST=$HEAD_HOST GLANCE_HOSTPORT=$HEAD_HOST:9292 NET_MAN=FlatDHCPManager FLAT_INTERFACE=eth0 FLOATING_RANGE=$FLOATING_RANGE MULTI_HOST=1"
12 17
 
13 18
 # Helper to launch containers
14 19
 function run_lxc {
15 20
     # For some reason container names with periods can cause issues :/
16
-    CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER STACKSH_PARAMS="$COMMON_VARS $3" ./build_lxc.sh
21
+    CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./build_lxc.sh
17 22
 }
18 23
 
19 24
 # Launch the head node - headnode uses a non-ip domain name,
... ...
@@ -21,10 +26,12 @@ function run_lxc {
21 21
 run_lxc STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,dash,mysql,rabbit"
22 22
 
23 23
 # Wait till the head node is up
24
-while ! wget -q -O- http://$HEAD_HOST | grep -q username; do
25
-    echo "Waiting for head node ($HEAD_HOST) to start..."
26
-    sleep 5
27
-done
24
+if [ ! "$TERMINATE" = "1" ]; then
25
+    while ! wget -q -O- http://$HEAD_HOST | grep -q username; do
26
+        echo "Waiting for head node ($HEAD_HOST) to start..."
27
+        sleep 5
28
+    done
29
+fi
28 30
 
29 31
 # Launch the compute hosts
30 32
 for compute_host in ${COMPUTE_HOSTS//,/ }; do
... ...
@@ -308,6 +308,9 @@ add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
308 308
 if [ -n "$FLAT_INTERFACE" ]; then
309 309
     add_nova_flag "--flat_interface=$FLAT_INTERFACE"
310 310
 fi
311
+if [ -n "$MULTI_HOST" ]; then
312
+    add_nova_flag "--multi_host=$MULTI_HOST"
313
+fi
311 314
 
312 315
 # create a new named screen to store things in
313 316
 screen -d -m -S nova -t nova
... ...
@@ -319,7 +322,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
319 319
     # device - used to manage qcow images)
320 320
     sudo modprobe nbd || true
321 321
     sudo modprobe kvm || true
322
-    # user needs to be member of libvirtd group for nova-compute to use libvirt
322
+    # User needs to be member of libvirtd group for nova-compute to use libvirt.
323 323
     sudo usermod -a -G libvirtd `whoami`
324 324
     # if kvm wasn't running before we need to restart libvirt to enable it
325 325
     sudo /etc/init.d/libvirt-bin restart
... ...
@@ -386,9 +389,9 @@ fi
386 386
 # so send the start command by forcing text into the window.
387 387
 # Only run the services specified in ``ENABLED_SERVICES``
388 388
 
389
-NL=`echo -ne '\015'`
390
-
389
+# our screen helper to launch a service in a hidden named screen
391 390
 function screen_it {
391
+    NL=`echo -ne '\015'`
392 392
     if [[ "$ENABLED_SERVICES" =~ "$1" ]]; then
393 393
         screen -S nova -X screen -t $1
394 394
         screen -S nova -p $1 -X stuff "$2$NL"
... ...
@@ -399,7 +402,13 @@ screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.con
399 399
 screen_it g-reg "cd $GLANCE_DIR; bin/glance-registry --config-file=etc/glance-registry.conf"
400 400
 screen_it key "$KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF"
401 401
 screen_it n-api "$NOVA_DIR/bin/nova-api"
402
-screen_it n-cpu "$NOVA_DIR/bin/nova-compute"
402
+# Launching nova-compute should be as simple as running ``nova-compute`` but 
403
+# have to do a little more than that in our script.  Since we add the group 
404
+# ``libvirtd`` to our user in this script, when nova-compute is run it is
405
+# within the context of our original shell (so our groups won't be updated). 
406
+# We can send the command nova-compute to the ``newgrp`` command to execute
407
+# in a specific context.
408
+screen_it n-cpu "echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd"
403 409
 screen_it n-net "$NOVA_DIR/bin/nova-network"
404 410
 screen_it n-sch "$NOVA_DIR/bin/nova-scheduler"
405 411
 # nova-vncproxy binds a privileged port, and so needs sudo
... ...
@@ -418,14 +427,13 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
418 418
 
419 419
     # extract ami-tty/image, aki-tty/image & ari-tty/image
420 420
     mkdir -p $FILES/images
421
-    cd $FILES/images
422
-    tar -zxf $DEST/tty.tgz
421
+    tar -zxf $FILES/tty.tgz -C $FILES/images
423 422
 
424 423
     # add images to glance 
425 424
     # FIXME: kernel/ramdisk is hardcoded - use return result from add
426
-    glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < aki-tty/image 
427
-    glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < ari-tty/image 
428
-    glance add name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < ami-tty/image
425
+    glance add name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image 
426
+    glance add name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image 
427
+    glance add name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < $FILES/images/ami-tty/image
429 428
 fi
430 429
 
431 430
 # Using the cloud