Created
January 6, 2017 15:44
-
-
Save brk3/8d029adf03fbfcd5b69f473cea451355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
vms=/storage01/pbourke/VMs | |
hosts=(operator | |
control01 | |
control02 | |
control03 | |
database01 | |
database02 | |
network01 | |
compute01 | |
compute02 | |
storage01 | |
storage02 | |
storage03 | |
monitoring01 | |
) | |
function destroy-env { | |
token=$1 | |
for i in ${hosts[@]}; do | |
virsh undefine $i-$token | |
virsh destroy $i-$token | |
rm $vms/$i-$token.qcow2 | |
done | |
} | |
function mk-env { | |
token=$1 | |
for i in ${hosts[@]}; do | |
name="$i-$token" | |
virt-clone \ | |
--original base-kickstart \ | |
--name $name \ | |
-f $vms/$name.qcow2 \ | |
--auto-clone | |
virt-edit \ | |
-d $name \ | |
/etc/hostname -e "s/^.*/$name/" | |
virt-edit \ | |
-d $name \ | |
/etc/sysconfig/network-scripts/ifcfg-eth0 \ | |
-e 's/^DHCP_HOSTNAME=.*/DHCP_HOSTNAME="'$name'"/' | |
virsh start ${name} | |
done | |
} | |
function start-env { | |
token=$1 | |
for i in ${hosts[@]}; do | |
virsh start $i-$token | |
done | |
} | |
function stop-env { | |
token=$1 | |
for i in ${hosts[@]}; do | |
virsh shutdown $i-$token | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment