pve admin tooling
This commit is contained in:
25
proxmox/admin_scripts/shutdown_nomigrates.sh
Executable file
25
proxmox/admin_scripts/shutdown_nomigrates.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
#set -e
|
||||
|
||||
if ! which jq >> /dev/null; then
|
||||
echo "jq not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#echo "USAGE: $0 [node (=hostname))]"
|
||||
host="$HOSTNAME"
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
host="$1"
|
||||
fi
|
||||
|
||||
function shutdown_ids {
|
||||
pvesh get "/nodes/${host}/qemu" --output-format json |\
|
||||
jq -r 'map(select( .status == "running" and (.tags | split(";") | any(.=="nomigrate")) ) | .vmid)[]'
|
||||
}
|
||||
|
||||
shutdown_ids | while IFS= read -r vmid; do
|
||||
pvesh create "/nodes/${host}/qemu/${vmid}/status/shutdown" -timeout 1 &
|
||||
sleep 1
|
||||
done
|
||||
|
||||
wait
|
Reference in New Issue
Block a user