Unable to modify template_contents of a role in my service template [ opennebula 7.0]

hey i’m planing on upgrading opennebula 6.8 to 7.0

i saw there was changes regarding the oneflow templates and the old way of updating templates vm_template_contents, does not apply anymore

This is for example, how i used to do it in 6.8:

This is working for me i can modify the VCPU and MEMORY and other atributes based on custom inputs from my service template

 "roles": [
    {
      "name": "test",
      "cardinality": 1,
      "vm_template": 48,
      "vm_template_contents": "NIC = [\n  NAME = \"_NIC0\",\n  NETWORK_ID = \"$mgmt\" ]\nDISK = [\n  IMAGE = \"$OS_VERSION\",\n  SIZE = \"$VM_SIZE\",\n  IMAGE_UNAME = \"oneadmin\" ]\nVCPU = \"$VIR_CPU\"\nMEMORY = \"$MEMORY\"\",
      "elasticity_policies": [],
      "scheduled_policies": []
    }
  ],
  "ready_status_gate": false,
  "automatic_deletion": true,
  "networks": {
    "mgmt": "M|network|| |id:103"
  },
  "custom_attrs": {
    "OS_VERSION": "M|list|ACP VERSION:|test|test",
    "VM_SIZE": "M|list|Size (MB):|130000,157000,200000|130000",
    "VIR_CPU": "M|range|Select CPU :|4..12|4",
    "MEMORY": "M|list|Select how much RAM(MB) (4GB,8GB,16GB,32GB)|4096,8192,16384,32768|4096"
  },
  "registration_time": 1708960162
}

and in opennebula 7.0 from what i understood from the docs it should be like this

  "user_inputs": {
    "OS_VERSION": "M|list|OS VERSION:|test|test1",
    "SIZE": "M|list|Size (MB):|110000,157000,200000|110000",
    "VIR_CPU": "M|range|Select CPU :|4..12|4",
    "VMEMORY": "M|list|Select how much RAM(MB):|4096,8192,16384|4096"
  },
  "roles": [
    {
      "name": "test",
      "cardinality": 1,
      "type": "vm",
      "template_id": 4,
      "template_contents": {
        "DISK": [
          {
            "IMAGE": "${OS_VERSION}",
            "SIZE": "${VM_SIZE}",
            "IMAGE_UNAME": "oneadmin"
          }
        ],
        "VCPU": "${VIR_CPU}",
        "MEMORY": "${VMEMORY}"
      }
    }
  ],


but this does not work i get empty variables and not the ones i got in user_inputs

any idea on how to implament this in 7.0 ?

Hey, I think it will be better to update first to OpenNebula 6.10 (the migration will be way simpler) and check if everything is working as expected

Also, I suppose you were checking this docs. I know it is not the question, but have you tried defining the user_inputs at role level? If there is a bug it will be very useful

Cheers

Hey @brunorro, thanks for getting back to me!

The reason I didn’t upgrade to 6.10 first is that this is just a staging environment. I’m testing things out before upgrading my production environment to the newer versions. I went straight to 7.0 because there are some really useful features I wanted to try like the use of profiles and tabs in services, which could be very helpful for my setup.

Regarding what you mentioned about placing user_inputs at the role level, I actually tried that as well, but unfortunately, the result is the same. The variable still ends up empty.

Hi, just checking in to see if there’s any update on this issue. If possible, could you also share an example of how to implement it? That would be really helpful for me.

Hello,

There may be a problem with the curly brackets on the service definition variables. Could you please delete them to make them look like this?

"roles": [
    {
      "name": "test",
      "cardinality": 1,
      "type": "vm",
      "template_id": 4,
      "template_contents": {
        "DISK": [
          {
            "IMAGE": "$OS_VERSION",
            "SIZE": "$VM_SIZE",
            "IMAGE_UNAME": "oneadmin"
          }
        ],
        "VCPU": "$VIR_CPU",
        "MEMORY": "$VMEMORY"
      }
    }
  ],

hey brunorro, thanks for the reply. i tried what you said here and when i try to put the values without curly brackets, i get this error for example for IMAGE value

Aug 8, 2025, 12:51 AM [Error] Role test : Instantiate failed for template 4; [one.template.instantiate] Error allocating a new virtual machine template. DISK 0: User 0 does not own an image with name: $OS_VERSION . Set IMAGE_UNAME or IMAGE_UID of owner in DISK

i tried also with other values like VCPU and MEMORY but i get these errors on these values probably because it’s not picking my variable that way

Instantiate failed for template 4; [one.template.instantiate] Error allocating a new virtual machine template. MEMORY attribute must be a positive integer value.

Any idea regarding this? Should I open a bug? I truly don’t know if I’m doing something wrong or if it’s a bug

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.