#!/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