blob: 33dc26f1bbd4763bd21595dde16d0481967089ba [file] [log] [blame]
Anthony Youngb62b4ca2011-10-26 22:29:08 -07001#!/bin/bash
2
Mate Lakat0b3804b2013-05-07 16:58:17 +01003# This script must be run on a XenServer or XCP machine
John Garbuttdaadf742012-04-27 18:28:28 +01004#
5# It creates a DomU VM that runs OpenStack services
6#
7# For more details see: README.md
8
Renuka Apte0af143b2012-04-02 15:46:53 -07009set -o errexit
Mate Lakat0b3804b2013-05-07 16:58:17 +010010set -o nounset
John Garbuttdaadf742012-04-27 18:28:28 +010011set -o xtrace
Renuka Apte0af143b2012-04-02 15:46:53 -070012
Mate Lakat1ca490c2013-09-19 10:03:36 +010013export LC_ALL=C
14
Anthony Youngb62b4ca2011-10-26 22:29:08 -070015# Abort if localrc is not set
16if [ ! -e ../../localrc ]; then
17 echo "You must have a localrc with ALL necessary passwords defined before proceeding."
18 echo "See the xen README for required passwords."
19 exit 1
20fi
21
Anthony Youngaf6ed6b2011-11-02 07:50:27 -050022# This directory
Mate Lakata8bf0f22013-03-07 18:37:31 +000023THIS_DIR=$(cd $(dirname "$0") && pwd)
Anthony Youngaf6ed6b2011-11-02 07:50:27 -050024
Anthony Youngb3e2f332012-03-16 17:01:49 -070025# Source lower level functions
Mate Lakata8bf0f22013-03-07 18:37:31 +000026. $THIS_DIR/../../functions
Anthony Youngb3e2f332012-03-16 17:01:49 -070027
John Garbuttdaadf742012-04-27 18:28:28 +010028# Include onexit commands
Mate Lakata8bf0f22013-03-07 18:37:31 +000029. $THIS_DIR/scripts/on_exit.sh
John Garbuttdaadf742012-04-27 18:28:28 +010030
Mate Lakat57e3da92013-03-22 16:34:05 +000031# xapi functions
32. $THIS_DIR/functions
33
Bob Ball46691222013-08-12 17:28:50 +010034# Determine what system we are running on.
35# Might not be XenServer if we're using xenserver-core
36GetDistro
37
John Garbuttdaadf742012-04-27 18:28:28 +010038#
39# Get Settings
40#
41
Anthony Youngb3e2f332012-03-16 17:01:49 -070042# Source params - override xenrc params in your localrc to suit your taste
Mate Lakat0b3804b2013-05-07 16:58:17 +010043source $THIS_DIR/xenrc
Anthony Youngaf6ed6b2011-11-02 07:50:27 -050044
Renuka Apte0af143b2012-04-02 15:46:53 -070045xe_min()
46{
Sean Dague0b865a52013-10-22 11:37:35 -040047 local cmd="$1"
48 shift
49 xe "$cmd" --minimal "$@"
Renuka Apte0af143b2012-04-02 15:46:53 -070050}
Anthony Youngb62b4ca2011-10-26 22:29:08 -070051
John Garbuttdaadf742012-04-27 18:28:28 +010052#
53# Prepare Dom0
54# including installing XenAPI plugins
55#
56
Mate Lakata8bf0f22013-03-07 18:37:31 +000057cd $THIS_DIR
John Garbuttdaadf742012-04-27 18:28:28 +010058
Mate Lakatd8511032013-07-03 10:44:44 +010059# Die if multiple hosts listed
60if have_multiple_hosts; then
61 cat >&2 << EOF
62ERROR: multiple hosts found. This might mean that the XenServer is a member
63of a pool - Exiting.
64EOF
65 exit 1
66fi
67
Mate Lakat57e3da92013-03-22 16:34:05 +000068# Install plugins
John Garbuttdaadf742012-04-27 18:28:28 +010069
Mate Lakat57e3da92013-03-22 16:34:05 +000070## Nova plugins
71NOVA_ZIPBALL_URL=${NOVA_ZIPBALL_URL:-$(zip_snapshot_location $NOVA_REPO $NOVA_BRANCH)}
Mate Lakatabe56ee2013-07-24 11:06:27 +010072EXTRACTED_NOVA=$(extract_remote_zipball "$NOVA_ZIPBALL_URL")
73install_xapi_plugins_from "$EXTRACTED_NOVA"
74
75LOGROT_SCRIPT=$(find "$EXTRACTED_NOVA" -name "rotate_xen_guest_logs.sh" -print)
76if [ -n "$LOGROT_SCRIPT" ]; then
77 mkdir -p "/var/log/xen/guest"
78 cp "$LOGROT_SCRIPT" /root/consolelogrotate
79 chmod +x /root/consolelogrotate
80 echo "* * * * * /root/consolelogrotate" | crontab
81fi
82
83rm -rf "$EXTRACTED_NOVA"
Maru Newby2298ca42012-10-25 23:46:42 +000084
Mate Lakat57e3da92013-03-22 16:34:05 +000085## Install the netwrap xapi plugin to support agent control of dom0 networking
Maru Newby2298ca42012-10-25 23:46:42 +000086if [[ "$ENABLED_SERVICES" =~ "q-agt" && "$Q_PLUGIN" = "openvswitch" ]]; then
Mark McClainb05c8762013-07-06 23:29:39 -040087 NEUTRON_ZIPBALL_URL=${NEUTRON_ZIPBALL_URL:-$(zip_snapshot_location $NEUTRON_REPO $NEUTRON_BRANCH)}
Mate Lakatabe56ee2013-07-24 11:06:27 +010088 EXTRACTED_NEUTRON=$(extract_remote_zipball "$NEUTRON_ZIPBALL_URL")
89 install_xapi_plugins_from "$EXTRACTED_NEUTRON"
90 rm -rf "$EXTRACTED_NEUTRON"
Maru Newby2298ca42012-10-25 23:46:42 +000091fi
92
Mate Lakat57e3da92013-03-22 16:34:05 +000093create_directory_for_kernels
Bob Ball39aeda22013-06-17 12:51:33 +010094create_directory_for_images
John Garbuttdaadf742012-04-27 18:28:28 +010095
96#
97# Configure Networking
98#
Bob Ball78ef1f32013-09-29 11:36:28 +010099
100MGT_NETWORK=`xe pif-list management=true params=network-uuid minimal=true`
101MGT_BRIDGE_OR_NET_NAME=`xe network-list uuid=$MGT_NETWORK params=bridge minimal=true`
102
Mate Lakat9e326772013-05-08 16:42:22 +0100103setup_network "$VM_BRIDGE_OR_NET_NAME"
104setup_network "$MGT_BRIDGE_OR_NET_NAME"
105setup_network "$PUB_BRIDGE_OR_NET_NAME"
Anthony Youngb62b4ca2011-10-26 22:29:08 -0700106
Mark McClainb05c8762013-07-06 23:29:39 -0400107# With neutron, one more network is required, which is internal to the
Mate Lakatf652e0f2013-05-21 18:12:48 +0100108# hypervisor, and used by the VMs
Mark McClainb05c8762013-07-06 23:29:39 -0400109if is_service_enabled neutron; then
Mate Lakatf652e0f2013-05-21 18:12:48 +0100110 setup_network "$XEN_INT_BRIDGE_OR_NET_NAME"
111fi
112
Mate Lakat9e326772013-05-08 16:42:22 +0100113if parameter_is_specified "FLAT_NETWORK_BRIDGE"; then
114 cat >&2 << EOF
115ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file
116This is considered as an error, as its value will be derived from the
117VM_BRIDGE_OR_NET_NAME variable's value.
118EOF
119 exit 1
Anthony Youngb62b4ca2011-10-26 22:29:08 -0700120fi
121
Mate Lakat9e326772013-05-08 16:42:22 +0100122if ! xenapi_is_listening_on "$MGT_BRIDGE_OR_NET_NAME"; then
123 cat >&2 << EOF
124ERROR: XenAPI does not have an assigned IP address on the management network.
125please review your XenServer network configuration / localrc file.
126EOF
127 exit 1
128fi
129
130HOST_IP=$(xenapi_ip_on "$MGT_BRIDGE_OR_NET_NAME")
John Garbuttdaadf742012-04-27 18:28:28 +0100131
132# Set up ip forwarding, but skip on xcp-xapi
John Garbuttd8f1a872012-06-26 11:16:38 +0100133if [ -a /etc/sysconfig/network ]; then
John Garbuttdaadf742012-04-27 18:28:28 +0100134 if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
Sean Dague0b865a52013-10-22 11:37:35 -0400135 # FIXME: This doesn't work on reboot!
136 echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
John Garbuttdaadf742012-04-27 18:28:28 +0100137 fi
138fi
Anthony Youngb62b4ca2011-10-26 22:29:08 -0700139# Also, enable ip forwarding in rc.local, since the above trick isn't working
140if ! grep -q "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
141 echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
142fi
Anthony Youngb62b4ca2011-10-26 22:29:08 -0700143# Enable ip forwarding at runtime as well
144echo 1 > /proc/sys/net/ipv4/ip_forward
145
John Garbuttdaadf742012-04-27 18:28:28 +0100146
147#
Anthony Young346e4912011-11-05 00:22:47 -0500148# Shutdown previous runs
John Garbuttdaadf742012-04-27 18:28:28 +0100149#
150
Anthony Young346e4912011-11-05 00:22:47 -0500151DO_SHUTDOWN=${DO_SHUTDOWN:-1}
John Garbuttdaadf742012-04-27 18:28:28 +0100152CLEAN_TEMPLATES=${CLEAN_TEMPLATES:-false}
Anthony Young346e4912011-11-05 00:22:47 -0500153if [ "$DO_SHUTDOWN" = "1" ]; then
Anthony Young40b57372011-11-05 00:30:07 -0500154 # Shutdown all domU's that created previously
John Garbuttdaadf742012-04-27 18:28:28 +0100155 clean_templates_arg=""
156 if $CLEAN_TEMPLATES; then
157 clean_templates_arg="--remove-templates"
158 fi
159 ./scripts/uninstall-os-vpx.sh $clean_templates_arg
Anthony Young346e4912011-11-05 00:22:47 -0500160
161 # Destroy any instances that were launched
162 for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
163 echo "Shutting down nova instance $uuid"
Mate Lakat0d97cbe2013-07-29 09:41:50 +0100164 xe vm-uninstall uuid=$uuid force=true
Anthony Young346e4912011-11-05 00:22:47 -0500165 done
Anthony Youngfa4ecc62011-11-11 10:23:22 -0800166
167 # Destroy orphaned vdis
168 for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do
169 xe vdi-destroy uuid=$uuid
170 done
Anthony Young346e4912011-11-05 00:22:47 -0500171fi
Anthony Youngb62b4ca2011-10-26 22:29:08 -0700172
Renuka Apte0af143b2012-04-02 15:46:53 -0700173
John Garbuttdaadf742012-04-27 18:28:28 +0100174#
175# Create Ubuntu VM template
176# and/or create VM from template
177#
Renuka Apte0af143b2012-04-02 15:46:53 -0700178
John Garbuttdaadf742012-04-27 18:28:28 +0100179GUEST_NAME=${GUEST_NAME:-"DevStackOSDomU"}
Mate Lakatc02b2f82013-07-30 19:43:10 +0100180TNAME="jeos_template_for_devstack"
181SNAME_TEMPLATE="jeos_snapshot_for_devstack"
John Garbuttdaadf742012-04-27 18:28:28 +0100182SNAME_FIRST_BOOT="before_first_boot"
183
184function wait_for_VM_to_halt() {
Bob Ball63c6c2b2013-01-24 13:13:51 +0000185 set +x
186 echo "Waiting for the VM to halt. Progress in-VM can be checked with vncviewer:"
187 mgmt_ip=$(echo $XENAPI_CONNECTION_URL | tr -d -c '1234567890.')
188 domid=$(xe vm-list name-label="$GUEST_NAME" params=dom-id minimal=true)
189 port=$(xenstore-read /local/domain/$domid/console/vnc-port)
Mate Lakat97621a12013-08-30 13:12:17 +0100190 echo "vncviewer -via root@$mgmt_ip localhost:${port:2}"
Renuka Apte0af143b2012-04-02 15:46:53 -0700191 while true
192 do
193 state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
194 if [ -n "$state" ]
195 then
196 break
197 else
Bob Ball63c6c2b2013-01-24 13:13:51 +0000198 echo -n "."
John Garbuttdaadf742012-04-27 18:28:28 +0100199 sleep 20
Renuka Apte0af143b2012-04-02 15:46:53 -0700200 fi
201 done
Bob Ball63c6c2b2013-01-24 13:13:51 +0000202 set -x
John Garbuttdaadf742012-04-27 18:28:28 +0100203}
Renuka Apte0af143b2012-04-02 15:46:53 -0700204
John Garbuttdaadf742012-04-27 18:28:28 +0100205templateuuid=$(xe template-list name-label="$TNAME")
206if [ -z "$templateuuid" ]; then
207 #
208 # Install Ubuntu over network
209 #
Bob Ball78ef1f32013-09-29 11:36:28 +0100210 UBUNTU_INST_BRIDGE_OR_NET_NAME=${UBUNTU_INST_BRIDGE_OR_NET_NAME:-"$MGT_BRIDGE_OR_NET_NAME"}
John Garbuttdaadf742012-04-27 18:28:28 +0100211
John Garbuttdaadf742012-04-27 18:28:28 +0100212 # always update the preseed file, incase we have a newer one
213 PRESEED_URL=${PRESEED_URL:-""}
214 if [ -z "$PRESEED_URL" ]; then
215 PRESEED_URL="${HOST_IP}/devstackubuntupreseed.cfg"
216 HTTP_SERVER_LOCATION="/opt/xensource/www"
217 if [ ! -e $HTTP_SERVER_LOCATION ]; then
218 HTTP_SERVER_LOCATION="/var/www/html"
219 mkdir -p $HTTP_SERVER_LOCATION
220 fi
Mate Lakata8bf0f22013-03-07 18:37:31 +0000221 cp -f $THIS_DIR/devstackubuntupreseed.cfg $HTTP_SERVER_LOCATION
Mate Lakatd3740f72013-05-09 15:02:21 +0100222
223 sed \
224 -e "s,\(d-i mirror/http/hostname string\).*,\1 $UBUNTU_INST_HTTP_HOSTNAME,g" \
225 -e "s,\(d-i mirror/http/directory string\).*,\1 $UBUNTU_INST_HTTP_DIRECTORY,g" \
226 -e "s,\(d-i mirror/http/proxy string\).*,\1 $UBUNTU_INST_HTTP_PROXY,g" \
227 -i "${HTTP_SERVER_LOCATION}/devstackubuntupreseed.cfg"
John Garbuttdaadf742012-04-27 18:28:28 +0100228 fi
229
John Garbuttd8f1a872012-06-26 11:16:38 +0100230 # Update the template
Mate Lakata8bf0f22013-03-07 18:37:31 +0000231 $THIS_DIR/scripts/install_ubuntu_template.sh $PRESEED_URL
John Garbuttdaadf742012-04-27 18:28:28 +0100232
Mate Lakat2f524bd2013-06-19 12:32:23 +0100233 # create a new VM from the given template with eth0 attached to the given
234 # network
Mate Lakat9e326772013-05-08 16:42:22 +0100235 $THIS_DIR/scripts/install-os-vpx.sh \
236 -t "$UBUNTU_INST_TEMPLATE_NAME" \
Mate Lakat2f524bd2013-06-19 12:32:23 +0100237 -n "$UBUNTU_INST_BRIDGE_OR_NET_NAME" \
Mate Lakat16ed0682013-08-30 13:28:31 +0100238 -l "$GUEST_NAME"
239
240 set_vm_memory "$GUEST_NAME" "$OSDOMU_MEM_MB"
241
242 xe vm-start vm="$GUEST_NAME"
John Garbuttdaadf742012-04-27 18:28:28 +0100243
244 # wait for install to finish
245 wait_for_VM_to_halt
246
247 # set VM to restart after a reboot
Renuka Apte0af143b2012-04-02 15:46:53 -0700248 vm_uuid=$(xe_min vm-list name-label="$GUEST_NAME")
249 xe vm-param-set actions-after-reboot=Restart uuid="$vm_uuid"
250
251 # Make template from VM
Mate Lakatc02b2f82013-07-30 19:43:10 +0100252 snuuid=$(xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_TEMPLATE")
John Garbuttdaadf742012-04-27 18:28:28 +0100253 xe snapshot-clone uuid=$snuuid new-name-label="$TNAME"
254else
255 #
256 # Template already installed, create VM from template
257 #
258 vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME")
Renuka Apte0af143b2012-04-02 15:46:53 -0700259fi
260
Mate Lakatc02b2f82013-07-30 19:43:10 +0100261#
262# Prepare VM for DevStack
263#
264
265# Install XenServer tools, and other such things
266$THIS_DIR/prepare_guest_template.sh "$GUEST_NAME"
267
Mate Lakat16ed0682013-08-30 13:28:31 +0100268# Set virtual machine parameters
269set_vm_memory "$GUEST_NAME" "$OSDOMU_MEM_MB"
270
Mate Lakat9f878cb2013-10-04 09:56:24 +0100271# Max out VCPU count for better performance
272max_vcpus "$GUEST_NAME"
273
Mate Lakat8787e0f2013-10-28 18:15:57 +0000274# Wipe out all network cards
275destroy_all_vifs_of "$GUEST_NAME"
276
277# Add only one interface to prepare the guest template
278add_interface "$GUEST_NAME" "$MGT_BRIDGE_OR_NET_NAME" "0"
279
Mate Lakatc02b2f82013-07-30 19:43:10 +0100280# start the VM to run the prepare steps
281xe vm-start vm="$GUEST_NAME"
282
283# Wait for prep script to finish and shutdown system
284wait_for_VM_to_halt
285
Mate Lakat5a56cd62013-06-17 13:54:43 +0100286## Setup network cards
287# Wipe out all
288destroy_all_vifs_of "$GUEST_NAME"
289# Tenant network
290add_interface "$GUEST_NAME" "$VM_BRIDGE_OR_NET_NAME" "$VM_DEV_NR"
291# Management network
292add_interface "$GUEST_NAME" "$MGT_BRIDGE_OR_NET_NAME" "$MGT_DEV_NR"
293# Public network
294add_interface "$GUEST_NAME" "$PUB_BRIDGE_OR_NET_NAME" "$PUB_DEV_NR"
John Garbuttdaadf742012-04-27 18:28:28 +0100295
296#
297# Inject DevStack inside VM disk
298#
Mate Lakata8bf0f22013-03-07 18:37:31 +0000299$THIS_DIR/build_xva.sh "$GUEST_NAME"
Renuka Apte0af143b2012-04-02 15:46:53 -0700300
Mate Lakatf652e0f2013-05-21 18:12:48 +0100301# Attach a network interface for the integration network (so that the bridge
Mark McClainb05c8762013-07-06 23:29:39 -0400302# is created by XenServer). This is required for Neutron. Also pass that as a
Mate Lakat8ff33ce2013-05-30 13:26:58 +0100303# kernel parameter for DomU
Mark McClainb05c8762013-07-06 23:29:39 -0400304if is_service_enabled neutron; then
Mate Lakatd8511032013-07-03 10:44:44 +0100305 attach_network "$XEN_INT_BRIDGE_OR_NET_NAME"
Mate Lakat8ff33ce2013-05-30 13:26:58 +0100306
307 XEN_INTEGRATION_BRIDGE=$(bridge_for "$XEN_INT_BRIDGE_OR_NET_NAME")
308 append_kernel_cmdline \
309 "$GUEST_NAME" \
310 "xen_integration_bridge=${XEN_INTEGRATION_BRIDGE}"
Mate Lakatf652e0f2013-05-21 18:12:48 +0100311fi
312
Mate Lakat8ff33ce2013-05-30 13:26:58 +0100313FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME")
314append_kernel_cmdline "$GUEST_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}"
315
Mate Lakat68ac03c2013-06-06 16:22:34 +0100316# Add a separate xvdb, if it was requested
317if [[ "0" != "$XEN_XVDB_SIZE_GB" ]]; then
318 vm=$(xe vm-list name-label="$GUEST_NAME" --minimal)
319
320 # Add a new disk
321 localsr=$(get_local_sr)
322 extra_vdi=$(xe vdi-create \
323 name-label=xvdb-added-by-devstack \
324 virtual-size="${XEN_XVDB_SIZE_GB}GiB" \
325 sr-uuid=$localsr type=user)
326 xe vbd-create vm-uuid=$vm vdi-uuid=$extra_vdi device=1
327fi
328
John Garbuttdaadf742012-04-27 18:28:28 +0100329# create a snapshot before the first boot
330# to allow a quick re-run with the same settings
331xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT"
332
John Garbuttdaadf742012-04-27 18:28:28 +0100333#
334# Run DevStack VM
335#
Renuka Apte0af143b2012-04-02 15:46:53 -0700336xe vm-start vm="$GUEST_NAME"
Anthony Young3eb8f592011-10-26 23:11:52 -0700337
John Garbuttdaadf742012-04-27 18:28:28 +0100338function ssh_no_check() {
339 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
340}
341
Mate Lakat86446762013-05-12 18:34:29 +0100342# Get hold of the Management IP of OpenStack VM
343OS_VM_MANAGEMENT_ADDRESS=$MGT_IP
344if [ $OS_VM_MANAGEMENT_ADDRESS == "dhcp" ]; then
Mate Lakat5a56cd62013-06-17 13:54:43 +0100345 OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $GUEST_NAME $MGT_DEV_NR)
Mate Lakat86446762013-05-12 18:34:29 +0100346fi
347
348# Get hold of the Service IP of OpenStack VM
Mate Lakat5a56cd62013-06-17 13:54:43 +0100349if [ $HOST_IP_IFACE == "eth${MGT_DEV_NR}" ]; then
Mate Lakat86446762013-05-12 18:34:29 +0100350 OS_VM_SERVICES_ADDRESS=$MGT_IP
John Garbuttdaadf742012-04-27 18:28:28 +0100351 if [ $MGT_IP == "dhcp" ]; then
Mate Lakat5a56cd62013-06-17 13:54:43 +0100352 OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME $MGT_DEV_NR)
John Garbuttdaadf742012-04-27 18:28:28 +0100353 fi
354else
Mate Lakat86446762013-05-12 18:34:29 +0100355 OS_VM_SERVICES_ADDRESS=$PUB_IP
John Garbuttdaadf742012-04-27 18:28:28 +0100356 if [ $PUB_IP == "dhcp" ]; then
Mate Lakat5a56cd62013-06-17 13:54:43 +0100357 OS_VM_SERVICES_ADDRESS=$(find_ip_by_name $GUEST_NAME $PUB_DEV_NR)
John Garbuttdaadf742012-04-27 18:28:28 +0100358 fi
Renuka Aptec56885a2012-02-29 16:09:26 -0800359fi
360
Anthony Young1de18c62011-11-01 14:19:18 -0500361# If we have copied our ssh credentials, use ssh to monitor while the installation runs
362WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
John Garbuttdaadf742012-04-27 18:28:28 +0100363COPYENV=${COPYENV:-1}
Anthony Young1de18c62011-11-01 14:19:18 -0500364if [ "$WAIT_TILL_LAUNCH" = "1" ] && [ -e ~/.ssh/id_rsa.pub ] && [ "$COPYENV" = "1" ]; then
Bob Ball7fcc1572013-02-20 15:56:25 +0000365 set +x
Anthony Young1de18c62011-11-01 14:19:18 -0500366
Bob Ball7fcc1572013-02-20 15:56:25 +0000367 echo "VM Launched - Waiting for startup script"
John Garbuttdaadf742012-04-27 18:28:28 +0100368 # wait for log to appear
Mate Lakat86446762013-05-12 18:34:29 +0100369 while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "[ -e run.sh.log ]"; do
John Garbuttdaadf742012-04-27 18:28:28 +0100370 sleep 10
Anthony Young1de18c62011-11-01 14:19:18 -0500371 done
Bob Ball7fcc1572013-02-20 15:56:25 +0000372 echo -n "Running"
Mate Lakat86446762013-05-12 18:34:29 +0100373 while [ `ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS pgrep -c run.sh` -ge 1 ]
Mate Lakat9efcf602012-12-19 10:23:06 +0000374 do
John Garbuttdaadf742012-04-27 18:28:28 +0100375 sleep 10
Mate Lakat9efcf602012-12-19 10:23:06 +0000376 echo -n "."
Anthony Young1de18c62011-11-01 14:19:18 -0500377 done
Mate Lakat9efcf602012-12-19 10:23:06 +0000378 echo "done!"
379 set -x
Anthony Young1de18c62011-11-01 14:19:18 -0500380
Mate Lakat9efcf602012-12-19 10:23:06 +0000381 # output the run.sh.log
Mate Lakat86446762013-05-12 18:34:29 +0100382 ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log'
Anthony Young1de18c62011-11-01 14:19:18 -0500383
Mate Lakat9efcf602012-12-19 10:23:06 +0000384 # Fail if the expected text is not found
Mate Lakat86446762013-05-12 18:34:29 +0100385 ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'cat run.sh.log' | grep -q 'stack.sh completed in'
Mate Lakat9efcf602012-12-19 10:23:06 +0000386
Bob Ball63c6c2b2013-01-24 13:13:51 +0000387 set +x
John Garbuttdaadf742012-04-27 18:28:28 +0100388 echo "################################################################################"
Anthony Young1de18c62011-11-01 14:19:18 -0500389 echo ""
John Garbuttdaadf742012-04-27 18:28:28 +0100390 echo "All Finished!"
391 echo "You can visit the OpenStack Dashboard"
Mate Lakat86446762013-05-12 18:34:29 +0100392 echo "at http://$OS_VM_SERVICES_ADDRESS, and contact other services at the usual ports."
Anthony Young1de18c62011-11-01 14:19:18 -0500393else
Bob Ball63c6c2b2013-01-24 13:13:51 +0000394 set +x
Anthony Young1de18c62011-11-01 14:19:18 -0500395 echo "################################################################################"
396 echo ""
397 echo "All Finished!"
398 echo "Now, you can monitor the progress of the stack.sh installation by "
399 echo "tailing /opt/stack/run.sh.log from within your domU."
400 echo ""
Mate Lakat86446762013-05-12 18:34:29 +0100401 echo "ssh into your domU now: 'ssh stack@$OS_VM_MANAGEMENT_ADDRESS' using your password"
Anthony Young1de18c62011-11-01 14:19:18 -0500402 echo "and then do: 'tail -f /opt/stack/run.sh.log'"
403 echo ""
404 echo "When the script completes, you can then visit the OpenStack Dashboard"
Mate Lakat86446762013-05-12 18:34:29 +0100405 echo "at http://$OS_VM_SERVICES_ADDRESS, and contact other services at the usual ports."
Anthony Young1de18c62011-11-01 14:19:18 -0500406fi