OpenNebula / terraform-provider-opennebula

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

Support Virtual Network scheduling (NETWORK_MODE = "auto") on virtual machine nics #477

Closed jamie-pate closed 8 months ago

jamie-pate commented 1 year ago

Description

https://docs.opennebula.io/6.2/management_and_operations/capacity_planning/scheduling.html#scheduling-virtual-networks

There is already a sched_requirements property on the opennebula_virtual_machine and opennebula_template definition, so it would make sense to carry this through to the nic structure.

I propose to add a mechanism to enable NETWORK_MODE=auto and other parameters to automatically determine the NIC to attach to a VM and Template.

It could look something like this:

nic {
  network_mode = "auto"
  sched_requirements = "TRAFFIC_TYPE = \"public\" "
  sched_rank = "-USED_LEASES"
]

This would enable automatic nic scheduling for VMs and reduce the terraform resources needed to set up a VM From the docs:

NIC = [ NETWORK_MODE = "auto",
        SCHED_REQUIREMENTS = "TRAFFIC_TYPE = \"public\"",
        SCHED_RANK = "-USED_LEASES" ]

New or affected resources and data sources

opennebula_virtual_machine and opennebula_template

Potential terraform configuration

resource "opennebula_virtual_machine" "my_vm" {
//...
nic {
  network_mode = "auto"
  sched_requirements = "TRAFFIC_TYPE = \"public\" "
  sched_rank = "-USED_LEASES"
]
}
resource "opennebula_template" "my_template" {
//...
nic {
  network_mode = "auto"
  sched_requirements = "TRAFFIC_TYPE = \"public\" "
  sched_rank = "-USED_LEASES"
]
}

### References

https://docs.opennebula.io/6.2/management_and_operations/capacity_planning/scheduling.html#scheduling-virtual-networks

NIC = [ NETWORK_MODE = "auto", SCHED_REQUIREMENTS = "TRAFFIC_TYPE = \"public\"", SCHED_RANK = "-USED_LEASES" ]

jamie-pate commented 1 year ago

Might be handy for datastores also?

treywelsh commented 12 months ago

For the disk with datastore scheduling open an other issue, please.

At first glance:

This will require careful testing regarding the tests cases to cover, the complexity of nic management code etc.