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 exampledir=$(cd $topdir/../examples; pwd)
15 functions=${topdir}/functions
17 deployiso=${tmpdir}/deploy.iso
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 "Coul 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=${exampledir}/libvirt_dea.yaml
59 deafile=$(cd `dirname $2`; echo `pwd`/`basename $2`)
62 if [ ! -f $deafile ]; then
63 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 controller1 controller2 controller3 compute4 compute5 fuel-master
78 virsh destroy $node >/dev/null 2>&1
81 # Install the Fuel master
82 # (Convert to functions at later stage)
83 echo "Patching iso file"
84 ${functions}/patch-iso.sh $isofile $deployiso $tmpdir || error_exit "Failed to patch ISO"
85 # Swap isofiles from now on
87 . ${functions}/install_iso.sh
88 . ${functions}/deploy_env.sh
90 echo "Waiting for five minutes for deploy to stabilize"
93 echo "Verifying node status after deployment"
94 # Any node with non-ready status?
95 ssh root@10.20.0.2 fuel node 2>/dev/null | tail -n +3 | cut -d "|" -f 2 | \
96 sed 's/ //g' | grep -v ready | wc -l | grep -q "^0$"
98 echo "Deploy failed to verify"
99 ssh root@10.20.0.2 fuel node 2>/dev/null
100 error_exit "Exiting with error status"
102 ssh root@10.20.0.2 fuel node 2>/dev/null
103 echo "Deployment verified"