mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 10:19:35 +00:00
* Update Fedora CoreOS live PXE and disk install examples to Fedora 33 * Increase libvirt VM memory from 2GB to 3GB to support live PXE example, which is mostly just for laptop examples/demos. Reduce the VM count from 3 to 2 to compensate. * Change `fedora-coreos.ign` to suggest using an ed25519 SSH key since Fedora CoreOS 33 disables RSA SHA1 (256 is still ok but most people won't know which they have)
95 lines
2.1 KiB
Bash
Executable File
95 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Manage VM nodes which have a specific set of hardware attributes.
|
|
|
|
VM_MEMORY=${VM_MEMORY:-3048}
|
|
VM_DISK=${VM_DISK:-10}
|
|
|
|
if [ "$EUID" -ne 0 ]
|
|
then echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
function main {
|
|
case "$1" in
|
|
"create") create_docker;;
|
|
"start") start;;
|
|
"reboot") reboot;;
|
|
"shutdown") shutdown;;
|
|
"poweroff") poweroff;;
|
|
"destroy") destroy;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function usage {
|
|
echo "USAGE: ${0##*/} <command>"
|
|
echo "Commands:"
|
|
echo -e "\tcreate\t\tcreate QEMU/KVM nodes on the docker0 bridge"
|
|
echo -e "\tstart\t\tstart the QEMU/KVM nodes"
|
|
echo -e "\treboot\t\treboot the QEMU/KVM nodes"
|
|
echo -e "\tshutdown\tshutdown the QEMU/KVM nodes"
|
|
echo -e "\tpoweroff\tpoweroff the QEMU/KVM nodes"
|
|
echo -e "\tdestroy\t\tdestroy the QEMU/KVM nodes"
|
|
}
|
|
|
|
COMMON_VIRT_OPTS="--memory=${VM_MEMORY} --vcpus=1 --disk pool=default,size=${VM_DISK} --os-type=linux --os-variant=generic --noautoconsole --events on_poweroff=preserve"
|
|
|
|
NODE1_NAME=node1
|
|
NODE1_MAC=52:54:00:a1:9c:ae
|
|
|
|
NODE2_NAME=node2
|
|
NODE2_MAC=52:54:00:b2:2f:86
|
|
|
|
NODE3_NAME=node3
|
|
NODE3_MAC=52:54:00:c3:61:77
|
|
|
|
function create_docker {
|
|
virt-install --name $NODE1_NAME --network=bridge:docker0,mac=$NODE1_MAC $COMMON_VIRT_OPTS --boot=hd,network
|
|
virt-install --name $NODE2_NAME --network=bridge:docker0,mac=$NODE2_MAC $COMMON_VIRT_OPTS --boot=hd,network
|
|
# virt-install --name $NODE3_NAME --network=bridge:docker0,mac=$NODE3_MAC $COMMON_VIRT_OPTS --boot=hd,network
|
|
}
|
|
|
|
nodes=(node1 node2)
|
|
|
|
function start {
|
|
for node in ${nodes[@]}; do
|
|
virsh start $node
|
|
done
|
|
}
|
|
|
|
function reboot {
|
|
for node in ${nodes[@]}; do
|
|
virsh reboot $node
|
|
done
|
|
}
|
|
|
|
function shutdown {
|
|
for node in ${nodes[@]}; do
|
|
virsh shutdown $node
|
|
done
|
|
}
|
|
|
|
function poweroff {
|
|
for node in ${nodes[@]}; do
|
|
virsh destroy $node
|
|
done
|
|
}
|
|
|
|
function destroy {
|
|
for node in ${nodes[@]}; do
|
|
virsh destroy $node
|
|
done
|
|
for node in ${nodes[@]}; do
|
|
virsh undefine $node
|
|
done
|
|
virsh pool-refresh default
|
|
for node in ${nodes[@]}; do
|
|
virsh vol-delete --pool default $node.qcow2
|
|
done
|
|
}
|
|
|
|
main $@
|