mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 18:19:36 +00:00
* Reboot depends on having a VM OS running * Use libvirt start after libvirt poweroff the nodes
76 lines
2.1 KiB
Bash
Executable File
76 lines
2.1 KiB
Bash
Executable File
#!/bin/bash -e
|
|
# Manage 5 VM nodes which have a specific set of hardware attributes.
|
|
|
|
if [ "$EUID" -ne 0 ]
|
|
then echo "Please run as root"
|
|
exit
|
|
fi
|
|
|
|
function main {
|
|
case "$1" in
|
|
"create") create;;
|
|
"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 5 libvirt nodes with specific hardware attributes"
|
|
echo -e "\tstart\t\tstart the 5 libvirt nodes"
|
|
echo -e "\treboot\t\treboot the 5 libvirt nodes"
|
|
echo -e "\tshutdown\tshutdown the 5 libvirt nodes"
|
|
echo -e "\tpoweroff\tpoweroff the 5 libvirt nodes"
|
|
echo -e "\tdestroy\t\tdestroy the 5 libvirt nodes"
|
|
}
|
|
|
|
function create {
|
|
virt-install --name node1 -u 16e7d8a7-bfa9-428b-9117-363341bb330b --pxe --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
|
virt-install --name node2 -u 264cd073-ca62-44b3-98c0-50aad5b5f819 --pxe --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
|
virt-install --name node3 -u 39d2e747-2648-4d68-ae92-bbc70b245055 --pxe --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
|
virt-install --name node4 -u 4ed46e8e-db69-471e-b874-0990dd65649d --pxe --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
|
virt-install --name node5 -u 53683e94-3273-4a49-9a82-d769b88e3ccf --pxe --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --disk none --noautoconsole
|
|
}
|
|
|
|
nodes=(node1 node2 node3 node4 node5)
|
|
|
|
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 undefine $node
|
|
done
|
|
}
|
|
|
|
main $@
|