summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 11:54:03 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 11:54:03 +0000
commitaa52c9dfd6b9060bc423262fb4052412f04ff7a1 (patch)
tree0dd560b1a827317de7ba2f1c1e90d53f67bdcc0b
parentc8624cb371b321091d693865aa4066ad66b5b956 (diff)
parent85a588e382a5eb6fbd8769fbe7ed19e2d73dcb4b (diff)
Merge "os-xenapi: remove install dependence with devstack 2:"
-rwxr-xr-x[-rw-r--r--]tools/install-devstack-xen.sh (renamed from install-devstack-xen.sh)222
-rwxr-xr-xtools/install/common/functions (renamed from install/common/functions)61
-rw-r--r--tools/install/conf/ubuntupreseed.cfg (renamed from install/conf/ubuntupreseed.cfg)0
-rw-r--r--tools/install/conf/xenrc (renamed from install/conf/xenrc)25
-rwxr-xr-xtools/install/create_ubuntu_template.sh (renamed from install/create_ubuntu_template.sh)7
-rwxr-xr-xtools/install/devstack/install_devstack.sh348
-rwxr-xr-xtools/install/scripts/install-os-vpx.sh (renamed from install/scripts/install-os-vpx.sh)0
-rwxr-xr-xtools/install/scripts/install_ubuntu_template.sh (renamed from install/scripts/install_ubuntu_template.sh)2
-rwxr-xr-xtools/install/scripts/manage-vdi97
-rwxr-xr-xtools/install/scripts/on_exit.sh (renamed from install/scripts/on_exit.sh)0
-rwxr-xr-xtools/install/scripts/persist_domU_interfaces.sh107
-rwxr-xr-xtools/install/scripts/prepare_guest.sh122
-rwxr-xr-xtools/install/scripts/prepare_guest_template.sh99
-rwxr-xr-xtools/install/scripts/ubuntu_latecommand.sh (renamed from install/scripts/ubuntu_latecommand.sh)0
-rwxr-xr-xtools/install/scripts/uninstall-os-vpx.sh (renamed from install/scripts/uninstall-os-vpx.sh)0
-rwxr-xr-xtools/install_on_xen_host.sh201
16 files changed, 1096 insertions, 195 deletions
diff --git a/install-devstack-xen.sh b/tools/install-devstack-xen.sh
index c6466e4..6431dac 100644..100755
--- a/install-devstack-xen.sh
+++ b/tools/install-devstack-xen.sh
@@ -37,6 +37,10 @@ optional arguments:
37 before running any tests. The host will not be rebooted after 37 before running any tests. The host will not be rebooted after
38 installing the supplemental pack, so new kernels will not be 38 installing the supplemental pack, so new kernels will not be
39 picked up. 39 picked up.
40 -o OS_XENAPI_SRC An URL point to a zip file for os-xenapi, This defaults to the
41 official os-xenapi repository.
42 -w WAIT_TILL_LAUNCH Set it to 1 if user want to pending on the installation until
43 it is done
40 44
41flags: 45flags:
42 -f Force SR replacement. If your XenServer has an LVM type SR, 46 -f Force SR replacement. If your XenServer has an LVM type SR,
@@ -61,7 +65,8 @@ exit 1
61} 65}
62 66
63# Defaults for optional arguments 67# Defaults for optional arguments
64DEVSTACK_SRC="https://github.com/openstack-dev/devstack/archive/master.tar.gz" 68DEVSTACK_SRC=${DEVSTACK_SRC:-"https://github.com/openstack-dev/devstack"}
69OS_XENAPI_SRC=${OS_XENAPI_SRC:-"https://github.com/openstack/os-xenapi/archive/master.zip"}
65TEST_TYPE="none" 70TEST_TYPE="none"
66FORCE_SR_REPLACEMENT="false" 71FORCE_SR_REPLACEMENT="false"
67EXIT_AFTER_JEOS_INSTALLATION="" 72EXIT_AFTER_JEOS_INSTALLATION=""
@@ -69,7 +74,9 @@ LOG_FILE_DIRECTORY=""
69JEOS_URL="" 74JEOS_URL=""
70JEOS_FILENAME="" 75JEOS_FILENAME=""
71SUPP_PACK_URL="" 76SUPP_PACK_URL=""
72SCREEN_LOGDIR="/opt/stack/devstack_logs" 77LOGDIR="/opt/stack/devstack_logs"
78DEV_STACK_DOMU_NAME=${DEV_STACK_DOMU_NAME:-DevStackOSDomU}
79WAIT_TILL_LAUNCH=1
73 80
74# Get Positional arguments 81# Get Positional arguments
75set +u 82set +u
@@ -86,7 +93,7 @@ REMAINING_OPTIONS="$#"
86 93
87# Get optional parameters 94# Get optional parameters
88set +e 95set +e
89while getopts ":t:d:fnl:j:e:s:" flag; do 96while getopts ":t:d:fnl:j:e:o:s:w:" flag; do
90 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1) 97 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
91 case "$flag" in 98 case "$flag" in
92 t) 99 t)
@@ -122,12 +129,29 @@ while getopts ":t:d:fnl:j:e:s:" flag; do
122 SUPP_PACK_URL="$OPTARG" 129 SUPP_PACK_URL="$OPTARG"
123 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1) 130 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
124 ;; 131 ;;
132 o)
133 OS_XENAPI_SRC="$OPTARG"
134 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
135 ;;
136 w)
137 WAIT_TILL_LAUNCH="$OPTARG"
138 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
139 ;;
125 \?) 140 \?)
126 print_usage_and_die "Invalid option -$OPTARG" 141 print_usage_and_die "Invalid option -$OPTARG"
127 ;; 142 ;;
128 esac 143 esac
129done 144done
145
130set -e 146set -e
147if [ "$TEST_TYPE" != "none" ] && [ $WAIT_TILL_LAUNCH -ne 1 ]; then
148 echo "WARNING: You can't perform a test even before the insallation done, force set WAIT_TILL_LAUNCH to 1"
149 WAIT_TILL_LAUNCH=1
150fi
151
152if [ "$TEST_TYPE" != "none" ] && [ "$EXIT_AFTER_JEOS_INSTALLATION" = "true" ]; then
153 print_usage_and_die "ERROR: You can't perform a test without a devstack invironment, exit"
154fi
131 155
132# Make sure that all options processed 156# Make sure that all options processed
133if [ "0" != "$REMAINING_OPTIONS" ]; then 157if [ "0" != "$REMAINING_OPTIONS" ]; then
@@ -152,6 +176,8 @@ XENSERVER_PASS: $XENSERVER_PASS
152PRIVKEY: $PRIVKEY 176PRIVKEY: $PRIVKEY
153TEST_TYPE: $TEST_TYPE 177TEST_TYPE: $TEST_TYPE
154DEVSTACK_SRC: $DEVSTACK_SRC 178DEVSTACK_SRC: $DEVSTACK_SRC
179OS_XENAPI_SRC: $OS_XENAPI_SRC
180
155 181
156FORCE_SR_REPLACEMENT: $FORCE_SR_REPLACEMENT 182FORCE_SR_REPLACEMENT: $FORCE_SR_REPLACEMENT
157JEOS_URL: ${JEOS_URL:-template will not be imported} 183JEOS_URL: ${JEOS_URL:-template will not be imported}
@@ -175,6 +201,12 @@ function assert_tool_exists() {
175 fi 201 fi
176} 202}
177 203
204DEFAULT_SR_ID=$(on_xenserver <<EOF
205xe pool-list params=default-SR minimal=true
206EOF
207)
208TMP_TEMPLATE_DIR=/var/run/sr-mount/$DEFAULT_SR_ID/devstack_template
209
178if [ -z "$JEOS_FILENAME" ]; then 210if [ -z "$JEOS_FILENAME" ]; then
179 if [ "$PRIVKEY" != "-" ]; then 211 if [ "$PRIVKEY" != "-" ]; then
180 echo "Setup ssh keys on XenServer..." 212 echo "Setup ssh keys on XenServer..."
@@ -196,21 +228,26 @@ if [ -z "$JEOS_FILENAME" ]; then
196 fi 228 fi
197else 229else
198 echo -n "Exporting JeOS template..." 230 echo -n "Exporting JeOS template..."
231 echo "template will save to $TMP_TEMPLATE_DIR"
232
199 on_xenserver << END_OF_EXPORT_COMMANDS 233 on_xenserver << END_OF_EXPORT_COMMANDS
200set -eu 234set -eu
235
236mkdir -p $TMP_TEMPLATE_DIR
237
201JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)" 238JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)"
202 239
203if [ -z "\$JEOS_TEMPLATE" ]; then 240if [ -z "\$JEOS_TEMPLATE" ]; then
204 echo "FATAL: jeos_template_for_devstack not found" 241 echo "FATAL: jeos_template_for_devstack not found"
205 exit 1 242 exit 1
206fi 243fi
207rm -f /root/jeos-for-devstack.xva 244rm -rf $TMP_TEMPLATE_DIR/jeos-for-devstack.xva
208xe template-export template-uuid="\$JEOS_TEMPLATE" filename="/root/jeos-for-devstack.xva" compress=true 245xe template-export template-uuid="\$JEOS_TEMPLATE" filename="\$TMP_TEMPLATE_DIR/jeos-for-devstack.xva" compress=true
209END_OF_EXPORT_COMMANDS 246END_OF_EXPORT_COMMANDS
210 echo "OK" 247 echo "OK"
211 248
212 echo -n "Copy exported template to local file..." 249 echo -n "Copy exported template to local file..."
213 if scp -3 $_SSH_OPTIONS "root@$XENSERVER:/root/jeos-for-devstack.xva" "$JEOS_FILENAME"; then 250 if scp -3 $_SSH_OPTIONS "root@$XENSERVER:$TMP_TEMPLATE_DIR/jeos-for-devstack.xva" "$JEOS_FILENAME"; then
214 echo "OK" 251 echo "OK"
215 RETURN_CODE=0 252 RETURN_CODE=0
216 else 253 else
@@ -220,14 +257,13 @@ END_OF_EXPORT_COMMANDS
220 echo "Cleanup: delete exported template from XenServer" 257 echo "Cleanup: delete exported template from XenServer"
221 on_xenserver << END_OF_CLEANUP 258 on_xenserver << END_OF_CLEANUP
222set -eu 259set -eu
223rm -f /root/jeos-for-devstack.xva 260
261rm -rf $TMP_TEMPLATE_DIR
224END_OF_CLEANUP 262END_OF_CLEANUP
225 echo "JeOS export done, exiting." 263 echo "JeOS export done, exiting."
226 exit $RETURN_CODE 264 exit $RETURN_CODE
227fi 265fi
228 266
229TMPDIR=$(echo "mktemp -d" | on_xenserver)
230
231function copy_logs_on_failure() { 267function copy_logs_on_failure() {
232 set +e 268 set +e
233 $@ 269 $@
@@ -243,18 +279,15 @@ function copy_logs() {
243 if [ -n "$LOG_FILE_DIRECTORY" ]; then 279 if [ -n "$LOG_FILE_DIRECTORY" ]; then
244 on_xenserver << END_OF_XENSERVER_COMMANDS 280 on_xenserver << END_OF_XENSERVER_COMMANDS
245set -xu 281set -xu
246cd $TMPDIR
247cd devstack*
248 282
249mkdir -p /root/artifacts 283mkdir -p /root/artifacts
250 284GUEST_IP=\$(. "$COMM_DIR/functions" && find_ip_by_name $DEV_STACK_DOMU_NAME 0)
251GUEST_IP=\$(. "tools/xen/functions" && find_ip_by_name DevStackOSDomU 0)
252if [ -n \$GUEST_IP ]; then 285if [ -n \$GUEST_IP ]; then
253ssh -q \ 286ssh -q \
254 -o Batchmode=yes \ 287 -o Batchmode=yes \
255 -o StrictHostKeyChecking=no \ 288 -o StrictHostKeyChecking=no \
256 -o UserKnownHostsFile=/dev/null \ 289 -o UserKnownHostsFile=/dev/null \
257 stack@\$GUEST_IP "tar --ignore-failed-read -czf - ${SCREEN_LOGDIR}/* /opt/stack/tempest/*.xml" > \ 290 stack@\$GUEST_IP "tar --ignore-failed-read -czf - ${LOGDIR}/* /opt/stack/tempest/*.xml" > \
258 /root/artifacts/domU.tgz < /dev/null || true 291 /root/artifacts/domU.tgz < /dev/null || true
259fi 292fi
260tar --ignore-failed-read -czf /root/artifacts/dom0.tgz /var/log/messages* /var/log/xensource* /var/log/SM* || true 293tar --ignore-failed-read -czf /root/artifacts/dom0.tgz /var/log/messages* /var/log/xensource* /var/log/SM* || true
@@ -284,48 +317,6 @@ else
284 exit 1 317 exit 1
285fi 318fi
286 319
287echo -n "Verify XenServer has an ext type default SR..."
288copy_logs_on_failure on_xenserver << END_OF_SR_OPERATIONS
289set -eu
290
291# Verify the host is suitable for devstack
292defaultSR=\$(xe pool-list params=default-SR minimal=true)
293currentSrType=\$(xe sr-param-get uuid=\$defaultSR param-name=type)
294if [ "\$currentSrType" != "ext" -a "\$currentSrType" != "nfs" -a "\$currentSrType" != "ffs" -a "\$currentSrType" != "file" ]; then
295 if [ "true" == "$FORCE_SR_REPLACEMENT" ]; then
296 echo ""
297 echo ""
298 echo "Trying to replace the default SR with an EXT SR"
299
300 pbd_uuid=\`xe pbd-list sr-uuid=\$defaultSR minimal=true\`
301 host_uuid=\`xe pbd-param-get uuid=\$pbd_uuid param-name=host-uuid\`
302 use_device=\`xe pbd-param-get uuid=\$pbd_uuid param-name=device-config param-key=device\`
303
304 # Destroy the existing SR
305 xe pbd-unplug uuid=\$pbd_uuid
306 xe sr-destroy uuid=\$defaultSR
307
308 sr_uuid=\`xe sr-create content-type=user host-uuid=\$host_uuid type=ext device-config:device=\$use_device shared=false name-label="Local storage"\`
309 pool_uuid=\`xe pool-list minimal=true\`
310 xe pool-param-set default-SR=\$sr_uuid uuid=\$pool_uuid
311 xe pool-param-set suspend-image-SR=\$sr_uuid uuid=\$pool_uuid
312 xe sr-param-add uuid=\$sr_uuid param-name=other-config i18n-key=local-storage
313 exit 0
314 fi
315 echo ""
316 echo ""
317 echo "ERROR: The xenserver host must have an EXT3/NFS/FFS/File SR as the default SR"
318 echo "Use the -f flag to destroy the current default SR and create a new"
319 echo "ext type default SR."
320 echo ""
321 echo "WARNING: This will destroy your actual default SR !"
322 echo ""
323
324 exit 1
325fi
326END_OF_SR_OPERATIONS
327echo "OK"
328
329echo -n "Get the IP address of XenServer..." 320echo -n "Get the IP address of XenServer..."
330XENSERVER_IP=$(on_xenserver << GET_XENSERVER_IP 321XENSERVER_IP=$(on_xenserver << GET_XENSERVER_IP
331xe host-list params=address minimal=true 322xe host-list params=address minimal=true
@@ -349,29 +340,13 @@ SUPP_PACK
349 sleep 10m 340 sleep 10m
350fi 341fi
351 342
352echo -n "Hack ISCSISR.py on XenServer (original saved to /root/ISCSISR.py.orig)..."
353on_xenserver << HACK_ISCSI_SR
354set -eu
355
356iscsi_target_file=""
357for candidate_file in "/opt/xensource/sm/ISCSISR.py" "/usr/lib64/xcp-sm/ISCSISR.py"; do
358 if [ -e "\$candidate_file" ]; then
359 iscsi_target_file=\$candidate_file
360 fi
361done
362if [ -n "\$iscsi_target_file" ]; then
363 if ! [ -e "/root/ISCSISR.py.orig" ]; then
364 cp \$iscsi_target_file /root/ISCSISR.py.orig
365 fi
366 sed -e "s/'phy'/'aio'/g" /root/ISCSISR.py.orig > \$iscsi_target_file
367fi
368HACK_ISCSI_SR
369echo "OK"
370
371if [ -n "$JEOS_URL" ]; then 343if [ -n "$JEOS_URL" ]; then
372 echo "(re-)importing JeOS template" 344 echo "(re-)importing JeOS template"
373 on_xenserver << END_OF_JEOS_IMPORT 345 on_xenserver << END_OF_JEOS_IMPORT
374set -eu 346set -eu
347
348mkdir -p $TMP_TEMPLATE_DIR
349
375JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)" 350JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)"
376 351
377if [ -n "\$JEOS_TEMPLATE" ]; then 352if [ -n "\$JEOS_TEMPLATE" ]; then
@@ -379,12 +354,12 @@ if [ -n "\$JEOS_TEMPLATE" ]; then
379 xe template-uninstall template-uuid="\$JEOS_TEMPLATE" force=true > /dev/null 354 xe template-uninstall template-uuid="\$JEOS_TEMPLATE" force=true > /dev/null
380fi 355fi
381 356
382rm -f /root/jeos-for-devstack.xva 357rm -f $TMP_TEMPLATE_DIR/jeos-for-devstack.xva
383echo " downloading $JEOS_URL to /root/jeos-for-devstack.xva" 358echo " downloading $JEOS_URL to $TMP_TEMPLATE_DIR/jeos-for-devstack.xva"
384wget -qO /root/jeos-for-devstack.xva "$JEOS_URL" 359wget -qO $TMP_TEMPLATE_DIR/jeos-for-devstack.xva "$JEOS_URL"
385echo " importing /root/jeos-for-devstack.xva" 360echo " importing $TMP_TEMPLATE_DIR/jeos-for-devstack.xva"
386xe vm-import filename=/root/jeos-for-devstack.xva 361xe vm-import filename=$TMP_TEMPLATE_DIR/jeos-for-devstack.xva
387rm -f /root/jeos-for-devstack.xva 362rm -rf $TMP_TEMPLATE_DIR
388echo " verify template imported" 363echo " verify template imported"
389JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)" 364JEOS_TEMPLATE="\$(xe template-list name-label="jeos_template_for_devstack" --minimal)"
390if [ -z "\$JEOS_TEMPLATE" ]; then 365if [ -z "\$JEOS_TEMPLATE" ]; then
@@ -396,35 +371,20 @@ END_OF_JEOS_IMPORT
396 echo "OK" 371 echo "OK"
397fi 372fi
398 373
399if [ -e $DEVSTACK_SRC ]; then 374TMPDIR=$(echo "mktemp -d" | on_xenserver)
400copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS
401set -eu
402
403mkdir -p $TMPDIR/devstack-local
404END_OF_XENSERVER_COMMANDS
405 scp $_SSH_OPTIONS -r $DEVSTACK_SRC/* "root@$XENSERVER:$TMPDIR/devstack-local"
406else
407copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS
408set -exu
409
410cd $TMPDIR
411
412wget "$DEVSTACK_SRC" -O _devstack.tgz
413tar -xzf _devstack.tgz
414cd devstack*
415END_OF_XENSERVER_COMMANDS
416fi
417 375
418# set nounset for $NOVA_CONF
419set +u 376set +u
420 377DOM0_OPT_DIR=$TMPDIR/domU
378DOM0_OS_API_UNZIP_DIR="$DOM0_OPT_DIR/os-xenapi"
379DOM0_OS_API_DIR="$DOM0_OS_API_UNZIP_DIR/os-xenapi-*"
380DOM0_TOOL_DIR="$DOM0_OS_API_DIR/tools"
381DOM0_INSTALL_DIR="$DOM0_TOOL_DIR/install"
421copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS 382copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS
422set -exu 383 mkdir $DOM0_OPT_DIR
423 384 cd $DOM0_OPT_DIR
424cd $TMPDIR 385 wget --no-check-certificate "$OS_XENAPI_SRC"
425 386 unzip -o master.zip -d $DOM0_OS_API_UNZIP_DIR
426cd devstack* 387 cd $DOM0_INSTALL_DIR
427
428cat << LOCALCONF_CONTENT_ENDS_HERE > local.conf 388cat << LOCALCONF_CONTENT_ENDS_HERE > local.conf
429# ``local.conf`` is a user-maintained settings file that is sourced from ``stackrc``. 389# ``local.conf`` is a user-maintained settings file that is sourced from ``stackrc``.
430# This gives it the ability to override any variables set in ``stackrc``. 390# This gives it the ability to override any variables set in ``stackrc``.
@@ -448,7 +408,6 @@ SWIFT_HASH="66a3d6b56c1f479c8b4e70ab5c2000f5"
448# Nice short names, so we could export an XVA 408# Nice short names, so we could export an XVA
449VM_BRIDGE_OR_NET_NAME="osvmnet" 409VM_BRIDGE_OR_NET_NAME="osvmnet"
450PUB_BRIDGE_OR_NET_NAME="ospubnet" 410PUB_BRIDGE_OR_NET_NAME="ospubnet"
451XEN_INT_BRIDGE_OR_NET_NAME="osintnet"
452 411
453# Do not use secure delete 412# Do not use secure delete
454CINDER_SECURE_DELETE=False 413CINDER_SECURE_DELETE=False
@@ -457,15 +416,13 @@ CINDER_SECURE_DELETE=False
457VIRT_DRIVER=xenserver 416VIRT_DRIVER=xenserver
458 417
459# OpenStack VM settings 418# OpenStack VM settings
460OSDOMU_VDI_GB=30
461OSDOMU_MEM_MB=8192
462
463TERMINATE_TIMEOUT=90 419TERMINATE_TIMEOUT=90
464BUILD_TIMEOUT=600 420BUILD_TIMEOUT=600
465 421
466# DevStack settings 422# DevStack settings
467LOGFILE=${SCREEN_LOGDIR}/stack.log 423
468SCREEN_LOGDIR=${SCREEN_LOGDIR} 424LOGDIR=${LOGDIR}
425LOGFILE=${LOGDIR}/stack.log
469 426
470UBUNTU_INST_HTTP_HOSTNAME=archive.ubuntu.com 427UBUNTU_INST_HTTP_HOSTNAME=archive.ubuntu.com
471UBUNTU_INST_HTTP_DIRECTORY=/ubuntu 428UBUNTU_INST_HTTP_DIRECTORY=/ubuntu
@@ -487,7 +444,6 @@ ENABLE_TENANT_VLANS=True
487Q_ML2_TENANT_NETWORK_TYPE=vlan 444Q_ML2_TENANT_NETWORK_TYPE=vlan
488ML2_VLAN_RANGES="physnet1:1100:1200" 445ML2_VLAN_RANGES="physnet1:1100:1200"
489 446
490PUB_IP=172.24.4.1
491SUBNETPOOL_PREFIX_V4=192.168.10.0/24 447SUBNETPOOL_PREFIX_V4=192.168.10.0/24
492NETWORK_GATEWAY=192.168.10.1 448NETWORK_GATEWAY=192.168.10.1
493 449
@@ -500,43 +456,35 @@ PUBLIC_INTERFACE=eth2
500[DEFAULT] 456[DEFAULT]
501disk_allocation_ratio = 2.0 457disk_allocation_ratio = 2.0
502 458
503# Neutron ovs bridge mapping
504[[post-config|\\\$NEUTRON_CORE_PLUGIN_CONF]]
505[ovs]
506bridge_mappings = physnet1:br-eth1,public:br-ex
507
508LOCALCONF_CONTENT_ENDS_HERE 459LOCALCONF_CONTENT_ENDS_HERE
509 460
510# unset nounset for $NOVA_CONF 461# begin installation process
511set -u 462cd $DOM0_TOOL_DIR
512 463if [ $FORCE_SR_REPLACEMENT = 'true' ]; then
513# XenServer doesn't have nproc by default - but it's used by stackrc. 464 ./install_on_xen_host.sh -d $DEVSTACK_SRC -l $LOGDIR -w $WAIT_TILL_LAUNCH -f
514# Fake it up if one doesn't exist 465else
515set +e 466 ./install_on_xen_host.sh -d $DEVSTACK_SRC -l $LOGDIR -w $WAIT_TILL_LAUNCH
516which nproc > /dev/null 2>&1
517if [ \$? -ne 0 ]; then
518 cat >> /usr/local/bin/nproc << END_OF_NPROC
519#!/bin/bash
520cat /proc/cpuinfo | grep -c processor
521END_OF_NPROC
522 chmod +x /usr/local/bin/nproc
523fi 467fi
524 468
525cd tools/xen
526EXIT_AFTER_JEOS_INSTALLATION="$EXIT_AFTER_JEOS_INSTALLATION" ./install_os_domU.sh
527END_OF_XENSERVER_COMMANDS 469END_OF_XENSERVER_COMMANDS
528 470
471on_xenserver << END_OF_RM_TMPDIR
472
473#delete install dir
474rm $TMPDIR -rf
475END_OF_RM_TMPDIR
476
529if [ "$TEST_TYPE" == "none" ]; then 477if [ "$TEST_TYPE" == "none" ]; then
530 exit 0 478 exit 0
531fi 479fi
532 480
533# Run tests 481# Run tests
482DOM0_FUNCTION_DIR="$DOM0_OS_API_DIR/install/common"
534copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS 483copy_logs_on_failure on_xenserver << END_OF_XENSERVER_COMMANDS
484
535set -exu 485set -exu
536cd $TMPDIR
537cd devstack*
538 486
539GUEST_IP=\$(. "tools/xen/functions" && find_ip_by_name DevStackOSDomU 0) 487GUEST_IP=\$(. $DOM0_FUNCTION_DIR/functions && find_ip_by_name $DEV_STACK_DOMU_NAME 0)
540ssh -q \ 488ssh -q \
541 -o Batchmode=yes \ 489 -o Batchmode=yes \
542 -o StrictHostKeyChecking=no \ 490 -o StrictHostKeyChecking=no \
diff --git a/install/common/functions b/tools/install/common/functions
index 933062a..42bb35d 100755
--- a/install/common/functions
+++ b/tools/install/common/functions
@@ -16,52 +16,10 @@ function die_with_error {
16 exit 1 16 exit 1
17} 17}
18 18
19function xapi_plugin_location {
20 for PLUGIN_DIR in "/etc/xapi.d/plugins/" "/usr/lib/xcp/plugins/" "/usr/lib/xapi/plugins" "/usr/lib64/xapi/plugins"; do
21 if [ -d $PLUGIN_DIR ]; then
22 echo $PLUGIN_DIR
23 return 0
24 fi
25 done
26 return 1
27}
28
29function create_directory_for_kernels {
30 if [ -d "/boot/guest" ]; then
31 echo "INFO: /boot/guest directory already exists, using that" >&2
32 else
33 local local_path
34 local_path="$(get_local_sr_path)/os-guest-kernels"
35 mkdir -p $local_path
36 ln -s $local_path /boot/guest
37 fi
38}
39
40function create_directory_for_images {
41 if [ -d "/images" ]; then
42 echo "INFO: /images directory already exists, using that" >&2
43 else
44 local local_path
45 local_path="$(get_local_sr_path)/os-images"
46 mkdir -p $local_path
47 ln -s $local_path /images
48 fi
49}
50
51function get_local_sr { 19function get_local_sr {
52 xe pool-list params=default-SR minimal=true 20 xe pool-list params=default-SR minimal=true
53} 21}
54 22
55function get_local_sr_path {
56 pbd_path="/var/run/sr-mount/$(get_local_sr)"
57 pbd_device_config_path=`xe pbd-list sr-uuid=$(get_local_sr) params=device-config | grep " path: "`
58 if [ -n "$pbd_device_config_path" ]; then
59 pbd_uuid=`xe pbd-list sr-uuid=$(get_local_sr) minimal=true`
60 pbd_path=`xe pbd-param-get uuid=$pbd_uuid param-name=device-config param-key=path || echo ""`
61 fi
62 echo $pbd_path
63}
64
65function find_ip_by_name { 23function find_ip_by_name {
66 local guest_name="$1" 24 local guest_name="$1"
67 local interface="$2" 25 local interface="$2"
@@ -273,6 +231,25 @@ function set_vm_memory {
273 uuid=$vm 231 uuid=$vm
274} 232}
275 233
234function set_vm_disk {
235 local vm_name_label
236 local vm_disk_size
237
238 vm_name_label="$1"
239 vm_disk_size="$2"
240
241 local vm_uuid
242 local vm_vbd
243 local vm_vdi
244
245 vm_uuid=$(xe vm-list name-label=$vm_name_label --minimal)
246 vm_vbd=$(xe vbd-list vm-uuid=$vm_uuid device=xvda --minimal)
247 vm_vdi=$(xe vdi-list vbd-uuids=$vm_vbd --minimal)
248
249 xe vdi-resize uuid=$vm_vdi disk-size=$((vm_disk_size * 1024 * 1024 * 1024))
250}
251
252
276function max_vcpus { 253function max_vcpus {
277 local vm_name_label 254 local vm_name_label
278 255
diff --git a/install/conf/ubuntupreseed.cfg b/tools/install/conf/ubuntupreseed.cfg
index 00bf37b..00bf37b 100644
--- a/install/conf/ubuntupreseed.cfg
+++ b/tools/install/conf/ubuntupreseed.cfg
diff --git a/install/conf/xenrc b/tools/install/conf/xenrc
index c2085b3..efb1ec8 100644
--- a/install/conf/xenrc
+++ b/tools/install/conf/xenrc
@@ -6,21 +6,13 @@
6# 6#
7 7
8# Name of this guest 8# Name of this guest
9GUEST_NAME=${GUEST_NAME:-CleanUbuntuVM} 9GUEST_NAME=${GUEST_NAME:-UbuntuVM}
10 10
11# Template cleanup 11# Template cleanup
12CLEAN_TEMPLATES=${CLEAN_TEMPLATES:-false} 12CLEAN_TEMPLATES=${CLEAN_TEMPLATES:-false}
13TNAME="jeos_template_for_ubuntu" 13TNAME="jeos_template_for_ubuntu"
14SNAME_TEMPLATE="jeos_snapshot_for_ubuntu" 14SNAME_TEMPLATE="jeos_snapshot_for_ubuntu"
15 15
16# Devstack now contains many components. 4GB ram is not enough to prevent
17# swapping and memory fragmentation - the latter of which can cause failures
18# such as blkfront failing to plug a VBD and lead to random test fails.
19#
20# Set to 6GB so an 8GB XenServer VM can have a 1GB Dom0 and leave 1GB for VMs
21OSDOMU_MEM_MB=6144
22OSDOMU_VDI_GB=8
23
24# Size of image 16# Size of image
25VDI_MB=${VDI_MB:-5000} 17VDI_MB=${VDI_MB:-5000}
26 18
@@ -29,11 +21,11 @@ VDI_MB=${VDI_MB:-5000}
29# such as blkfront failing to plug a VBD and lead to random test fails. 21# such as blkfront failing to plug a VBD and lead to random test fails.
30# 22#
31# Set to 6GB so an 8GB XenServer VM can have a 1GB Dom0 and leave 1GB for VMs 23# Set to 6GB so an 8GB XenServer VM can have a 1GB Dom0 and leave 1GB for VMs
32CLEAN_VM_MEM_MB=6144 24VM_MEM_MB=${VM_MEM_MB:-6144}
33CLEAN_VM_VDI_GB=8 25VM_VDI_GB=${VM_VDI_GB:-30}
34 26
35# VM Password 27# VM Password
36GUEST_PASSWORD=${GUEST_PASSWORD:-secret} 28GUEST_PASSWORD=${GUEST_PASSWORD:-admin}
37 29
38# Extracted variables for OpenStack VM network device numbers. 30# Extracted variables for OpenStack VM network device numbers.
39# Make sure they form a continuous sequence starting from 0 31# Make sure they form a continuous sequence starting from 0
@@ -105,10 +97,17 @@ DOMZERO_USER=domzero
105# Get the management network from the XS installation 97# Get the management network from the XS installation
106VM_BRIDGE_OR_NET_NAME="OpenStack VM Network" 98VM_BRIDGE_OR_NET_NAME="OpenStack VM Network"
107PUB_BRIDGE_OR_NET_NAME="OpenStack Public Network" 99PUB_BRIDGE_OR_NET_NAME="OpenStack Public Network"
108XEN_INT_BRIDGE_OR_NET_NAME="OpenStack VM Integration Network"
109 100
110# Extracted variables for OpenStack VM network device numbers. 101# Extracted variables for OpenStack VM network device numbers.
111# Make sure they form a continuous sequence starting from 0 102# Make sure they form a continuous sequence starting from 0
112MGT_DEV_NR=0 103MGT_DEV_NR=0
113VM_DEV_NR=1 104VM_DEV_NR=1
114PUB_DEV_NR=2 105PUB_DEV_NR=2
106
107# VM Network
108VM_IP=${VM_IP:-10.255.255.255}
109VM_NETMASK=${VM_NETMASK:-255.255.255.0}
110
111# Public network
112PUB_IP=${PUB_IP:-172.24.4.1}
113PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
diff --git a/install/create_ubuntu_template.sh b/tools/install/create_ubuntu_template.sh
index 7ed6b37..5efcb0f 100755
--- a/install/create_ubuntu_template.sh
+++ b/tools/install/create_ubuntu_template.sh
@@ -192,10 +192,13 @@ else
192 echo "the template has already exist" 192 echo "the template has already exist"
193fi 193fi
194template_uuid=$(xe_min template-list name-label="$TNAME") 194template_uuid=$(xe_min template-list name-label="$TNAME")
195echo "$template_uuid"
196exist_val=$(xe template-param-get uuid=$template_uuid param-name=PV-args) 195exist_val=$(xe template-param-get uuid=$template_uuid param-name=PV-args)
197echo "$exist_val"
198if [ -n "$exist_val" ]; 196if [ -n "$exist_val" ];
199 then 197 then
200 xe template-param-set uuid=$template_uuid PV-args="" 198 xe template-param-set uuid=$template_uuid PV-args=""
201fi 199fi
200set +x
201echo "################################################################################"
202echo ""
203echo "Template create done!"
204echo "################################################################################"
diff --git a/tools/install/devstack/install_devstack.sh b/tools/install/devstack/install_devstack.sh
new file mode 100755
index 0000000..78e3771
--- /dev/null
+++ b/tools/install/devstack/install_devstack.sh
@@ -0,0 +1,348 @@
1#!/bin/bash
2
3# This script is run by install_on_xen_host.sh
4#
5# It modifies the ubuntu image created by install_on_xen_host.sh
6# and previously moodified by prepare_guest_template.sh
7#
8# This script is responsible for:
9# - creates a DomU VM
10# - creating run.sh, to run the code on DomU boot
11#
12# by install_on_xen_host.sh
13
14# Exit on errors
15set -o errexit
16# Echo commands
17set -o xtrace
18
19# This directory
20THIS_DIR=$(cd $(dirname "$0") && pwd)
21TOP_DIR="$THIS_DIR/../"
22SCRIPT_DIR="$TOP_DIR/scripts"
23COMM_DIR="$TOP_DIR/common"
24CONF_DIR="$TOP_DIR/conf"
25
26# Include onexit commands
27. $SCRIPT_DIR/on_exit.sh
28
29# xapi functions
30. $COMM_DIR/functions
31
32# Source params
33source $CONF_DIR/xenrc
34
35# Defaults for optional arguments
36DEVSTACK_SRC=${DEVSTACK_SRC:-"https://github.com/openstack-dev/devstack"}
37LOGDIR="/opt/stack/devstack_logs"
38
39# Number of options passed to this script
40REMAINING_OPTIONS="$#"
41# Get optional parameters
42set +e
43while getopts ":d:l:" flag; do
44 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
45 case "$flag" in
46 d)
47 DEVSTACK_SRC="$DEVSTACK_SRC"
48 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
49 ;;
50 l)
51 LOGDIR="$LOGDIR"
52 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
53 ;;
54 \?)
55 print_usage_and_die "Invalid option -$OPTARG"
56 ;;
57 esac
58done
59set -e
60
61# Make sure that all options processed
62if [ "0" != "$REMAINING_OPTIONS" ]; then
63 print_usage_and_die "ERROR: some arguments were not recognised!"
64fi
65
66#
67# Prepare VM for DevStack
68#
69
70#
71# Configure Networking
72#
73
74MGT_NETWORK=`xe pif-list management=true params=network-uuid minimal=true`
75MGT_BRIDGE_OR_NET_NAME=`xe network-list uuid=$MGT_NETWORK params=bridge minimal=true`
76
77setup_network "$VM_BRIDGE_OR_NET_NAME"
78setup_network "$MGT_BRIDGE_OR_NET_NAME"
79setup_network "$PUB_BRIDGE_OR_NET_NAME"
80
81if parameter_is_specified "FLAT_NETWORK_BRIDGE"; then
82 if [ "$(bridge_for "$VM_BRIDGE_OR_NET_NAME")" != "$(bridge_for "$FLAT_NETWORK_BRIDGE")" ]; then
83 cat >&2 << EOF
84ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file, and either no network
85found on XenServer by searching for networks by that value as name-label or
86bridge name or the network found does not match the network specified by
87VM_BRIDGE_OR_NET_NAME. Please check your localrc file.
88EOF
89 exit 1
90 fi
91fi
92
93if ! xenapi_is_listening_on "$MGT_BRIDGE_OR_NET_NAME"; then
94 cat >&2 << EOF
95ERROR: XenAPI does not have an assigned IP address on the management network.
96please review your XenServer network configuration / localrc file.
97EOF
98 exit 1
99fi
100
101HOST_IP=$(xenapi_ip_on "$MGT_BRIDGE_OR_NET_NAME")
102
103# Also, enable ip forwarding in rc.local, since the above trick isn't working
104if ! grep -q "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
105 echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
106fi
107# Enable ip forwarding at runtime as well
108echo 1 > /proc/sys/net/ipv4/ip_forward
109
110HOST_IP=$(xenapi_ip_on "$MGT_BRIDGE_OR_NET_NAME")
111
112#install the previous ubuntu VM
113
114vm_exist=$(xe vm-list name-label="$DEV_STACK_DOMU_NAME" --minimal)
115if [ "$vm_exist" != "" ]
116then
117 echo "Uninstall the previous VM"
118 xe vm-uninstall vm="$DEV_STACK_DOMU_NAME" force=true
119fi
120
121echo "Install a new ubuntu VM according to previous template"
122
123vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$DEV_STACK_DOMU_NAME")
124
125xe vm-param-set other-config:os-vpx=true uuid="$vm_uuid"
126
127# Install XenServer tools, and other such things
128$SCRIPT_DIR/prepare_guest_template.sh "$DEV_STACK_DOMU_NAME"
129
130# Set virtual machine parameters
131set_vm_memory "$DEV_STACK_DOMU_NAME" "$VM_MEM_MB"
132
133# Max out VCPU count for better performance
134max_vcpus "$DEV_STACK_DOMU_NAME"
135
136# Wipe out all network cards
137destroy_all_vifs_of "$DEV_STACK_DOMU_NAME"
138
139# Add only one interface to prepare the guest template
140add_interface "$DEV_STACK_DOMU_NAME" "$MGT_BRIDGE_OR_NET_NAME" "0"
141
142# start the VM to run the prepare steps
143xe vm-start vm="$DEV_STACK_DOMU_NAME"
144
145# Wait for prep script to finish and shutdown system
146wait_for_VM_to_halt "$DEV_STACK_DOMU_NAME"
147
148## Setup network cards
149# Wipe out all
150destroy_all_vifs_of "$DEV_STACK_DOMU_NAME"
151# Tenant network
152add_interface "$DEV_STACK_DOMU_NAME" "$VM_BRIDGE_OR_NET_NAME" "$VM_DEV_NR"
153# Management network
154add_interface "$DEV_STACK_DOMU_NAME" "$MGT_BRIDGE_OR_NET_NAME" "$MGT_DEV_NR"
155# Public network
156add_interface "$DEV_STACK_DOMU_NAME" "$PUB_BRIDGE_OR_NET_NAME" "$PUB_DEV_NR"
157
158#
159# persistant the VM's interfaces
160#
161$SCRIPT_DIR/persist_domU_interfaces.sh "$DEV_STACK_DOMU_NAME"
162
163
164FLAT_NETWORK_BRIDGE="${FLAT_NETWORK_BRIDGE:-$(bridge_for "$VM_BRIDGE_OR_NET_NAME")}"
165append_kernel_cmdline "$DEV_STACK_DOMU_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}"
166
167# Add a separate xvdb, if it was requested
168if [[ "0" != "$XEN_XVDB_SIZE_GB" ]]; then
169 vm=$(xe vm-list name-label="$DEV_STACK_DOMU_NAME" --minimal)
170
171 # Add a new disk
172 localsr=$(get_local_sr)
173 extra_vdi=$(xe vdi-create \
174 name-label=xvdb-added-by-devstack \
175 virtual-size="${XEN_XVDB_SIZE_GB}GiB" \
176 sr-uuid=$localsr type=user)
177 xe vbd-create vm-uuid=$vm vdi-uuid=$extra_vdi device=1
178fi
179
180#
181# Run DevStack VM
182#
183xe vm-start vm="$DEV_STACK_DOMU_NAME"
184
185# Get hold of the Management IP of OpenStack VM
186OS_VM_MANAGEMENT_ADDRESS=$MGT_IP
187if [ $OS_VM_MANAGEMENT_ADDRESS == "dhcp" ]; then
188 OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $DEV_STACK_DOMU_NAME $MGT_DEV_NR)
189fi
190
191# Create an ssh-keypair, and set it up for dom0 user
192rm -f /root/dom0key /root/dom0key.pub
193ssh-keygen -f /root/dom0key -P "" -C "dom0"
194DOMID=$(get_domid "$DEV_STACK_DOMU_NAME")
195
196xenstore-write /local/domain/$DOMID/authorized_keys/$DOMZERO_USER "$(cat /root/dom0key.pub)"
197xenstore-chmod -u /local/domain/$DOMID/authorized_keys/$DOMZERO_USER r$DOMID
198
199function run_on_appliance {
200 ssh \
201 -i /root/dom0key \
202 -o UserKnownHostsFile=/dev/null \
203 -o StrictHostKeyChecking=no \
204 -o BatchMode=yes \
205 "$DOMZERO_USER@$OS_VM_MANAGEMENT_ADDRESS" "$@"
206}
207
208# Wait until we can log in to the appliance
209while ! run_on_appliance true; do
210 sleep 1
211done
212
213# Remove authenticated_keys updater cronjob
214echo "" | run_on_appliance crontab -
215
216# Generate a passwordless ssh key for domzero user
217echo "ssh-keygen -f /home/$DOMZERO_USER/.ssh/id_rsa -C $DOMZERO_USER@appliance -N \"\" -q" | run_on_appliance
218
219# Authenticate that user to dom0
220run_on_appliance cat /home/$DOMZERO_USER/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
221
222set +x
223echo "################################################################################"
224echo ""
225echo "VM configuration done!"
226echo "################################################################################"
227
228
229xe vm-shutdown vm="$DEV_STACK_DOMU_NAME"
230wait_for_VM_to_halt "$DEV_STACK_DOMU_NAME"
231#
232# Mount the VDI
233#
234echo "check vdi mapping"
235STAGING_DIR=$($SCRIPT_DIR/manage-vdi open $DEV_STACK_DOMU_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
236add_on_exit "$SCRIPT_DIR/manage-vdi close $DEV_STACK_DOMU_NAME 0 1"
237# Make sure we have a stage
238if [ ! -d $STAGING_DIR/etc ]; then
239 echo "ERROR:ct properly set up!"
240 exit 1
241fi
242
243if [ ! -d "$STAGING_DIR/opt/stack" ]; then
244 echo "ERROR: scet"
245 exit -1
246fi
247
248rm -f $STAGING_DIR/opt/stack/local.conf
249XENSERVER_IP=$(xe host-list params=address minimal=true)
250
251# Create an systemd task for devstack
252cat >$STAGING_DIR/etc/systemd/system/devstack.service << EOF
253[Unit]
254Description=Install OpenStack by DevStack
255
256[Service]
257Type=oneshot
258RemainAfterExit=yes
259ExecStartPre=/bin/rm -f /opt/stack/runsh.succeeded
260ExecStart=/bin/su -c "/opt/stack/run.sh" stack
261StandardOutput=tty
262StandardError=tty
263
264[Install]
265WantedBy=multi-user.target
266
267EOF
268
269if [ $? -ne 0 ]; then
270echo "fatal error, install service failed."
271exit 1
272fi
273
274# enable this service
275rm -f $STAGING_DIR/etc/systemd/system/multi-user.target.wants/devstack.service
276ln -s /etc/systemd/system/devstack.service $STAGING_DIR/etc/systemd/system/multi-user.target.wants/devstack.service
277
278# Gracefully cp only if source file/dir exists
279function cp_it {
280 if [ -e $1 ] || [ -d $1 ]; then
281 cp -pRL $1 $2
282 fi
283}
284
285# Copy over your ssh keys and env if desired
286cp_it ~/.ssh $STAGING_DIR/opt/stack/.ssh
287cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/opt/stack/.ssh/authorized_keys
288cp_it ~/.gitconfig $STAGING_DIR/opt/stack/.gitconfig
289cp_it ~/.vimrc $STAGING_DIR/opt/stack/.vimrc
290cp_it ~/.bashrc $STAGING_DIR/opt/stack/.bashrc
291
292
293# Configure run.sh
294DOMU_STACK_DIR=/opt/stack
295DOMU_DEV_STACK_DIR=$DOMU_STACK_DIR/devstack
296cat <<EOF >$STAGING_DIR/opt/stack/run.sh
297#!/bin/bash
298set -eux
299(
300 flock -n 9 || exit 1
301
302 sudo chown -R stack $DOMU_STACK_DIR
303
304 cd $DOMU_STACK_DIR
305
306 [ -e /opt/stack/runsh.succeeded ] && rm /opt/stack/runsh.succeeded
307 echo \$\$ >> /opt/stack/run_sh.pid
308
309 if [ ! -d $DOMU_DEV_STACK_DIR ]; then
310 git clone $DEVSTACK_SRC $DOMU_DEV_STACK_DIR
311 fi
312
313 cp $DOMU_STACK_DIR/local.conf $DOMU_DEV_STACK_DIR/
314
315 cd $DOMU_DEV_STACK_DIR
316 ./unstack.sh || true
317 ./stack.sh
318
319 # Got to the end - success
320 touch /opt/stack/runsh.succeeded
321
322 # Update /etc/issue
323 (
324 echo "OpenStack VM - Installed by DevStack"
325 IPADDR=$(ip -4 address show eth0 | sed -n 's/.*inet \([0-9\.]\+\).*/\1/p')
326 echo " Management IP: $IPADDR"
327 echo -n " Devstack run: "
328 if [ -e /opt/stack/runsh.succeeded ]; then
329 echo "SUCCEEDED"
330 else
331 echo "FAILED"
332 fi
333 echo ""
334 ) > /opt/stack/issue
335 sudo cp /opt/stack/issue /etc/issue
336
337 rm /opt/stack/run_sh.pid
338) 9> /opt/stack/.runsh_lock
339EOF
340
341chmod 755 $STAGING_DIR/opt/stack/run.sh
342if [ ! -f $TOP_DIR/local.conf ]; then
343 echo "ERROR: You should prepare a local.conf and put it under $TOP_DIR"
344 exit 1
345fi
346
347cp_it $TOP_DIR/local.conf $STAGING_DIR/opt/stack/local.conf
348cp_it $THIS_DIR/run.sh $STAGING_DIR/opt/stack/run.sh
diff --git a/install/scripts/install-os-vpx.sh b/tools/install/scripts/install-os-vpx.sh
index 66f7ef4..66f7ef4 100755
--- a/install/scripts/install-os-vpx.sh
+++ b/tools/install/scripts/install-os-vpx.sh
diff --git a/install/scripts/install_ubuntu_template.sh b/tools/install/scripts/install_ubuntu_template.sh
index 17bd6ba..1521eba 100755
--- a/install/scripts/install_ubuntu_template.sh
+++ b/tools/install/scripts/install_ubuntu_template.sh
@@ -46,7 +46,7 @@ fi
46# Clone built-in template to create new template 46# Clone built-in template to create new template
47new_uuid=$(xe vm-clone uuid=$builtin_uuid \ 47new_uuid=$(xe vm-clone uuid=$builtin_uuid \
48 new-name-label="$UBUNTU_INST_TEMPLATE_NAME") 48 new-name-label="$UBUNTU_INST_TEMPLATE_NAME")
49disk_size=$(($CLEAN_VM_VDI_GB * 1024 * 1024 * 1024)) 49disk_size=$(($VM_VDI_GB * 1024 * 1024 * 1024))
50 50
51# Some of these settings can be found in example preseed files 51# Some of these settings can be found in example preseed files
52# however these need to be answered before the netinstall 52# however these need to be answered before the netinstall
diff --git a/tools/install/scripts/manage-vdi b/tools/install/scripts/manage-vdi
new file mode 100755
index 0000000..f3112bb
--- /dev/null
+++ b/tools/install/scripts/manage-vdi
@@ -0,0 +1,97 @@
1#!/bin/bash
2
3set -eux
4
5action="$1"
6vm="$2"
7device="${3-0}"
8part="${4-}"
9
10function xe_min() {
11 local cmd="$1"
12 shift
13 xe "$cmd" --minimal "$@"
14}
15
16function run_udev_settle() {
17 which_udev=$(which udevsettle) || true
18 if [ -n "$which_udev" ]; then
19 udevsettle
20 else
21 udevadm settle
22 fi
23}
24
25vm_uuid=$(xe_min vm-list name-label="$vm")
26vdi_uuid=$(xe_min vbd-list params=vdi-uuid vm-uuid="$vm_uuid" \
27 userdevice="$device")
28
29
30dom0_uuid=$(xe_min vm-list is-control-domain=true)
31
32function get_mount_device() {
33 vbd_uuid=$1
34
35 dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
36 if [[ "$dev" =~ "sm/" || "$dev" =~ "blktap-2/" ]]; then
37 DEBIAN_FRONTEND=noninteractive \
38 apt-get --option "Dpkg::Options::=--force-confold" --assume-yes \
39 install kpartx &> /dev/null || true
40 mapping=$(kpartx -av "/dev/$dev" | sed -ne 's,^add map \([a-z0-9\-]*\).*$,\1,p' | sed -ne "s,^\(.*${part}\)\$,\1,p")
41 if [ -z "$mapping" ]; then
42 echo "Failed to find mapping"
43 exit -1
44 fi
45
46 local device="/dev/mapper/${mapping}"
47 for (( i = 0; i < 5; i++ )) ; do
48 if [ -b $device ] ; then
49 echo $device
50 return
51 fi
52 sleep 1
53 done
54 echo "ERROR: timed out waiting for dev-mapper"
55 exit 1
56 else
57 echo "/dev/$dev$part"
58 fi
59}
60
61function clean_dev_mappings() {
62 dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
63 if [[ "$dev" =~ "sm/" || "$dev" =~ "blktap-2/" ]]; then
64 kpartx -dv "/dev/$dev"
65 fi
66}
67
68function open_vdi() {
69 vbd_uuid=$(xe vbd-create vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid" \
70 device=autodetect)
71 mp=$(mktemp -d)
72 xe vbd-plug uuid="$vbd_uuid"
73
74 run_udev_settle
75
76 mount_device=$(get_mount_device "$vbd_uuid")
77 mount "$mount_device" "$mp"
78 echo "Your vdi is mounted at $mp"
79}
80
81function close_vdi() {
82 vbd_uuid=$(xe_min vbd-list vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid")
83 mount_device=$(get_mount_device "$vbd_uuid")
84 run_udev_settle
85 umount "$mount_device"
86
87 clean_dev_mappings
88
89 xe vbd-unplug uuid=$vbd_uuid
90 xe vbd-destroy uuid=$vbd_uuid
91}
92
93if [ "$action" == "open" ]; then
94 open_vdi
95elif [ "$action" == "close" ]; then
96 close_vdi
97fi
diff --git a/install/scripts/on_exit.sh b/tools/install/scripts/on_exit.sh
index 2846dc4..2846dc4 100755
--- a/install/scripts/on_exit.sh
+++ b/tools/install/scripts/on_exit.sh
diff --git a/tools/install/scripts/persist_domU_interfaces.sh b/tools/install/scripts/persist_domU_interfaces.sh
new file mode 100755
index 0000000..a3ff18d
--- /dev/null
+++ b/tools/install/scripts/persist_domU_interfaces.sh
@@ -0,0 +1,107 @@
1#!/bin/bash
2
3# This script is run by config_devstack_domu_vm.sh
4#
5# It modifies the ubuntu image created by config_devstack_domu_vm.sh
6# and previously moodified by prepare_guest_template.sh
7#
8# This script is responsible for:
9# - pushing in the DevStack code
10# It does this by mounting the disk image of the VM.
11#
12# The resultant image is then templated and started
13# by config_devstack_domu_vm.sh
14
15# Exit on errors
16set -o errexit
17# Echo commands
18set -o xtrace
19
20# This directory
21THIS_DIR=$(cd $(dirname "$0") && pwd)
22TOP_DIR="$THIS_DIR/../"
23SCRIPT_DIR="$TOP_DIR/scripts"
24COMM_DIR="$TOP_DIR/common"
25CONF_DIR="$TOP_DIR/conf"
26
27# Include onexit commands
28. $SCRIPT_DIR/on_exit.sh
29
30# xapi functions
31. $COMM_DIR/functions
32
33# Source params
34source $CONF_DIR/xenrc
35
36#
37# Parameters
38#
39GUEST_NAME="$1"
40
41function _print_interface_config {
42 local device_nr
43 local ip_address
44 local netmask
45
46 device_nr="$1"
47 ip_address="$2"
48 netmask="$3"
49
50 local device
51
52 device="eth${device_nr}"
53
54 echo "auto $device"
55 if [ "$ip_address" = "dhcp" ]; then
56 echo "iface $device inet dhcp"
57 else
58 echo "iface $device inet static"
59 echo " address $ip_address"
60 echo " netmask $netmask"
61 fi
62
63 # Turn off tx checksumming for better performance
64 echo " post-up ethtool -K $device tx off"
65}
66
67function print_interfaces_config {
68 echo "auto lo"
69 echo "iface lo inet loopback"
70
71 _print_interface_config $PUB_DEV_NR $PUB_IP $PUB_NETMASK
72 _print_interface_config $VM_DEV_NR $VM_IP $VM_NETMASK
73 _print_interface_config $MGT_DEV_NR $MGT_IP $MGT_NETMASK
74}
75
76#
77# Mount the VDI
78#
79STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
80add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
81
82# Make sure we have a stage
83if [ ! -d $STAGING_DIR/etc ]; then
84 echo "Stage is not properly set up!"
85 exit 1
86fi
87
88# Only support DHCP for now - don't support how different versions of Ubuntu handle resolv.conf
89if [ "$MGT_IP" != "dhcp" ] && [ "$PUB_IP" != "dhcp" ]; then
90 echo "Configuration without DHCP not supported"
91 exit 1
92fi
93
94# Configure the hostname
95echo $GUEST_NAME > $STAGING_DIR/etc/hostname
96
97# Hostname must resolve for rabbit
98HOSTS_FILE_IP=$PUB_IP
99if [ $MGT_IP != "dhcp" ]; then
100 HOSTS_FILE_IP=$MGT_IP
101fi
102cat <<EOF >$STAGING_DIR/etc/hosts
103127.0.0.1 localhost localhost.localdomain
104EOF
105
106# Configure the network
107print_interfaces_config > $STAGING_DIR/etc/network/interfaces
diff --git a/tools/install/scripts/prepare_guest.sh b/tools/install/scripts/prepare_guest.sh
new file mode 100755
index 0000000..664aef5
--- /dev/null
+++ b/tools/install/scripts/prepare_guest.sh
@@ -0,0 +1,122 @@
1#!/bin/bash
2
3# This script is run on an Ubuntu VM.
4# This script is inserted into the VM by prepare_guest_template.sh
5# and is run when that VM boots.
6# It customizes a fresh Ubuntu install, so it is ready
7# to run stack.sh
8#
9# creating the user called "stack",
10# and shuts down the VM to signal the script has completed
11
12set -o errexit
13set -o nounset
14set -o xtrace
15
16# Configurable nuggets
17GUEST_PASSWORD="$1"
18STACK_USER="$2"
19DOMZERO_USER="$3"
20
21
22function setup_domzero_user {
23 local username
24
25 username="$1"
26
27 local key_updater_script
28 local sudoers_file
29 key_updater_script="/home/$username/update_authorized_keys.sh"
30 sudoers_file="/etc/sudoers.d/allow_$username"
31
32 # Create user
33 adduser --disabled-password --quiet "$username" --gecos "$username"
34
35 # Give passwordless sudo
36 cat > $sudoers_file << EOF
37 $username ALL = NOPASSWD: ALL
38EOF
39 chmod 0440 $sudoers_file
40
41 # A script to populate this user's authenticated_keys from xenstore
42 cat > $key_updater_script << EOF
43#!/bin/bash
44set -eux
45
46DOMID=\$(sudo xenstore-read domid)
47sudo xenstore-exists /local/domain/\$DOMID/authorized_keys/$username
48sudo xenstore-read /local/domain/\$DOMID/authorized_keys/$username > /home/$username/xenstore_value
49cat /home/$username/xenstore_value > /home/$username/.ssh/authorized_keys
50EOF
51
52 # Give the key updater to the user
53 chown $username:$username $key_updater_script
54 chmod 0700 $key_updater_script
55
56 # Setup the .ssh folder
57 mkdir -p /home/$username/.ssh
58 chown $username:$username /home/$username/.ssh
59 chmod 0700 /home/$username/.ssh
60 touch /home/$username/.ssh/authorized_keys
61 chown $username:$username /home/$username/.ssh/authorized_keys
62 chmod 0600 /home/$username/.ssh/authorized_keys
63
64 # Setup the key updater as a cron job
65 crontab -u $username - << EOF
66* * * * * $key_updater_script
67EOF
68
69}
70
71# Make a small cracklib dictionary, so that passwd still works, but we don't
72# have the big dictionary.
73mkdir -p /usr/share/cracklib
74echo a | cracklib-packer
75
76# Make /etc/shadow, and set the root password
77pwconv
78echo "root:$GUEST_PASSWORD" | chpasswd
79
80# Put the VPX into UTC.
81rm -f /etc/localtime
82
83# Add stack user
84groupadd libvirtd
85useradd $STACK_USER -s /bin/bash -d /opt/stack -G libvirtd
86echo $STACK_USER:$GUEST_PASSWORD | chpasswd
87echo "$STACK_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
88
89setup_domzero_user "$DOMZERO_USER"
90
91# Add an udev rule, so that new block devices could be written by stack user
92cat > /etc/udev/rules.d/50-openstack-blockdev.rules << EOF
93KERNEL=="xvd[b-z]", GROUP="$STACK_USER", MODE="0660"
94EOF
95
96# Give ownership of /opt/stack to stack user
97chown -R $STACK_USER /opt/stack
98
99function setup_vimrc {
100 if [ ! -e $1 ]; then
101 # Simple but usable vimrc
102 cat > $1 <<EOF
103se ts=4
104se expandtab
105se shiftwidth=4
106EOF
107 fi
108}
109
110# Setup simple .vimrcs
111setup_vimrc /root/.vimrc
112setup_vimrc /opt/stack/.vimrc
113
114# remove self from local.rc
115# so this script is not run again
116rm -rf /etc/rc.local
117
118# Restore rc.local file
119cp /etc/rc.local.preparebackup /etc/rc.local
120
121# shutdown to notify we are done
122shutdown -h now
diff --git a/tools/install/scripts/prepare_guest_template.sh b/tools/install/scripts/prepare_guest_template.sh
new file mode 100755
index 0000000..3044ae9
--- /dev/null
+++ b/tools/install/scripts/prepare_guest_template.sh
@@ -0,0 +1,99 @@
1#!/bin/bash
2
3# This script is run by install_os_domU.sh
4#
5# Parameters:
6# - $GUEST_NAME - hostname for the DomU VM
7#
8# It modifies the ubuntu image created by install_os_domU.sh
9#
10# This script is responsible for cusomtizing the fresh ubuntu
11# image so on boot it runs the prepare_guest.sh script
12# that modifies the VM so it is ready to run stack.sh.
13# It does this by mounting the disk image of the VM.
14#
15# The resultant image is started by install_os_domU.sh,
16# and once the VM has shutdown, build_xva.sh is run
17
18set -o errexit
19set -o nounset
20set -o xtrace
21
22# This directory
23THIS_DIR=$(cd $(dirname "$0") && pwd)
24TOP_DIR="$THIS_DIR/../"
25SCRIPT_DIR="$TOP_DIR/scripts"
26COMM_DIR="$TOP_DIR/common"
27CONF_DIR="$TOP_DIR/conf"
28
29# Include onexit commands
30. $SCRIPT_DIR/on_exit.sh
31
32# xapi functions
33. $COMM_DIR/functions
34
35# Source params
36source $CONF_DIR/xenrc
37
38#
39# Parameters
40#
41GUEST_NAME="$1"
42
43# Mount the VDI
44STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
45add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
46
47# Make sure we have a stage
48if [ ! -d $STAGING_DIR/etc ]; then
49 echo "Stage is not properly set up!"
50 exit 1
51fi
52
53# Copy prepare_guest.sh to VM
54mkdir -p $STAGING_DIR/opt/stack/
55cp $SCRIPT_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh
56
57# backup rc.local
58cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.preparebackup
59
60echo "$STAGING_DIR/etc/rc.local"
61# run prepare_guest.sh on boot
62cat <<EOF >$STAGING_DIR/etc/rc.local
63#!/bin/sh -e
64bash /opt/stack/prepare_guest.sh \\
65 "$GUEST_PASSWORD" "$STACK_USER" "$DOMZERO_USER" \\
66 > /opt/stack/prepare_guest.log 2>&1
67EOF
68echo "$STAGING_DIR/etc/apt/sources.list"
69# Update ubuntu repositories
70cat > $STAGING_DIR/etc/apt/sources.list << EOF
71deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} main restricted
72deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} main restricted
73deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates main restricted
74deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates main restricted
75deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} universe
76deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} universe
77deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates universe
78deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates universe
79deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} multiverse
80deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE} multiverse
81deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates multiverse
82deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-updates multiverse
83deb http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-backports main restricted universe multiverse
84deb-src http://${UBUNTU_INST_HTTP_HOSTNAME}${UBUNTU_INST_HTTP_DIRECTORY} ${UBUNTU_INST_RELEASE}-backports main restricted universe multiverse
85
86deb http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security main restricted
87deb-src http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security main restricted
88deb http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security universe
89deb-src http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security universe
90deb http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security multiverse
91deb-src http://security.ubuntu.com/ubuntu ${UBUNTU_INST_RELEASE}-security multiverse
92EOF
93
94rm -f $STAGING_DIR/etc/apt/apt.conf
95if [ -n "$UBUNTU_INST_HTTP_PROXY" ]; then
96 cat > $STAGING_DIR/etc/apt/apt.conf << EOF
97Acquire::http::Proxy "$UBUNTU_INST_HTTP_PROXY";
98EOF
99fi
diff --git a/install/scripts/ubuntu_latecommand.sh b/tools/install/scripts/ubuntu_latecommand.sh
index 2afbe2c..2afbe2c 100755
--- a/install/scripts/ubuntu_latecommand.sh
+++ b/tools/install/scripts/ubuntu_latecommand.sh
diff --git a/install/scripts/uninstall-os-vpx.sh b/tools/install/scripts/uninstall-os-vpx.sh
index 96dad7e..96dad7e 100755
--- a/install/scripts/uninstall-os-vpx.sh
+++ b/tools/install/scripts/uninstall-os-vpx.sh
diff --git a/tools/install_on_xen_host.sh b/tools/install_on_xen_host.sh
new file mode 100755
index 0000000..00d4790
--- /dev/null
+++ b/tools/install_on_xen_host.sh
@@ -0,0 +1,201 @@
1#!/bin/bash
2
3set -o errexit
4set -o nounset
5set -o xtrace
6
7export LC_ALL=C
8
9# This directory
10THIS_DIR=$(cd $(dirname "$0") && pwd)
11INSTALL_DIR="$THIS_DIR/install"
12
13COMM_DIR="$INSTALL_DIR/common"
14CONF_DIR="$INSTALL_DIR/conf"
15DEV_STACK_DIR="$INSTALL_DIR/devstack"
16
17. $COMM_DIR/functions
18# Source params
19source $CONF_DIR/xenrc
20
21function print_usage_and_die
22{
23cat >&2 << EOF
24usage: $0 <optional arguments>
25
26A simple script to use devstack to setup an OpenStack. This script should be
27executed on a xenserver host.
28
29optional arguments:
30 -d DEVSTACK_SRC An URL pointing to a tar.gz snapshot of devstack. This
31 defaults to the official devstack repository. Can also be a local
32 file location.
33 -l LOG_FILE_DIRECTORY The directory in which to store the devstack logs on failure.
34 -w WAIT_TILL_LAUNCH Set it to 1 if user want to pending on the installation until
35 it is done
36
37flags:
38 -f Force SR replacement. If your XenServer has an LVM type SR,
39 it will be destroyed and replaced with an ext SR.
40 WARNING: This will destroy your actual default SR !
41
42An example run:
43
44 # Install devstack
45 $0 mypassword
46
47$@
48EOF
49exit 1
50}
51
52# Defaults for optional arguments
53DEVSTACK_SRC=${DEVSTACK_SRC:-"https://github.com/openstack-dev/devstack"}
54LOGDIR="/opt/stack/devstack_logs"
55WAIT_TILL_LAUNCH=1
56FORCE_SR_REPLACEMENT="false"
57
58# Number of options passed to this script
59REMAINING_OPTIONS="$#"
60
61# Get optional parameters
62set +e
63while getopts ":d:fl:w:" flag; do
64 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
65 case "$flag" in
66 d)
67 DEVSTACK_SRC="$OPTARG"
68 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
69 ;;
70 f)
71 FORCE_SR_REPLACEMENT="true"
72 ;;
73 l)
74 LOGDIR="$OPTARG"
75 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
76 ;;
77 w)
78 WAIT_TILL_LAUNCH="$OPTARG"
79 REMAINING_OPTIONS=$(expr "$REMAINING_OPTIONS" - 1)
80 ;;
81 \?)
82 print_usage_and_die "Invalid option -$OPTARG"
83 exit 1
84 ;;
85 esac
86done
87set -e
88
89# Make sure that all options processed
90if [ "0" != "$REMAINING_OPTIONS" ]; then
91 print_usage_and_die "ERROR: some arguments were not recognised!"
92fi
93
94##
95# begin install devstack process
96##
97
98# Verify the host is suitable for devstack
99echo -n "Verify XenServer has an ext type default SR..."
100defaultSR=$(xe pool-list params=default-SR minimal=true)
101currentSrType=$(xe sr-param-get uuid=$defaultSR param-name=type)
102if [ "$currentSrType" != "ext" -a "$currentSrType" != "nfs" -a "$currentSrType" != "ffs" -a "$currentSrType" != "file" ]; then
103 if [ "true" == "$FORCE_SR_REPLACEMENT" ]; then
104 echo ""
105 echo ""
106 echo "Trying to replace the default SR with an EXT SR"
107
108 pbd_uuid=`xe pbd-list sr-uuid=$defaultSR minimal=true`
109 host_uuid=`xe pbd-param-get uuid=$pbd_uuid param-name=host-uuid`
110 use_device=`xe pbd-param-get uuid=$pbd_uuid param-name=device-config param-key=device`
111
112 # Destroy the existing SR
113 xe pbd-unplug uuid=$pbd_uuid
114 xe sr-destroy uuid=$defaultSR
115
116 sr_uuid=`xe sr-create content-type=user host-uuid=$host_uuid type=ext device-config:device=$use_device shared=false name-label="Local storage"`
117 pool_uuid=`xe pool-list minimal=true`
118 xe pool-param-set default-SR=$sr_uuid uuid=$pool_uuid
119 xe pool-param-set suspend-image-SR=$sr_uuid uuid=$pool_uuid
120 xe sr-param-add uuid=$sr_uuid param-name=other-config i18n-key=local-storage
121 exit 0
122 fi
123 echo ""
124 echo ""
125 echo "ERROR: The xenserver host must have an EXT3/NFS/FFS/File SR as the default SR"
126 echo "Use the -f flag to destroy the current default SR and create a new"
127 echo "ext type default SR."
128 echo ""
129 echo "WARNING: This will destroy your actual default SR !"
130 echo ""
131
132 exit 1
133fi
134
135# create template if needed
136$INSTALL_DIR/create_ubuntu_template.sh
137if [ -n "${EXIT_AFTER_JEOS_INSTALLATION:-}" ]; then
138 echo "User requested to quit after JEOS installation"
139 exit 0
140fi
141
142# install DevStack on the VM
143$DEV_STACK_DIR/install_devstack.sh -d $DEVSTACK_SRC -l $LOGDIR
144
145#start openstack domU VM
146xe vm-start vm="$DEV_STACK_DOMU_NAME"
147
148# If we have copied our ssh credentials, use ssh to monitor while the installation runs
149function ssh_no_check {
150 ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
151}
152
153# Get hold of the Management IP of OpenStack VM
154OS_VM_MANAGEMENT_ADDRESS=$MGT_IP
155if [ $OS_VM_MANAGEMENT_ADDRESS == "dhcp" ]; then
156 OS_VM_MANAGEMENT_ADDRESS=$(find_ip_by_name $DEV_STACK_DOMU_NAME $MGT_DEV_NR)
157fi
158
159if [ "$WAIT_TILL_LAUNCH" = "1" ] && [ -e ~/.ssh/id_rsa.pub ]; then
160 set +x
161 echo "VM Launched - Waiting for run.sh"
162 while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "test -e /opt/stack/run_sh.pid"; do
163 echo "VM Launched - Waiting for run.sh"
164 sleep 10
165 done
166 echo -n "devstack service is running, waiting for stack.sh to start logging..."
167
168 pid=`ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "cat /opt/stack/run_sh.pid"`
169 if [ -n "$LOGDIR" ]; then
170 while ! ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "test -e ${LOGDIR}/stack.log"; do
171 echo -n "..."
172 sleep 10
173 done
174
175 ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "tail --pid $pid -n +1 -f ${LOGDIR}/stack.log"
176 else
177 echo -n "LOGDIR not set; just waiting for process $pid to finish"
178 ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS "wait $pid"
179 fi
180 # Fail if devstack did not succeed
181 ssh_no_check -q stack@$OS_VM_MANAGEMENT_ADDRESS 'test -e /opt/stack/runsh.succeeded'
182 echo "################################################################################"
183 echo ""
184 echo "All Finished!"
185 echo "You can visit the OpenStack Dashboard"
186 echo "at http://$OS_VM_MANAGEMENT_ADDRESS, and contact other services at the usual ports."
187else
188 set +x
189 echo "################################################################################"
190 echo ""
191 echo "All Finished!"
192 echo "Now, you can monitor the progress of the stack.sh installation by "
193 echo "looking at the console of your domU / checking the log files."
194 echo ""
195 echo "ssh into your domU now: 'ssh stack@$OS_VM_MANAGEMENT_ADDRESS' using your password"
196 echo "and then do: 'sudo systemctl status devstack' to check if devstack is still running."
197 echo "Check that /opt/stack/runsh.succeeded exists"
198 echo ""
199 echo "When devstack completes, you can visit the OpenStack Dashboard"
200 echo "at http://$OS_VM_MANAGEMENT_ADDRESS, and contact other services at the usual ports."
201fi