capacity limiter and general cleanup

This commit is contained in:
2020-05-13 13:56:43 -05:00
parent a43b3b4e1e
commit 403506a0b0
10 changed files with 121 additions and 50 deletions

View File

@ -0,0 +1,25 @@
#!/bin/sh
## check avaliable RAM and IPv4s
RAM_BYTES_TO_ALLOCATE="$1"
if echo "$RAM_BYTES_TO_ALLOCATE" | grep -vqE "^[0-9]+$"; then
echo "RAM_BYTES_TO_ALLOCATE \"$RAM_BYTES_TO_ALLOCATE\" must be an integer"
exit 1
fi
#100GB
RAM_LIMIT=100000000000
## compare current allocated ram + RAM_BYTES_TO_ALLOCATE with RAM_LIMIT
IPV4_LIMIT=26
IPV4_COUNT=$(grep ip-add /var/lib/libvirt/dnsmasq/virbr1.status | wc -l)
if [ $IPV4_COUNT -gt $IPV4_LIMIT ]; then
echo "IPv4 address limit reached"
exit 1
fi
echo "yes"

View File

@ -10,7 +10,7 @@ three_dots() {
vmname="$1"
if echo "$vmname" | grep -vqE '^capsul-[a-z0-9]{10}$'; then
if echo "$vmname" | grep -vqE '^(cvm|capsul)-[a-z0-9]{10}$'; then
echo "vmname $vmname must match "'"^capsul-[a-z0-9]{10}$"'
exit 1
fi

View File

@ -2,7 +2,7 @@
vmname="$1"
if echo "$vmname" | grep -vqE '^capsul-[a-z0-9]{10}$'; then
if echo "$vmname" | grep -vqE '^(cvm|capsul)-[a-z0-9]{10}$'; then
echo "vmname $vmname must match "'"^capsul-[a-z0-9]{10}$"'
exit 1
fi

View File

@ -0,0 +1,3 @@
#!/bin/sh
virsh list --all | grep running | grep -v ' Id' | grep -v -- '----' | awk '{print $2}' | sort