Peter Surda
28d722e9c9
- forgot to change VM name - also some code quality fixes in virt-install-all.sh
165 lines
5.4 KiB
Bash
Executable File
165 lines
5.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
trusty()
|
|
{
|
|
id="$1"
|
|
qemu-img create -b /var/lib/libvirt/backingstore/trusty.qcow2 \
|
|
-f qcow2 -F qcow2 \
|
|
/var/lib/libvirt/ephemeral/trusty_libvirt_"${hostname}_${id}".qcow2
|
|
cloud-localds /var/lib/libvirt/ephemeral/trusty_libvirt_"${hostname}_${id}".iso \
|
|
/var/lib/libvirt/backingstore/trusty.user
|
|
|
|
virsh undefine trusty_libvirt_"${hostname}_${id}"
|
|
|
|
xml=$(mktemp)
|
|
|
|
virt-install -r "$mempercore" --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
|
|
-n trusty_libvirt_"${hostname}_${id}" -w network=default --nographics \
|
|
--disk path=/var/lib/libvirt/ephemeral/trusty_libvirt_"${hostname}_${id}".qcow2 \
|
|
--disk path=/var/lib/libvirt/ephemeral/trusty_libvirt_"${hostname}_${id}".iso,device=cdrom \
|
|
--import --noautoconsole \
|
|
--print-xml --dry-run --check disk_size=off,path_in_use=off \
|
|
--boot=hd --os-type=Linux --os-variant ubuntu14.04 > "$xml"
|
|
|
|
virsh define "$xml"
|
|
|
|
rm -f "$xml" /var/lib/libvirt/ephemeral/trusty_libvirt_"${hostname}_${id}".{iso,qcow2}
|
|
}
|
|
|
|
xenial()
|
|
{
|
|
id="$1"
|
|
qemu-img create -b /var/lib/libvirt/backingstore/xenial.qcow2 \
|
|
-f qcow2 -F qcow2 \
|
|
/var/lib/libvirt/ephemeral/xenial_libvirt_"${hostname}_${id}".qcow2
|
|
cloud-localds /var/lib/libvirt/ephemeral/xenial_libvirt_"${hostname}_${id}".iso \
|
|
/var/lib/libvirt/backingstore/xenial.user
|
|
|
|
virsh undefine xenial_libvirt_"${hostname}_${id}"
|
|
|
|
xml=$(mktemp)
|
|
|
|
virt-install -r "$mempercore" --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
|
|
-n xenial_libvirt_"${hostname}_${id}" -w network=default --nographics \
|
|
--disk path=/var/lib/libvirt/ephemeral/xenial_libvirt_"${hostname}_${id}".qcow2 \
|
|
--disk path=/var/lib/libvirt/ephemeral/xenial_libvirt_"${hostname}_${id}".iso,device=cdrom \
|
|
--import --noautoconsole \
|
|
--print-xml --dry-run --check disk_size=off,path_in_use=off \
|
|
--boot=hd --os-type=Linux --os-variant ubuntu16.04 > "$xml"
|
|
|
|
virsh define "$xml"
|
|
|
|
rm -f "$xml" /var/lib/libvirt/ephemeral/xenial_libvirt_"${hostname}_${id}".{iso,qcow2}
|
|
}
|
|
|
|
bionic()
|
|
{
|
|
id="$1"
|
|
qemu-img create -b /var/lib/libvirt/backingstore/bionic.qcow2 \
|
|
-f qcow2 -F qcow2 \
|
|
/var/lib/libvirt/ephemeral/bionic_libvirt_"${hostname}_${id}".qcow2
|
|
cloud-localds /var/lib/libvirt/ephemeral/bionic_libvirt_"${hostname}_${id}".iso \
|
|
/var/lib/libvirt/backingstore/bionic.user
|
|
|
|
virsh undefine bionic_libvirt_"${hostname}_${id}"
|
|
|
|
xml=$(mktemp)
|
|
|
|
virt-install -r "$mempercore" --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
|
|
-n bionic_libvirt_"${hostname}_${id}" -w network=default --nographics \
|
|
--disk path=/var/lib/libvirt/ephemeral/bionic_libvirt_"${hostname}_${id}".qcow2 \
|
|
--disk path=/var/lib/libvirt/ephemeral/bionic_libvirt_"${hostname}_${id}".iso,device=cdrom \
|
|
--import --noautoconsole \
|
|
--print-xml --dry-run --check disk_size=off,path_in_use=off \
|
|
--boot=hd --os-type=Linux --os-variant ubuntu18.04 > "$xml"
|
|
|
|
virsh define "$xml"
|
|
|
|
rm -f "$xml" /var/lib/libvirt/ephemeral/bionic_libvirt_"${hostname}_${id}".{iso,qcow2}
|
|
}
|
|
|
|
focal()
|
|
{
|
|
id="$1"
|
|
qemu-img create -b /var/lib/libvirt/backingstore/focal.qcow2 \
|
|
-f qcow2 -F qcow2 \
|
|
/var/lib/libvirt/ephemeral/focal_libvirt_"${hostname}_${id}".qcow2
|
|
cloud-localds /var/lib/libvirt/ephemeral/focal_libvirt_"${hostname}_${id}".iso \
|
|
/var/lib/libvirt/backingstore/focal.user
|
|
|
|
virsh undefine focal_libvirt_"${hostname}_${id}"
|
|
|
|
xml=$(mktemp)
|
|
|
|
virt-install -r "$mempercore" --vcpus=2,maxvcpus=2,sockets=1,cores=1,threads=2 \
|
|
-n focal_libvirt_"${hostname}_${id}" -w network=default --nographics \
|
|
--disk path=/var/lib/libvirt/ephemeral/focal_libvirt_"${hostname}_${id}".qcow2 \
|
|
--disk path=/var/lib/libvirt/ephemeral/focal_libvirt_"${hostname}_${id}".iso,device=cdrom \
|
|
--import --noautoconsole \
|
|
--print-xml --dry-run --check disk_size=off,path_in_use=off \
|
|
--boot=hd --os-type=Linux --os-variant ubuntu18.04 > "$xml"
|
|
|
|
virsh define "$xml"
|
|
|
|
rm -f "$xml" /var/lib/libvirt/ephemeral/focal_libvirt_"${hostname}_${id}".{iso,qcow2}
|
|
}
|
|
|
|
elcapitan()
|
|
{
|
|
local id
|
|
local threads
|
|
local cores
|
|
id="$1"
|
|
|
|
virsh undefine elcapitan_libvirt_"${hostname}_${id}"
|
|
|
|
xml=$(mktemp)
|
|
|
|
cat /var/lib/libvirt/backingstore/elcapitan.xml > "$xml"
|
|
|
|
threads="$(grep -c processor /proc/cpuinfo)"
|
|
if [ "$threads" -gt 16 ]; then
|
|
threads=16
|
|
fi
|
|
cores="$((threads/2))"
|
|
|
|
cp /var/lib/libvirt/backingstore/enoch_rev2839_boot \
|
|
/var/lib/libvirt/ephemeral/enoch_rev2839_boot
|
|
|
|
sed -Ei "
|
|
s#<name>.*<#<name>elcapitan_libvirt_${hostname}_${id}<#;
|
|
s#<vcpu (.*)>[0-9]+#<vcpu \\1>$threads#;
|
|
s#<topology (.*)cores='[0-9]+'#<topology \\1cores='$cores'#;
|
|
s#<source file='(.*\\.qcow2)'#<source file='/var/lib/libvirt/ephemeral/elcapitan_libvirt_${hostname}_${id}.qcow2'#;
|
|
" "$xml"
|
|
|
|
virsh define "$xml"
|
|
|
|
rm -f "$xml"
|
|
}
|
|
|
|
hostname=$(hostname|cut -d. -f1)
|
|
|
|
cores=$(grep -E '^cpu cores' /proc/cpuinfo |head -1|cut -d: -f2|tr -d '[:space:]')
|
|
mem=$(sed -E 's/^MemTotal: +([0-9]+) kB/\1/p;d' < /proc/meminfo)
|
|
mempercore=$(((mem/1024-4096)/cores))
|
|
|
|
elcapitan 1
|
|
|
|
for i in $(seq "$cores"); do
|
|
trusty "$i" &
|
|
done
|
|
wait
|
|
for i in $(seq "$cores"); do
|
|
xenial "$i" &
|
|
done
|
|
wait
|
|
for i in $(seq "$cores"); do
|
|
bionic "$i" &
|
|
done
|
|
wait
|
|
for i in $(seq "$cores"); do
|
|
focal "$i" &
|
|
done
|
|
wait
|