dnaeon / py-vpoller

Distributed vSphere API Proxy
Other
83 stars 31 forks source link

Skip all VM's that are in a specific folder ? #249

Open mikefarace opened 6 years ago

mikefarace commented 6 years ago

Hello,

We want to skip all VM's that are in a specific folder in Vsphere. We have a folder where archived and to be deleted VM's are put, which don't need to be monitored, and are already powered off.

We also have one ESXi test machine, that has a group of VMs on it that are only used for test migrations. We want to either exlude this ESXi host and all VMs on it, or exclude them only when they are powered off. I think just excluding them completely is fine. Is there a way to do this?

It seems there is python method to find VMs in a folder, so I was hopping there was a way in vpoller to identify a folder as being excluded. https://stackoverflow.com/questions/37950968/how-to-find-vm-in-particular-folder-using-pyvmomi

dnaeon commented 6 years ago

I’ll be happy to review a PR, but I don’t have time to implement that now.

You can already skip VMs by name pattern, so that’s an option as well.

mikefarace commented 6 years ago

Is there a --properties option on vpoller-client that will show me the folder name? then I can just export the list of VMs and fold those that are in a particular folder, then add those VMs to the exclude line in the YAML file?

dnaeon commented 6 years ago

There's no such feature in vPoller as of today. You might be able to get that by requesting all properties of the VMs, and filter the result based on the folder name, but that would be an expensive API call.

A better approach IMO would be to simply have a naming convention for VMs that are about to be archived - that way you can filter these VMs based on the naming convention.

mikefarace commented 6 years ago

I am thinking now to have some external script run, maybe esxcli or something else can do it, to inventory the VMs and write to a file the list of VMs in the specific folder. Then add exclude those in the import / yaml file. Anyway, thats the best thing I can think of for now.

ioshkin commented 3 years ago

There's no such feature in vPoller as of today. You might be able to get that by requesting all properties of the VMs, and filter the result based on the folder name, but that would be an expensive API call.

Hello. Are there any changes as for today in this question about folder name in properties?