Merge pull request #89 from cloudbuilders/openrc
Add openrc to make it easier to use cli
diff --git a/stack.sh b/stack.sh
index ada4c70..18206cd 100755
--- a/stack.sh
+++ b/stack.sh
@@ -84,9 +84,10 @@
# sudo privileges and runs as that user.
if [[ $EUID -eq 0 ]]; then
+ ROOTSLEEP=${ROOTSLEEP:-10}
echo "You are running this script as root."
- echo "In 10 seconds, we will create a user 'stack' and run as that user"
- sleep 10
+ echo "In $ROOTSLEEP seconds, we will create a user 'stack' and run as that user"
+ sleep $ROOTSLEEP
# since this script runs as a normal user, we need to give that user
# ability to run sudo
@@ -397,7 +398,7 @@
# Install and start mysql-server
apt_get install mysql-server
# 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:
sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
@@ -546,6 +547,31 @@
mkdir -p $NOVA_DIR/networks
fi
+# Volume Service
+# --------------
+
+if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then
+ #
+ # Configure a default volume group called 'nova-volumes' for the nova-volume
+ # service if it does not yet exist. If you don't wish to use a file backed
+ # volume group, create your own volume group called 'nova-volumes' before
+ # invoking stack.sh.
+ #
+ # By default, the backing file is 2G in size, and is stored in /opt/stack.
+ #
+ if ! sudo vgdisplay | grep -q nova-volumes; then
+ VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-/opt/stack/nova-volumes-backing-file}
+ VOLUME_BACKING_FILE_SIZE=${VOLUME_BACKING_FILE_SIZE:-2052M}
+ truncate -s $VOLUME_BACKING_FILE_SIZE $VOLUME_BACKING_FILE
+ DEV=`sudo losetup -f --show $VOLUME_BACKING_FILE`
+ sudo vgcreate nova-volumes $DEV
+ fi
+
+ # Configure iscsitarget
+ sudo sed 's/ISCSITARGET_ENABLE=false/ISCSITARGET_ENABLE=true/' -i /etc/default/iscsitarget
+ sudo /etc/init.d/iscsitarget restart
+fi
+
function add_nova_flag {
echo "$1" >> $NOVA_DIR/bin/nova.conf
}
@@ -654,28 +680,31 @@
# launch the glance api and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "g-api" ]]; then
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..."
- sleep 1
- done
+ 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
+ echo "g-api did not start"
+ exit 1
+ fi
fi
# launch the keystone and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
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..."
- sleep 1
- done
+ 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
+ echo "keystone did not start"
+ exit 1
+ fi
fi
# launch the nova-api and wait for it to answer before continuing
if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
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..."
- sleep 1
- done
+ 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
+ echo "nova-api did not start"
+ exit 1
+ fi
fi
# 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
@@ -683,6 +712,7 @@
# within the context of our original shell (so our groups won't be updated).
# Use 'sg' to execute nova-compute as a member of the libvirtd group.
screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute"
+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"
diff --git a/tools/build_bm.sh b/tools/build_bm.sh
new file mode 100755
index 0000000..44cf303
--- /dev/null
+++ b/tools/build_bm.sh
@@ -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
diff --git a/tools/build_bm_multi.sh b/tools/build_bm_multi.sh
new file mode 100755
index 0000000..44c0705
--- /dev/null
+++ b/tools/build_bm_multi.sh
@@ -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"
diff --git a/tools/build_kvm.sh b/tools/build_kvm.sh
index 95aff7b..207f86b 100755
--- a/tools/build_kvm.sh
+++ b/tools/build_kvm.sh
@@ -148,18 +148,11 @@
git_clone $KEYSTONE_REPO $COPY_DIR/$DEST/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $COPY_DIR/$DEST/noVNC $NOVNC_BRANCH
-# Back to devstack
-cd $TOP_DIR
-
# Unmount the filesystems
unmount_images
-# Clean up old runs
-cd $VM_DIR
-rm -f $VM_DIR/disk
-
-# Clean up old instance data
-qemu-img create -f qcow2 -b $BASE_IMAGE_COPY disk
+# Back to devstack
+cd $TOP_DIR
# Network configuration variables
BRIDGE=${BRIDGE:-br0}
@@ -169,13 +162,15 @@
CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0}
CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1}
CONTAINER_MAC=${CONTAINER_MAC:-"02:16:3e:07:69:`printf '%02X' $(echo $CONTAINER_IP | sed "s/.*\.//")`"}
+CONTAINER_RAM=${CONTAINER_RAM:-1524288}
+CONTAINER_CORES=${CONTAINER_CORES:-1}
# libvirt.xml configuration
LIBVIRT_XML=libvirt.xml
cat > $LIBVIRT_XML <<EOF
<domain type='kvm'>
<name>$CONTAINER_NAME</name>
- <memory>1524288</memory>
+ <memory>$CONTAINER_RAM</memory>
<os>
<type>hvm</type>
<bootmenu enable='yes'/>
@@ -183,7 +178,7 @@
<features>
<acpi/>
</features>
- <vcpu>1</vcpu>
+ <vcpu>$CONTAINER_CORES</vcpu>
<devices>
<disk type='file'>
<driver type='qcow2'/>
@@ -231,8 +226,20 @@
umount $ROOTFS || echo 'ok'
qemu-nbd -d $NBD || echo 'ok'
-# Mount the instance
+# Clean up old runs
+cd $VM_DIR
+rm -f $VM_DIR/disk
+
+# Create our instance fs
+qemu-img create -f qcow2 -b $BASE_IMAGE_COPY disk
+
+sleep 5
+
qemu-nbd -c $NBD disk
+
+sleep 5
+
+# Mount the instance
mount $NBD $ROOTFS -o offset=32256 -t ext4
# Configure instance network
diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh
index 4d2372b..fc71be8 100755
--- a/tools/build_lxc.sh
+++ b/tools/build_lxc.sh
@@ -38,7 +38,8 @@
WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
-STACKSH_PARAMS=${STACKSH_PARAMS:-}
+# By default, n-vol is disabled for lxc, as iscsitarget doesn't work properly in lxc
+STACKSH_PARAMS=${STACKSH_PARAMS:-"ENABLED_SERVICES=g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit"}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh
index ca7bdd5..be6ca77 100755
--- a/tools/build_ramdisk.sh
+++ b/tools/build_ramdisk.sh
@@ -99,11 +99,10 @@
git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
-# Use this version of devstack?
-if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
- rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
- cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
-fi
+# Use this version of devstack
+rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
+cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
+chroot $CHROOTCACHE/natty-stack chown -R stack $DEST/devstack
# Configure host network for DHCP
mkdir -p $CHROOTCACHE/natty-stack/etc/network