Browse code

Add bare-metal build scripts.

Add ROOTSLEEP parameter to avoid 10 second sleep.

Add host argument to mysql password change command so that it
will still work if mysql is already installed and running
(otherwise, the my.cnf created immediately prior takes precedence).

Add timeouts when waiting for things to start so they aren't in
infinite loops.

James E. Blair authored on 2011/10/11 23:26:29
Showing 3 changed files
... ...
@@ -84,9 +84,10 @@ DEST=${DEST:-/opt/stack}
84 84
 # sudo privileges and runs as that user.
85 85
 
86 86
 if [[ $EUID -eq 0 ]]; then
87
+    ROOTSLEEP=${ROOTSLEEP:-10}
87 88
     echo "You are running this script as root."
88
-    echo "In 10 seconds, we will create a user 'stack' and run as that user"
89
-    sleep 10 
89
+    echo "In $ROOTSLEEP seconds, we will create a user 'stack' and run as that user"
90
+    sleep $ROOTSLEEP
90 91
 
91 92
     # since this script runs as a normal user, we need to give that user
92 93
     # ability to run sudo
... ...
@@ -385,7 +386,7 @@ EOF
385 385
     # Install and start mysql-server
386 386
     sudo apt-get -y -q install mysql-server
387 387
     # Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
388
-    sudo mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
388
+    sudo mysql -uroot -p$MYSQL_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
389 389
 
390 390
     # Edit /etc/mysql/my.cnf to change ‘bind-address’ from localhost (127.0.0.1) to any (0.0.0.0) and restart the mysql service:
391 391
     sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
... ...
@@ -642,28 +643,31 @@ fi
642 642
 # launch the glance api and wait for it to answer before continuing
643 643
 if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
644 644
     screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
645
-    while ! wget -q -O- http://$GLANCE_HOSTPORT; do
646
-        echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
647
-        sleep 1
648
-    done
645
+    echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
646
+    if ! timeout 600 sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
647
+      echo "g-api did not start"
648
+      exit 1
649
+    fi
649 650
 fi
650 651
 
651 652
 # launch the keystone and wait for it to answer before continuing
652 653
 if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
653 654
     screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d"
654
-    while ! wget -q -O- http://127.0.0.1:5000; do
655
-        echo "Waiting for keystone to start..."
656
-        sleep 1
657
-    done
655
+    echo "Waiting for keystone to start..."
656
+    if ! timeout 600 sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then
657
+      echo "keystone did not start"
658
+      exit 1
659
+    fi
658 660
 fi
659 661
 
660 662
 # launch the nova-api and wait for it to answer before continuing
661 663
 if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
662 664
     screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
663
-    while ! wget -q -O- http://127.0.0.1:8774; do
664
-        echo "Waiting for nova-api to start..."
665
-        sleep 1
666
-    done
665
+    echo "Waiting for nova-api to start..."
666
+    if ! timeout 600 sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
667
+      echo "nova-api did not start"
668
+      exit 1
669
+    fi
667 670
 fi
668 671
 # Launching nova-compute should be as simple as running ``nova-compute`` but
669 672
 # have to do a little more than that in our script.  Since we add the group
670 673
new file mode 100755
... ...
@@ -0,0 +1,28 @@
0
+#!/usr/bin/env bash
1
+# Build an OpenStack install on a bare metal machine.
2
+set +x
3
+
4
+# Source params
5
+source ./stackrc
6
+
7
+# Param string to pass to stack.sh.  Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
8
+STACKSH_PARAMS=${STACKSH_PARAMS:-}
9
+
10
+# Option to use the version of devstack on which we are currently working
11
+USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
12
+
13
+# Configure the runner
14
+RUN_SH=`mktemp`
15
+cat > $RUN_SH <<EOF
16
+#!/usr/bin/env bash
17
+# Install and run stack.sh
18
+cd devstack
19
+$STACKSH_PARAMS ./stack.sh
20
+EOF
21
+
22
+# Make the run.sh executable
23
+chmod 755 $RUN_SH
24
+
25
+scp -r . root@$CONTAINER_IP:devstack
26
+scp $RUN_SH root@$CONTAINER_IP:$RUN_SH
27
+ssh root@$CONTAINER_IP $RUN_SH
0 28
new file mode 100755
... ...
@@ -0,0 +1,37 @@
0
+#!/usr/bin/env bash
1
+# Build an OpenStack install on several bare metal machines.
2
+SHELL_AFTER_RUN=no
3
+
4
+# Variables common amongst all hosts in the cluster
5
+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 SHELL_AFTER_RUN=$SHELL_AFTER_RUN"
6
+
7
+# Helper to launch containers
8
+function run_bm {
9
+    # For some reason container names with periods can cause issues :/
10
+    CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./tools/build_bm.sh
11
+}
12
+
13
+# Launch the head node - headnode uses a non-ip domain name,
14
+# because rabbit won't launch with an ip addr hostname :(
15
+run_bm STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,dash,mysql,rabbit"
16
+
17
+# Wait till the head node is up
18
+if [ ! "$TERMINATE" = "1" ]; then
19
+    echo "Waiting for head node ($HEAD_HOST) to start..."
20
+    if ! timeout 600 sh -c "while ! wget -q -O- http://$HEAD_HOST | grep -q username; do sleep 1; done"; then
21
+      echo "Head node did not start"
22
+      exit 1
23
+    fi
24
+fi
25
+
26
+PIDS=""
27
+# Launch the compute hosts in parallel
28
+for compute_host in ${COMPUTE_HOSTS//,/ }; do
29
+    run_bm $compute_host $compute_host "ENABLED_SERVICES=n-cpu,n-net,n-api" &
30
+    PIDS="$PIDS $!"
31
+done
32
+
33
+for x in $PIDS; do
34
+    wait $x
35
+done
36
+echo "build_bm_multi complete"