Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lamtt77
Copy link

@lamtt77 lamtt77 commented Nov 21, 2021

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

Feature:

  • Supports both single --network and/or multiple --net for network_interfaces creation with ova/ovf sources. So multiple network interfaces already defined in ova/ovf source file will not raise error anymore.
  • Before the changes, you have to extract ovf file from ova source and manually change to only single network interface and then re-package that ova file - which will not work if you have to deal with signed ova file.
  • Please see original issue: OVFtool error: No network mapping specified. #103

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:

  • ovf network mapping: --net:'WAN=VM Network' --net:'LAN=VM Network'
  • default style: --network='VM Network'
  • mixed: --network='VyOS VLAN 20' --net:'WAN=VM Network' --net:'LAN=VyOS VLAN 10'

Test case 1:

  • Create with the above example
  • Run terraform apply
  • Add/update
  network_interfaces {
    virtual_network = "VyOS VLAN 30"
    nic_type        = "vmxnet3"
  }

  network_interfaces {
    virtual_network = "VyOS VLAN 40"
    nic_type        = "vmxnet3"
  }
  • Run terraform apply

Test case 2:

  • Create with 1 single network
  • Update with 2,3 more network interfaces
  • Run terraform apply

Test case 3:

  • Create with 4 mixed network interfaces
  • Delete 2 network interfaces
  • Run terraform apply

Test case 4:

  • Create with default (old) style single network
  • Run terraform apply

Test case 5:

  • Define multiple 'esxi_guest' with ovf_network and without ovf_network
  • Run terraform apply

Test case 6:

  • Run terraform destroy and repeat Test Case 1
  • Once successful verify that the value ovf_network has been populated into terraform.tfstate
  • Double-check by running terraform plan, this time it should advise that no changes are needed

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

@josenk
Copy link
Owner

josenk commented Nov 21, 2021

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
Copy link
Author

lamtt77 commented Nov 22, 2021

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants