terraform-provider-nsxt icon indicating copy to clipboard operation
terraform-provider-nsxt copied to clipboard

nsxt_policy_vms resource not returning multiple VMs with same name

Open m-garrido opened this issue 2 years ago • 1 comments

Describe the bug

In a multi-site NSX-t environment with vSphere replication/SRM in order to protect some VMs, "nsxt_policy_vms" resource only returns one entry for a replicated VM. A replicated VM from one site creates another VM in a second site with the same name as "placeholder". The "nsxt_policy_vms " resource returns an "items" dictonary based on display_name key. So, two VMs with same name is not possible. Therefore, it returns sometimes the wrong one. Depends on the order in NSX-t VMs inventory. It would be nice to add some filters like :

  • VM power state
  • Compute Manager
  • Location ID

With thoses filters, we can force the resource to return only the expected VM.

Reproduction steps

  1. Add two vcenters to nsx-t manager. Each one in a separate site.
  2. Replicate a VM from one site to another. Or, create 2 VMs with same name.
  3. Use "nsxt_policy_vms" resource in order to retrieves all VMs.

Expected behavior

Returned dictonary contains two VMs with the same name.

Additional context

No response

m-garrido avatar Sep 28 '22 17:09 m-garrido

Hi @m-garrido, as you mentioned, this data source is defined by providing a map between display name and a certain type of VM id (single value), so by definition, it can not present two VMs with same name. What it can do, however, is fail the data source in case there are two VMs with same. Would you find this useful?

annakhm avatar Oct 21 '22 18:10 annakhm

Hello @annakhm, thanks for the help. I already know that a dictionary cannot have the same key twice. The aim of my issue is to report an incompatibility for this "data resource" when we use "vSphere replication". I think, VMware developpers can enhanced it by adding another filters like thoses i suggested for example. It would be nice. Just adding a filter for the state should fix that.

m-garrido avatar Nov 04 '22 13:11 m-garrido

Thanks @m-garrido, that makes sense. I've updated issue title to reflect the ask.

annakhm avatar Nov 29 '22 16:11 annakhm