Merge pull request #83 from jeblair/master

Add bare-metal build scripts.
This commit is contained in:
Jesse Andrews 2011-10-21 10:24:59 -07:00
commit 8063e6fe38
3 changed files with 84 additions and 15 deletions

View file

@ -84,9 +84,10 @@ DEST=${DEST:-/opt/stack}
# sudo privileges and runs as that user. # sudo privileges and runs as that user.
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
ROOTSLEEP=${ROOTSLEEP:-10}
echo "You are running this script as root." echo "You are running this script as root."
echo "In 10 seconds, we will create a user 'stack' and run as that user" echo "In $ROOTSLEEP seconds, we will create a user 'stack' and run as that user"
sleep 10 sleep $ROOTSLEEP
# since this script runs as a normal user, we need to give that user # since this script runs as a normal user, we need to give that user
# ability to run sudo # ability to run sudo
@ -397,7 +398,7 @@ EOF
# Install and start mysql-server # Install and start mysql-server
apt_get install mysql-server apt_get install mysql-server
# Update the DB to give user $MYSQL_USER@% full control of the all databases: # Update the DB to give user $MYSQL_USER@% full control of the all databases:
sudo mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';" sudo mysql -uroot -p$MYSQL_PASSWORD -h127.0.0.1 -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
# 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: # 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:
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
@ -654,28 +655,31 @@ fi
# launch the glance api and wait for it to answer before continuing # launch the glance api and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf" screen_it g-api "cd $GLANCE_DIR; bin/glance-api --config-file=etc/glance-api.conf"
while ! wget -q -O- http://$GLANCE_HOSTPORT; do
echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..." echo "Waiting for g-api ($GLANCE_HOSTPORT) to start..."
sleep 1 if ! timeout 60 sh -c "while ! wget -q -O- http://$GLANCE_HOSTPORT; do sleep 1; done"; then
done echo "g-api did not start"
exit 1
fi
fi fi
# launch the keystone and wait for it to answer before continuing # launch the keystone and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d" screen_it key "cd $KEYSTONE_DIR && $KEYSTONE_DIR/bin/keystone --config-file $KEYSTONE_CONF -d"
while ! wget -q -O- http://127.0.0.1:5000; do
echo "Waiting for keystone to start..." echo "Waiting for keystone to start..."
sleep 1 if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:5000; do sleep 1; done"; then
done echo "keystone did not start"
exit 1
fi
fi fi
# launch the nova-api and wait for it to answer before continuing # launch the nova-api and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api" screen_it n-api "cd $NOVA_DIR && $NOVA_DIR/bin/nova-api"
while ! wget -q -O- http://127.0.0.1:8774; do
echo "Waiting for nova-api to start..." echo "Waiting for nova-api to start..."
sleep 1 if ! timeout 60 sh -c "while ! wget -q -O- http://127.0.0.1:8774; do sleep 1; done"; then
done echo "nova-api did not start"
exit 1
fi
fi fi
# Launching nova-compute should be as simple as running ``nova-compute`` but # Launching nova-compute should be as simple as running ``nova-compute`` but
# have to do a little more than that in our script. Since we add the group # have to do a little more than that in our script. Since we add the group

28
tools/build_bm.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Build an OpenStack install on a bare metal machine.
set +x
# Source params
source ./stackrc
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
# Configure the runner
RUN_SH=`mktemp`
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Install and run stack.sh
cd devstack
$STACKSH_PARAMS ./stack.sh
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
scp -r . root@$CONTAINER_IP:devstack
scp $RUN_SH root@$CONTAINER_IP:$RUN_SH
ssh root@$CONTAINER_IP $RUN_SH

37
tools/build_bm_multi.sh Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Build an OpenStack install on several bare metal machines.
SHELL_AFTER_RUN=no
# Variables common amongst all hosts in the cluster
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"
# Helper to launch containers
function run_bm {
# For some reason container names with periods can cause issues :/
CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./tools/build_bm.sh
}
# Launch the head node - headnode uses a non-ip domain name,
# because rabbit won't launch with an ip addr hostname :(
run_bm STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,dash,mysql,rabbit"
# Wait till the head node is up
if [ ! "$TERMINATE" = "1" ]; then
echo "Waiting for head node ($HEAD_HOST) to start..."
if ! timeout 60 sh -c "while ! wget -q -O- http://$HEAD_HOST | grep -q username; do sleep 1; done"; then
echo "Head node did not start"
exit 1
fi
fi
PIDS=""
# Launch the compute hosts in parallel
for compute_host in ${COMPUTE_HOSTS//,/ }; do
run_bm $compute_host $compute_host "ENABLED_SERVICES=n-cpu,n-net,n-api" &
PIDS="$PIDS $!"
done
for x in $PIDS; do
wait $x
done
echo "build_bm_multi complete"