Simplified Virtual Machine Definition File 3.0
This is the simplified version of the complete definition file reference. In this guide, only the basic attributes and functionality are described.
A template file consists of a set of attributes that defines a Virtual Machine. Using the command onetemplate create
, a template can be registered in OpenNebula to be later instantiated.
The syntax of the template file is as follows:
NAME=VALUE
NAME=[NAME1=VALUE1,NAME2=VALUE2...]
This template uses the most common functionality. The following sections briefly explain each attribute.
#### Capacity #### NAME = test-vm MEMORY = 128 CPU = 1 #### Disks #### # OS image, mapped to sda. DISK = [ IMAGE_ID = 2 ] # First DATABLOCK image, mapped to sde DISK = [ IMAGE_ID = 3 ] # Second DATABLOCK image, mapped to sdf DISK = [ IMAGE_ID = 12 ] # swap, sdd DISK = [ TYPE = swap, SIZE = 1024 ] #### Network interfaces #### NIC = [ NETWORK_ID = 1 ] #### I/O Devices #### GRAPHICS = [ TYPE = "vnc", LISTEN = "0.0.0.0", PORT = "5"]
The following attributes can be defined to specify the capacity of a VM.
Attribute | Description | Mandatory |
---|---|---|
NAME | Name that the VM will get for description purposes. | NO - will be set to one-<vmid> if omitted |
MEMORY | Amount of RAM required for the VM, in Megabytes. | YES |
CPU | Percentage of CPU divided by 100 required for the Virtual Machine, half a processor is written 0.5. This value is used by OpenNebula and the scheduler to guide the host overcommitment. | YES - will be set to 1 if omitted, this can be changed in the driver configuration |
VCPU | Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU. | YES - will be set to 1 if omitted, this can be changed in the driver configuration |
The disks of a VM are defined with the DISK
vector attribute. You can define as many DISK
attributes as you need.
There are two ways to attach a disk to a VM: using an OpenNebula image from the image repository, or declaring a disk type that can be created from a source disk file in your system. This guide assumes that you will only use Images from the repository (can be listed with oneimage list
).
To use the registered images in your VMs, you need to specify the IMAGE_ID
sub-attribute.
Once the VM machine is shut down, the changes made to the images can be saved back to the repository. To do so, make your Images persistent, or use the onevm saveas
command to save the changes as a new Image.
DISK Sub-Attribute | Description |
---|---|
IMAGE_ID | ID of the Image to use |
In a similar way that you can create empty datablock Images, VM disks can be created on the fly. This is specially useful to create swap disks.
DISK Sub-Attribute | Description |
---|---|
TYPE | Set to “swap” |
SIZE | size in MB |
When you use images in your VM template, OpenNebula will mount the disks as follows:
Only one OS type image per VM template can be declared, the same applies for CDROM type images. You can use as many DATABLOCK images as you need. Please visit the guide for managing images and the image template reference to learn more about the different image types.
You can find a complete description of the contextualization features in the contextualization guide.
The device prefix sd
can be changed to hd
or other prefix that suits your virtualization hypervisor requirements. You can find more information in the configuration guide and the daemon configuration guide.
For more information on image management and moving please check the Storage guide.
Each network interface of a VM is defined with the NIC
vector attribute. You can define as many NIC
attributes as you need.
For more information on setting up virtual networks please check the Managing Virtual Networks guide.
NIC Sub-Attribute | Description |
---|---|
NETWORK_ID | ID of the network to attach this device, as defined by onevnet |
The following I/O interfaces can be defined for a VM:
Note the hypervisor column states that the attribute is Optional, Mandatory, or -
not supported for that hypervisor
Attribute | Description | XEN | KVM | VMWARE |
---|---|---|---|---|
INPUT | Define input devices, available sub-attributes: - TYPE: values are mouse or tablet - BUS: values are usb , ps2 or xen | - | O | - |
GRAPHICS | Wether the VM should export its graphical display and how, available sub-attributes: - TYPE: values: vnc sdl - LISTEN: IP to listen on. - PORT: port for the VNC server - PASSWD: password for the VNC server - KEYMAP: keyboard configuration locale to use in the VNC display | O | O | - |
$VNC_BASE_PORT + $VMID
, allowing to generate different ports for VMs so they do not collide. The VNC_BASE_PORT
is specified inside the oned.conf
file.