1
0
Fork 0

add a service and script for making sure that VM pools are online

This commit is contained in:
Pratham Patel 2023-03-25 14:05:50 +05:30
parent ee93c15da6
commit 7fe6aeb4da
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
ALL_OK=false
ALL_VIRT_POOLS=("default" "ISOs")
for POOL in "${ALL_VIRT_POOLS[@]}"; do
POOL_OK=false
while [[ "$POOL_OK" == "false" ]]; do
virsh pool-info --pool "$POOL" | grep "State: *running" > /dev/null
if [[ $? -ne 0 ]]; then
echo "$POOL: not running"
systemctl restart libvirtd && POOL_OK=true
else
echo "$POOL: OK"
POOL_OK=true
fi
done
done

View File

@ -0,0 +1,9 @@
[Unit]
Description=Ensure that the VM pools are available
[Service]
ExecStart=/usr/bin/bash /home/pratham/.scripts/_flameboi/virt/ensure-pool-online-status.sh
Type=simple
[Install]
WantedBy=multi-user.target