User inputs to define DISK image in VM template?

How can I use user inputs in an OpenNebula VM template to define the DISK image? The documentation provides an example of selecting the OS using user inputs, but I’ve tried several approaches without success. What am I missing or doing wrong?

Example:

CONTEXT = [
NETWORK = “YES”,
SET_HOSTNAME = “$HOSTNAME”,
SSH_PUBLIC_KEY = “$USER[SSH_PUBLIC_KEY]” ]
CPU = “1”
DISK = [
IMAGE = “$OPERATIVE_SYSTEM”,
IMAGE_UNAME = “oneadmin” ]
GRAPHICS = [
LISTEN = “0.0.0.0”,
TYPE = “vnc” ]
LOGO = “images/logos/linux.png”
LXD_SECURITY_PRIVILEGED = “true”
MEMORY = “128”
NIC_DEFAULT = [
MODEL = “virtio” ]
OS = [
ARCH = “x86_64” ]
USER_INPUTS = [
HOSTNAME = “M|text|Hostname”,
OPERATIVE_SYSTEM = “M|list|Operative System|ubuntu-20.04,alpine-linux-3.20” ]

Hi @Emanuel_Torres :wave:

Welcome to the OpenNebula forum!

The image you share only shows an example of how user entries work. Unfortunately, you cannot use user entries to select disks for the VM. User inputs can be used to add attributes to the VM and environment variables as well in case you add these attributes to the CONTEXT section. Here is an example:

USER_INPUTS = [
  BLOG_TITLE="M|text|Blog Title",
  MYSQL_PASSWORD="M|password|MySQL Password",
]

CONTEXT=[
  BLOG_TITLE="$BLOG_TITLE",
  MYSQL_PASSWORD="$MYSQL_PASSWORD" ]

In this case, OpenNebula will ask the user (using Sunstone or CLI) for the attributes defined in user inputs, subsequently filling these values in the CONTEXT section of the VM.

In case you need to provide the user with VMs with different distributions, you should create a separate VM template for each of them.

Best,
Victor.

1 Like

Thanks Much Victor!