xenapi: enable user interaction with stack.sh

In XenServer, devstack runs inside a virtual machine. This makes it hard
for the user to interact with stack.sh should a parameter be missing.
This change will create an upstart job (devstack) that runs
stack.sh with console enabled so user can interact with it by running
vncviewer or using XenCenter.

Logging the output is also disabled, stamp files are used instead to
detect the script run status in case install_os_domU.sh is used.

As run.sh.log is removed, standard devstack logging should be used.

The change also removes the environment settings from run.sh, as they
are not needed, they should be specified in localrc. This way user
cannot get different experiences by using unstack.sh/stack.sh or run.sh

Also a proper unstack.sh is called instead of killing screen in run.sh

Change-Id: I7eb12bd74746cc7a1db3aa9fd68ece645a50001d
This commit is contained in:
Mate Lakat 2013-09-24 17:35:00 +01:00
parent 5a9609bed3
commit 93f3b8693a
2 changed files with 41 additions and 23 deletions

View File

@ -93,13 +93,34 @@ mkdir -p $STAGING_DIR/opt/stack/devstack
tar xf /tmp/devstack.tar -C $STAGING_DIR/opt/stack/devstack
cd $TOP_DIR
# Run devstack on launch
cat <<EOF >$STAGING_DIR/etc/rc.local
# network restart required for getting the right gateway
/etc/init.d/networking restart
chown -R $STACK_USER /opt/stack
su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" $STACK_USER
exit 0
# Create an upstart job (task) for devstack, which can interact with the console
cat >$STAGING_DIR/etc/init/devstack.conf << EOF
start on stopped rc RUNLEVEL=[2345]
console output
task
pre-start script
rm -f /var/run/devstack.succeeded
end script
script
initctl stop hvc0 || true
# Read any leftover characters from standard input
while read -n 1 -s -t 0.1 -r ignored; do
true
done
clear
chown -R $STACK_USER /opt/stack
if su -c "/opt/stack/run.sh" $STACK_USER; then
touch /var/run/devstack.succeeded
fi
initctl start hvc0 > /dev/null 2>&1
end script
EOF
# Configure the hostname
@ -138,8 +159,9 @@ fi
# Configure run.sh
cat <<EOF >$STAGING_DIR/opt/stack/run.sh
#!/bin/bash
set -eux
cd /opt/stack/devstack
killall screen
VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=$MULTI_HOST HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh
./unstack.sh || true
./stack.sh
EOF
chmod 755 $STAGING_DIR/opt/stack/run.sh

View File

@ -350,25 +350,20 @@ COPYENV=${COPYENV:-1}
if [ "$WAIT_TILL_LAUNCH" = "1" ] && [ -e ~/.ssh/id_rsa.pub ] && [ "$COPYENV" = "1" ]; then
set +x
echo "VM Launched - Waiting for startup script"
# wait for log to appear
while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "[ -e run.sh.log ]"; do
echo "VM Launched - Waiting for devstack to start"
while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "service devstack status | grep -q running"; do
sleep 10
done
echo -n "Running"
while [ `ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS pgrep -c run.sh` -ge 1 ]
do
echo -n "devstack is running"
while ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "service devstack status | grep -q running"; do
sleep 10
echo -n "."
done
echo "done!"
set -x
# output the run.sh.log
ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log'
# Fail if the expected text is not found
ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log' | grep -q 'stack.sh completed in'
# Fail if devstack did not succeed
ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'test -e /var/run/devstack.succeeded'
set +x
echo "################################################################################"
@ -382,11 +377,12 @@ else
echo ""
echo "All Finished!"
echo "Now, you can monitor the progress of the stack.sh installation by "
echo "tailing /opt/stack/run.sh.log from within your domU."
echo "looking at the console of your domU / checking the log files."
echo ""
echo "ssh into your domU now: 'ssh stack@$OS_VM_MANAGEMENT_ADDRESS' using your password"
echo "and then do: 'tail -f /opt/stack/run.sh.log'"
echo "and then do: 'sudo service devstack status' to check if devstack is still running."
echo "Check that /var/run/devstack.succeeded exists"
echo ""
echo "When the script completes, you can then visit the OpenStack Dashboard"
echo "When devstack completes, you can visit the OpenStack Dashboard"
echo "at http://$OS_VM_SERVICES_ADDRESS, and contact other services at the usual ports."
fi