feat(nebula): adding multiple data disk support for Virtual Machines

This commit is contained in:
Philippe Caseiro 2023-03-02 16:10:47 +01:00
parent 75babdbff8
commit 18365fdf80
1 changed files with 24 additions and 10 deletions

View File

@ -32,6 +32,17 @@ variable "one_sys_datastore" {
default = "100"
}
locals {
data_disks = flatten([
for vm_key, vm in var.vms : [
for disk in vm.data_disks : {
name = "${vm_key}.${vm.domain}-data-${disk.name}"
size = disk.size
persist = disk.persistent
}
]
])
}
// system image
resource "opennebula_image" "system" {
@ -47,19 +58,22 @@ resource "opennebula_image" "system" {
permissions = var.permissions
}
/* data image not needed now
resource "opennebula_image" "data" {
for_each = var.vms
name = "data-${each.key}.${each.value.domain}"
path = "https://vulcain.cadoles.com/empty_40G"
// data image not needed now
resource "opennebula_image" "data" {
for_each = {
for ds in local.data_disks : "${ds.vm_key}.${ds.name}" => ds
}
name = each.value.name
path = "https://vulcain.cadoles.com/empty_${each.value.size}"
datastore_id = var.one_image_ds
description = "data disk for ${each.key}"
persistent = each.value.data_image_persistent
description = "Data disk of ${each.value.size} for ${each.value.vm_key}"
persistent = each.value.persist
format = var.image_format
dev_prefix = var.dev_prefix
permissions = var.permissions
}*/
}
resource "opennebula_template" "vm_template" {
for_each = var.vms