[PVE-User] fast way to get all vm names via pvesh?

David Lawley davel at upilab.com
Thu Dec 15 13:36:45 CET 2016

no more often than I need it, this works well for me.

thanks for sharing

On 12/15/2016 5:35 AM, IMMO WETZEL wrote:
> #!/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

More information about the pve-user mailing list