mirror of
https://github.com/outbackdingo/matchbox.git
synced 2026-01-27 18:19:36 +00:00
93 lines
3.2 KiB
Bash
Executable File
93 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Manage four 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-docker") create_docker;;
|
|
"create-rkt") create_rkt;;
|
|
"start") start;;
|
|
"reboot") reboot;;
|
|
"shutdown") shutdown;;
|
|
"poweroff") poweroff;;
|
|
"destroy") destroy;;
|
|
"delete-disks") delete_disks;;
|
|
*)
|
|
usage
|
|
exit 2
|
|
;;
|
|
esac
|
|
}
|
|
|
|
function usage {
|
|
echo "USAGE: ${0##*/} <command>"
|
|
echo "Commands:"
|
|
echo -e "\tcreate-docker\tcreate 4 libvirt nodes on the docker0 bridge"
|
|
echo -e "\tcreate-rkt\tcreate 4 libvirt nodes on a rkt CNI metal0 bridge"
|
|
echo -e "\tstart\t\tstart the 4 libvirt nodes"
|
|
echo -e "\treboot\t\treboot the 4 libvirt nodes"
|
|
echo -e "\tshutdown\tshutdown the 4 libvirt nodes"
|
|
echo -e "\tpoweroff\tpoweroff the 4 libvirt nodes"
|
|
echo -e "\tdestroy\t\tdestroy the 4 libvirt nodes"
|
|
echo -e "\tdelete-disks\tdelete the allocated disks"
|
|
}
|
|
|
|
function create_docker {
|
|
virt-install --name node1 -u 16e7d8a7-bfa9-428b-9117-363341bb330b --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node2 -u 264cd073-ca62-44b3-98c0-50aad5b5f819 --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node3 -u 39d2e747-2648-4d68-ae92-bbc70b245055 --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node4 -u 4ed46e8e-db69-471e-b874-0990dd65649d --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:docker0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
}
|
|
|
|
function create_rkt {
|
|
virt-install --name node1 -u 16e7d8a7-bfa9-428b-9117-363341bb330b --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:metal0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node2 -u 264cd073-ca62-44b3-98c0-50aad5b5f819 --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:metal0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node3 -u 39d2e747-2648-4d68-ae92-bbc70b245055 --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:metal0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
virt-install --name node4 -u 4ed46e8e-db69-471e-b874-0990dd65649d --pxe --disk pool=default,size=6 --boot=hd,network --network=bridge:metal0 --memory=1024 --vcpus=1 --os-type=linux --noautoconsole
|
|
}
|
|
|
|
nodes=(node1 node2 node3 node4)
|
|
|
|
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
|
|
}
|
|
|
|
function delete_disks {
|
|
virsh pool-refresh default
|
|
for node in ${nodes[@]}; do
|
|
virsh vol-delete --pool default $node.qcow2
|
|
done
|
|
}
|
|
|
|
main $@
|