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

Add `opennebula_group_quota` resource #447

Closed frousselet closed 1 year ago

frousselet commented 1 year ago

Description

I am facing an issue where using quotas in opennebula_group applies only in one of our two zones, and detects drift when creating resources without defining a quota.

Instead of using an attribute, I suggest to add a new resource opennebula_group_quota to be able to select the zone where the quotas will apply.

In the HCL bellow, all opennebula_group_quota > scope conflict with each others.

units, running_units, size, running_size, leases are optional. If not set, the value is -1, meaning .

Since a quota doesn't have any ID in the OpenNebula side, there is no way to import. Even if the quota exists, terraforming a new one will override it.

In the same way, there is no data source, but quotas might be returned when fetching opennebula_group as usual.

New or affected resources and data sources

Potential terraform configuration

resource "opennebula_group" "hw" {
  name = "My Group"

  # quotas {} # Deprecated
}

resource "opennebula_group_quota" "vm" {
  group_id = opennebula_group.hw.id

  scope         = "vm"
  units         = 8    # Number of units
  running_units = 8    # Number of running units
}

resource "opennebula_group_quota" "cpu" {
  group_id = opennebula_group.hw.id

  scope         = "cpu"
  units         = 16    # Number of units
  running_units = 16    # Number of running units
}

resource "opennebula_group_quota" "memory" {
  group_id = opennebula_group.hw.id

  scope        = "memory"
  size         = 16384  # Total size in MB
  running_size = 16384  # Size of running memory in MB
}

resource "opennebula_group_quota" "system_disks" {
  group_id = opennebula_group.hw.id

  scope = "system_disks"
  size  = 20480          # Size in MB
}

resource "opennebula_group_quota" "image" {
  group_id = opennebula_group.hw.id

  scope    = "image"
  image_id = 100          # Only if scope=image
  units    = 2            # Number of units
}

resource "opennebula_group_quota" "network" {
  group_id = opennebula_group.hw.id

  scope    = "network"
  leases   = 1            # Number of units
}

resource "opennebula_group_quota" "datastore" {
  group_id = opennebula_group.hw.id

  scope        = "datastore"
  datastore_id = 100          # Only if scope=datastore
  units        = 1            # Number of units
  size         = 10240        # Size in MB. Only available if scope=datastore
}

References

448