diff options
author | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-04-14 14:48:11 +0200 |
---|---|---|
committer | Stefan Berg <stefan.k.berg@ericsson.com> | 2015-04-16 15:18:47 +0000 |
commit | d2b1e4628ae701c5c220ff7dc98560af7d9855ae (patch) | |
tree | 657f2affd353a55aa625a42ae3ca13857d1d385d /fuel/prototypes/libvirt/deploy/deploy.sh | |
parent | 101550e036ca0dd7cc5bab0fc8e635062ac32138 (diff) |
Prototype of automated libvirt installation
This is a prototype to experiment with the DEA concept and
how to use it to automatically deploy a KVM environment using
libvirt.
It is now possible to perform a fully automated deploy from
an ISO file.
Highlights:
- Fully automated Fuel deploy installing three controllers,
two computes in full HA mode including Ceilometer
- create_dea.sh will create a DEA YAML file with an
existing deployment as template.
- The install will configure settings, networks and the
interface config of all nodes.
JIRA:
Change-Id: Icc8922afca8508c9062aa5be95e2482086a4f624
Signed-off-by: Stefan K. Berg <stefan.k.berg@ericsson.com>
Diffstat (limited to 'fuel/prototypes/libvirt/deploy/deploy.sh')
-rwxr-xr-x | fuel/prototypes/libvirt/deploy/deploy.sh | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/fuel/prototypes/libvirt/deploy/deploy.sh b/fuel/prototypes/libvirt/deploy/deploy.sh new file mode 100755 index 0000000..7eff3da --- /dev/null +++ b/fuel/prototypes/libvirt/deploy/deploy.sh @@ -0,0 +1,98 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2015 Ericsson AB and others. +# stefan.k.berg@ericsson.com +# jonas.bjurel@ericsson.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +# Setup locations +topdir=$(cd `dirname $0`; pwd) +exampledir=$(cd $topdir/../examples; pwd) +functions=${topdir}/functions +tmpdir=$HOME/fueltmp +deployiso=${tmpdir}/deploy.iso + +# Define common functions +. ${functions}/common.sh + +exit_handler() { + # Remove safety catch + kill $killpid +} + +####### MAIN ######## + +if [ "`whoami`" != "root" ]; then + error_exit "You need be root to run this script" +fi + +if [ $# -eq 0 -o $# -gt 2 ]; then + error_exit "Argument error" +fi + +# Setup tmpdir +if [ -d $tmpdir ]; then + rm -Rf $tmpdir || error_exit "Coul not remove tmpdir $tmpdir" +fi + +mkdir $tmpdir || error_exit "Could not create tmpdir $tmpdir" + +if [ ! -f $1 ]; then + error_exit "Could not find ISO file $1" +else + isofile=$(cd `dirname $1`; echo `pwd`/`basename $1`) +fi + +# If no DEA specified, use the example one +if [ $# -eq 1 ]; then + deafile=${exampledir}/libvirt_dea.yaml +else + deafile=$(cd `dirname $2`; echo `pwd`/`basename $2`) +fi + +if [ ! -f $deafile ]; then + error-exit "Could not find DEA file $deafile" +fi + + +# Enable safety catch at three hours +(sleep 3h; kill $$) & +killpid=$! + +# Enable exit handler +trap exit_handler exit + + +# Stop all VMs +for node in controller1 controller2 controller3 compute4 compute5 fuel-master +do + virsh destroy $node >/dev/null 2>&1 +done + +# Install the Fuel master +# (Convert to functions at later stage) +echo "Patching iso file" +${functions}/patch-iso.sh $isofile $deployiso $tmpdir || error_exit "Failed to patch ISO" +# Swap isofiles from now on +isofile=$deployiso +. ${functions}/install_iso.sh +. ${functions}/deploy_env.sh + +echo "Waiting for two minutes for deploy to stabilize" +sleep 2m + +echo "Verifying node status after deployment" +set -o pipefail +# Any node with non-ready status? +ssh root@10.20.0.2 fuel node | tail -n +3 | cut -d "|" -f 2 | \ + sed 's/ //g' | grep -v ready | wc -l | grep -q "^0$" +if [ $? -ne 0 ]; then + error_exit "Deployment failed verification" +else + echo "Deployment verified" +fi + |