josenk / terraform-provider-esxi

Terraform-provider-esxi plugin
GNU General Public License v3.0
540 stars 154 forks source link

[feature] support multiple ovf_network mapping, enhance/fix upstream issue #103 #159

Open lamtt77 opened 2 years ago

lamtt77 commented 2 years ago

This PR created from my actual use-cases involved multiple ovf network interfaces already defined in a signed ova file (by other).

Feature:

The changes should work with any variations or orders of the following declaration:

  network_interfaces {
    virtual_network = "VM Network"
    nic_type        = "vmxnet3"
    ovf_network     = "WAN"
  }

  network_interfaces {
    virtual_network = "VyOS VLAN 10"
    nic_type        = "vmxnet3"
    ovf_network     = "LAN"
  }

  network_interfaces {
    virtual_network = "VyOS VLAN 20"
    nic_type        = "vmxnet3"
  }

In the above example, the ova source file defined 2 default ovf network interfaces (WAN and LAN), therefore --net:'WAN=VM Network' --net:'LAN=VM Network' will be generated as new 'net_param'. Without these changes, you will see the error message "OVFtool error: No network mapping specified".

Support 'net_param' style:

Test case 1:

Test case 2:

Test case 3:

Test case 4:

Test case 5:

Test case 6:

Please feel free to let me know should you need any changes/correction from this, I would be happy to revise accordingly.

josenk commented 2 years ago

Thanks for the contribution. I need to do some regression testing to make sure all is OK. I'll update this pr if there's any issues.

lamtt77 commented 2 years ago

I have fixed an issue when ovf_network's value had not been persisted correctly in terraform.tfstate and updated more test case. Everything looks good now from my end. Thanks!

martap79 commented 2 years ago

running into this issue as well. will this be merged at some point?