OpenNebula / terraform-provider-opennebula

Terraform provider for OpenNebula
https://www.terraform.io/docs/providers/opennebula/
Mozilla Public License 2.0
61 stars 53 forks source link

It is not possible to add more than a PCI device (passthrough) to a VM #540

Open brodriguez-opennebula opened 3 months ago

brodriguez-opennebula commented 3 months ago

Description

By default, a PCI template section does not allow more than one element

Terraform and Provider version

1.4.0

Affected resources and data sources

No response

Terraform configuration

template_section {
  name = "PCI"
  elements = {
    VENDOR = "...",
    DEVICE = "...",
    CLASS = "..."
  }
}

template_section {
  name = "PCI"
  elements = {
    VENDOR = "...",
    DEVICE = "...",
    CLASS = "..."
  }
}

Expected behavior

Both PCI elements should be created

Actual behavior

Only a PCI entry is created

Steps to Reproduce

template_section {
  name = "PCI"
  elements = {
    VENDOR = "...",
    DEVICE = "...",
    CLASS = "..."
  }
}

template_section {
  name = "PCI"
  elements = {
    VENDOR = "...",
    DEVICE = "...",
    CLASS = "..."
  }
}

Debug output

No response

Panic output

No response

Important factoids

No response

References

No response

treywelsh commented 3 months ago

The template_section limitation is expected to keep things simple. In this case we just need to find the vector with the matching name. However, having the same name in multiple template_section implies that we need to compare the contents when reading i.e. matching the template_section with the same keys, same values. See initial template_section PR here: https://github.com/OpenNebula/terraform-provider-opennebula/pull/362

To solve you probleme we could either improve template_section to manage multiple instances with the same name, or introduce a PCI section like disk or nic. In this case, should we may want to introduce directly a new resource named opennebula_virtual_machine_pci.