diff options
author | 2015-04-14 14:48:11 +0200 | |
---|---|---|
committer | 2015-04-16 15:18:47 +0000 | |
commit | d2b1e4628ae701c5c220ff7dc98560af7d9855ae (patch) | |
tree | 657f2affd353a55aa625a42ae3ca13857d1d385d /fuel/prototypes/libvirt/setup_vms | |
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/setup_vms')
-rwxr-xr-x | fuel/prototypes/libvirt/setup_vms/apply_setup.sh | 61 | ||||
-rwxr-xr-x | fuel/prototypes/libvirt/setup_vms/dump_setup.sh | 59 | ||||
-rwxr-xr-x | fuel/prototypes/libvirt/setup_vms/setup-vm-host.sh | 16 |
3 files changed, 136 insertions, 0 deletions
diff --git a/fuel/prototypes/libvirt/setup_vms/apply_setup.sh b/fuel/prototypes/libvirt/setup_vms/apply_setup.sh new file mode 100755 index 0000000..1598d66 --- /dev/null +++ b/fuel/prototypes/libvirt/setup_vms/apply_setup.sh @@ -0,0 +1,61 @@ +#!/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 +############################################################################## + +error_exit () { + echo "$@" + exit 1 +} + +netdir='../examples/networks' +vmdir='../examples/vms' +tmpfile=/tmp/foo + +if [ ! -d $netdir ]; then + error_exit "No net directory $netdir" + exit 1 +elif [ ! -d $vmdir ]; then + error_exit "No VM directory $vmdir" + exit 1 +fi + +if [ $# -ne 2 ]; then + echo "Argument error." + echo "`basename $0` <path to storage dir> <size in GB of disk per VM>" + exit 1 +fi + +storagedir=$1 +size=$2 + +if [ ! -d $storagedir ]; then + error_exit "Could not find storagedir directory $storagedir" +fi + +# Create storage space and patch it in +for vm in $vmdir/* +do + storage=${storagedir}/`basename ${vm}`.raw + if [ -f ${storage} ]; then + error_exit "Storage already present: ${storage}" + fi + echo "Creating ${size} GB of storage in ${storage}" + fallocate -l ${size}G ${storage} || \ + error_exit "Could not create storage" + sed "s:<source file='disk.raw':<source file='${storage}':" $vm >$tmpfile + virsh define $tmpfile +done + +for net in $netdir/* +do + virsh net-define $net + virsh net-autostart `basename $net` + virsh net-start `basename $net` +done diff --git a/fuel/prototypes/libvirt/setup_vms/dump_setup.sh b/fuel/prototypes/libvirt/setup_vms/dump_setup.sh new file mode 100755 index 0000000..b65cf31 --- /dev/null +++ b/fuel/prototypes/libvirt/setup_vms/dump_setup.sh @@ -0,0 +1,59 @@ +#!/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 +############################################################################## + +netdir='../examples/networks' +vmdir='../examples/vms' + +if [ -d $netdir ]; then + echo "Net directory already present" + exit 1 +elif [ -d $vmdir ]; then + echo "VM directory already present" + exit 1 +fi + +mkdir -p $netdir +mkdir -p $vmdir + +# Check that no VM is up +if virsh list | egrep -q "fuel-master|controller|compute" ; then + echo "Can't dump while VMs are up:" + virsh list | egrep "fuel-master|controller|compute" + exit 1 +fi + +# Dump all networks in the fuell* namespace +for net in `virsh net-list --all | tail -n+3 | awk '{ print $1 }' | grep fuel` +do + virsh net-dumpxml $net > $netdir/$net +done + +# Dump all fuel-master, compute* and controller* VMs +for vm in `virsh list --all | tail -n+3 | awk '{ print $2 }' | egrep 'fuel-master|compute|controller'` +do + virsh dumpxml $vm > $vmdir/$vm +done + +# Remove all attached ISOs, generalize the rest of the setup +for vm in $vmdir/* +do + sed -i '/.iso/d' $vm + sed -i "s/<source file='.*raw'/<source file='disk.raw'/" $vm + sed -i '/<uuid/d' $vm + sed -i '/<mac/d' $vm +done + +# Generalize all nets +for net in $netdir/* +do + sed -i '/<uuid/d' $net + sed -i '/<mac/d' $net +done diff --git a/fuel/prototypes/libvirt/setup_vms/setup-vm-host.sh b/fuel/prototypes/libvirt/setup_vms/setup-vm-host.sh new file mode 100755 index 0000000..58ce19a --- /dev/null +++ b/fuel/prototypes/libvirt/setup_vms/setup-vm-host.sh @@ -0,0 +1,16 @@ +#!/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 +############################################################################## + +# Tools for installation on the libvirt server/base host +# +apt-get install -y libvirt-bin qemu-kvm tightvncserver virt-manager \ + sshpass fuseiso genisoimage blackbox xterm +restart libvirt-bin |