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

IMMO WETZEL IMMO.WETZEL at adtran.com
Thu Dec 15 11:50:24 CET 2016


Thats cool thanks a lot

Immo

-----Original Message-----
From: pve-user [mailto:pve-user-bounces at pve.proxmox.com] On Behalf Of Mark Schouten
Sent: Thursday, December 15, 2016 11:42 AM
To: PVE User List
Subject: Re: [PVE-User] fast way to get all vm names via pvesh?


pve:/> get /cluster/resources -type=vm


?

Met vriendelijke groeten,

--
Kerio Operator in de Cloud? https://www.kerioindecloud.nl/ Mark Schouten  | Tuxis Internet Engineering
KvK: 61527076 | http://www.tuxis.nl/
T: 0318 200208 | info at tuxis.nl



 Van:   IMMO WETZEL <IMMO.WETZEL at adtran.com> 
 Aan:   "pve-user at pve.proxmox.com" <pve-user at pve.proxmox.com> 
 Verzonden:   15-12-2016 11:35 
 Onderwerp:   [PVE-User] fast way to get all vm names via pvesh? 

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 ?

Mit freundlichen Grüßen / With kind regards

Immo Wetzel
_______________________________________________
pve-user mailing list
pve-user at pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user
_______________________________________________
pve-user mailing list
pve-user at pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-user


More information about the pve-user mailing list