vmware / terraform-provider-vcd

Terraform VMware Cloud Director provider
https://www.terraform.io/docs/providers/vcd/
Mozilla Public License 2.0
146 stars 113 forks source link

vcd_vapp_vm with dualstack ip adress pool ipv4 and ipv6 #1100

Open riconem opened 11 months ago

riconem commented 11 months ago

Community Note

Description

Creation of a vcd_vapp_vm with dualstack ip adress pools in the network section. Currently there are no options for that. You can create a vm with an ip adress pool but you can't choose if it's ipv4 or ipv6 like in the GUI. It's some kind of random behaviour.

resource "vcd_vapp_vm" "web2" {
  vapp_name        = vcd_vapp.web.name
  name             = "web2"
  vapp_template_id = data.vcd_catalog_vapp_template.linux.id
  memory           = 2048
  cpus             = 1

  network {
    type               = "org"
    name               = "net"
    ip_allocation_mode = "POOL"
    adapter_type       = "VMXNET3"
  }
}

When the code is applied and you have a dualstack network with ipv4 and ipv6. It happens that there are a ipv6 ip adress on an ip4 adress pool. It also doesn't add the other ipv4 adress to the pool.

image

Inside the GUI you can choose a pool for ipv4 and ipv6. So it should look like the following.

image

New or Affected Resource(s)

riconem commented 11 months ago

I also tried to implement it, but I am struggeling with it and documented in this issue. Does someone know how to fix the xml error? I am assume that I am using the wrong schemas.

terraform-provider-vcd go-vcloud-director

OnnO14 commented 4 months ago

Is this issue still being tracked and is it planned already?

nxcc commented 4 weeks ago

hi @riconem, just found out how to fix the xml. Looks like order of elements in NetworkConnection is important. You have to move SecondaryIpAddress just below IPAddress, and SecondaryIpAddressAllocationMode below IPAddressAllocationMode in the struct. This also changes the order in the XML. Just tied it out and it works for me.

riconem commented 3 weeks ago

Thank you @nxcc. I will try.

danielmasur commented 1 week ago

Thank you @nxcc. I will try.

@riconem Have you had a chance to test this? My couple first tests looked promising.

Didainius commented 1 week ago

Hello, Just to let you know - we see this is a demanded feature and we're working on it. I am progressing on testing it and looking for possible side effects now as VM operations are quite tricky and based on XML which often gives surprises.

Didainius commented 1 week ago

Hello, I have gone through testing and would like to ask if any of the interested parties could test. Field names are such (they match the approach that we have in Org VDC networks (e.g. https://registry.terraform.io/providers/vmware/vcd/latest/docs/resources/network_routed_v2#secondary_gateway)

image
riconem commented 1 week ago

Thank you. I will test it. Could you also provide your go-vcloud-director version? I couldn't find it.

Didainius commented 1 week ago

Thank you. I will test it. Could you also provide your go-vcloud-director version? I couldn't find it.

Thanks. It is here - https://github.com/vmware/go-vcloud-director/pull/694 (this PR for Terraform also uses it)

riconem commented 1 week ago

It worked on my module 🚀 Thank you

image