Skip to content

Inner Workings

GoodOldJack12 edited this page Oct 23, 2026 · 1 revision

Important

This page was written for version 0.0.13

VM

VM Templates

The tofu module uses a base template ( UserDefault or UserL40 for GPUs) that contains some restricted attributes that are effectively mandatory for users to use.

Then, tofu adds its own configuration (cpu, memory, disks, …) on top of that to create the VM.

Disks

Warning

At the time of writing, there are quite a few issues with disks, so there are a lot of workarounds in the code

This module clones the given image into a new, persistent image that will be the root disk for the VM. For convenience, disk creation of any kind is handled by the disk submodule.

Windows

Windows only supports 1 or 2 CPU sockets (depending on the edition), and the hypervisor exposes vCPUs as sockets. To get around this, the tofu module defines a different topology:

    content {
      name = "TOPOLOGY"
      elements = {
        "CORES"         = max(coalesce(var.cpu / 2, data.opennebula_template.template.cpu / 2), 1),
        "SOCKETS"       = 1,
        "THREADS"       = 2,
        "HUGEPAGE_SIZE" = 1024, # Since this is in the base template, removing it is not allowed.
      }
    }

Virtual Router

Router Templates

Just like the VMs, routers have a base template (vr and vr_vsc). vr_vsc contains a startup script that creates all the routes for the VSC network. This way we can update the routes without updating the tofu templates.

The routes will not be updated on existing VMs, however.

Port Forwarding

The router submodule supports port forwarding. The OpenNebula Virtual Router appliance takes these rules as entries in the CONTEXT in the following format:

ONEAPP_VNF_NAT4_PORT_FWDX = "publicip:port:privateip:port"

portforwarding.tf processes both the access_vm port forwarding rules, as well as any custom port forwarding rules in order to append them to the virtual router.

Clone this wiki locally