2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 # stefan.k.berg@ericsson.com
5 # jonas.bjurel@ericsson.com
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
13 topdir=$(cd `dirname $0`; pwd)
14 functions=${topdir}/functions
16 deployiso=${tmpdir}/deploy.iso
17 cloud_deploy=$(cd ${topdir}/cloud_deploy; pwd)
19 # Define common functions
20 . ${functions}/common.sh
24 kill -9 `ps -p $killpid -o pid --no-headers` \
25 `ps --ppid $killpid -o pid --no-headers`\
29 # Set maximum allowed deploy time (default three hours)
30 MAXDEPLOYTIME=${MAXDEPLOYTIME-3h}
34 if [ "`whoami`" != "root" ]; then
35 error_exit "You need be root to run this script"
38 if [ $# -eq 0 -o $# -gt 2 ]; then
39 error_exit "Argument error"
43 if [ -d $tmpdir ]; then
44 rm -Rf $tmpdir || error_exit "Could not remove tmpdir $tmpdir"
47 mkdir $tmpdir || error_exit "Could not create tmpdir $tmpdir"
50 error_exit "Could not find ISO file $1"
52 isofile=$(cd `dirname $1`; echo `pwd`/`basename $1`)
55 # If no DEA specified, use the example one
57 deafile=${topdir}/dea.yaml
59 deafile=$(cd `dirname $2`; echo `pwd`/`basename $2`)
61 cp ${deafile} ${cloud_deploy}/
63 if [ ! -f $deafile ]; then
64 error-exit "Could not find DEA file $deafile"
68 echo "Enabling auto-kill if deployment exceeds $MAXDEPLOYTIME"
69 (sleep $MAXDEPLOYTIME; echo "Auto-kill of deploy after a timeout of $MAXDEPLOYTIME"; kill $$) &
73 trap exit_handler exit
76 for node in `ls libvirt/vms`
78 virsh destroy $node >/dev/null 2>&1
82 # Install the Fuel master
83 # (Convert to functions at later stage)
84 echo "Patching iso file"
85 ${functions}/patch-iso.sh $isofile $deployiso $tmpdir || error_exit "Failed to patch ISO"
86 # Swap isofiles from now on
88 . ${functions}/install_iso.sh
90 python ${cloud_deploy}/cloud_deploy.py
92 echo "Waiting for five minutes for deploy to stabilize"
95 echo "Verifying node status after deployment"
96 # Any node with non-ready status?
97 ssh root@10.20.0.2 fuel node 2>/dev/null | tail -n +3 | cut -d "|" -f 2 | \
98 sed 's/ //g' | grep -v ready | wc -l | grep -q "^0$"
100 echo "Deploy failed to verify"
101 ssh root@10.20.0.2 fuel node 2>/dev/null
102 error_exit "Exiting with error status"
104 ssh root@10.20.0.2 fuel node 2>/dev/null
105 echo "Deployment verified"