On 12/15/2016 11:35 AM, IMMO WETZEL wrote:
Hi
Thats my current script to get all vm names from the cluster. Afterwards I
check the new name against the list to prevent errors.
#!/usr/bin/env bash
nodes=$(pvesh get /nodes/ 2>/dev/null | sed -n -E '/\"id\"/
s/.*:\s\"(.*)\".*/\1/p' | sed -n -E 's/node/nodes/p' )
vms=$(for i in $nodes ; do vms=$(pvesh get $i/qemu/ 2>/dev/null | sed -n -E
'/vmid/ s/.*:\s(.*[^\s]).*/\/qemu\/\1/p') ; for q in $vms ; do echo $i$q ; done ;
done )
for i in $vms ; do pvesh get $i/config 2>/dev/null | sed -n -E '/\"name\"/
s/.*:\s\"(.*[^\"])\".*/\1/p' | xargs echo "vm $i has name" ; done
But its so SLOOOOOWWWWW
Any better ideas ?
By factor 10 faster than a pvesh call would be the following "one liner":
# shopt -s globstar; for i in /etc/pve/nodes/**/{qemu-server,lxc}/*; do
grep -oP '(?<=name:)\s*(\S+)' "$i"; done
shopt -s globstar is for '**' only and could be circumvented if necessary.
_______________________________________________
pve-user mailing list
[email protected]
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user