Virtual Machine Definition File 2.2
Virtual Machine Definition File 2.2
http://archives.opennebula.org/documentation:archives:rel2.2:template#disks_device_mapping
A template file consists of a set of attributes that defines a Virtual Machine. The syntax of the template file is as follows:
- Anything behind the pound or hash sign (#) is a comment.
- Strings are delimited with double quotes (”), if the a double quote is part of the string it needs to be escaped (\”).
- Single Attributes are in the form:
NAME=VALUE
- Vector Attributes that contain several values can be defined as follows:
NAME=[NAME1=VALUE1,NAME2=VALUE2...]
- Vector Attributes must contain at least one value.
- Attribute names are case insensitive, in fact the names are converted to uppercase internally.
Capacity Section
The following attributes can be defined to specified the capacity of a VM.
| Attribute | Description |
|---|---|
| NAME | Name that the VM will get for description purposes. If NAME is not supplied a name generated by one will be in the form of one-<VID>. |
| MEMORY | Amount of RAM required for the VM, in Megabytes. |
| CPU | Percentage of CPU divided by 100 required for the Virtual Machine. Half a processor is written 0.5. |
| VCPU | Number of virtual cpus. This value is optional, the default hypervisor behavior is used, usually one virtual CPU |
Example:
NAME = test-vm
MEMORY = 128 CPU = 1
OS and Boot Options Section
The OS system is defined with the OS vector attribute. The following sub-attributes are supported:
Note the hypervisor column states that the attribute is Optional, Mandatory, or - not supported for that hypervisor
| OS Sub-Attribute | Description | XEN | KVM |
|---|---|---|---|
| ARCH | CPU architecture to virtualization | - | M (default i686) |
| KERNEL | path to the OS kernel to boot the image | M see (*) | O |
| INITRD | path to the initrd image | O (for kernel) | O (for kernel) |
| ROOT | device to be mounted as root | O (for kernel) | O (for kernel) |
| KERNEL_CMD | arguments for the booting kernel | O (for kernel) | O (for kernel) |
| BOOTLOADER | path to the bootloader executable | M see (*) | O |
| BOOT | boot device type: hd,fd,cdrom ,network |
- | M |
(*) Xen needs a kernel or a bootloader to be specified. If both are set in the template, the kernel boot method will be used.
Example, a VM booting from sda1 with kernel /vmlinuz :
OS = [ KERNEL = /vmlinuz,
INITRD = /initrd.img,
ROOT = sda1,
KERNEL_CMD = "ro xencons=tty console=tty1"]
Disks Section
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. Both kinds of disks can be combined, with some considerations to be taken into account.
Using an Image
In OpenNebula 2.0 the image repository was introduced. To use the registered images in your VMs, you need to specify either the IMAGE or the IMAGE_ID sub-attributes.
Once the VM machine is shut down, the changes made to the images can be saved back to the repository. To do so, use theonevm saveas command.
| DISK Sub-Attribute | M / O | Description |
|---|---|---|
| IMAGE | M | Name of the Image to use |
| IMAGE_ID | O (M if IMAGE is not present) | ID of the Image to use |
| BUS | O | Type of disk device to emulate: ide, scsi |
| TARGET | O | Device to map image disk. If set, it will overwrite the default device mapping. |
| DRIVER | O | Specific image mapping driver. KVM: raw, qcow2. Xen:tap:aio:, file:. VMware unsupported |
Declaring the Disk Type
You can define a DISK from a disk file without having to register it first in the image repository. There are two special disk types that are created on-the-fly in the target resource: swap and fs. The following sub-attributes for DISK are supported:
Note the hypervisor column states that the attribute is Optional, Mandatory, or - not supported for that hypervisor
| DISK Sub-Attribute | Description | XEN | KVM |
|---|---|---|---|
| TYPE | disk type:floppy, disk, cdrom, swap, fs,block |
O (only swap, fs and block) (if not present,disk will be assumed) |
O |
| SOURCE | disk file location path or URL | M | M |
| SIZE | size in MB for swap, fs and block images | M (for swap and fs) |
M (for swapand fs) |
| FORMAT | filesystem type for the fs images | M (for fs) |
M (for fs) |
| TARGET | device to map disk | M (O for swap) |
M (O forswap) |
| CLONE | clone this image yes (default), or no |
O | O |
| SAVE | save this image after shutting down the VM yes, or no (default) |
O | O |
| READONLY | yes, or no (default) |
O | O |
| BUS | type of disk device to emulate: ide, scsi |
- | O |
| DRIVER | special disk mapping options. KVM: raw,qcow2. Xen: tap:aio:, file: |
O | O |
Disks Device Mapping
When you use images in your VM template, you don't have to define the target device to mount them. OpenNebula will mount the disks as follows:
- sda: OS type Image.
- sdb: Contextualization CDROM.
- sdc: CDROM type Image.
- sdd: Swap disk.
- sd[e,f,g…]: DATABLOCK type Images.
This automatic mapping doesn't take into account any disk defined by type (those that do not use an image from the repository), apart from the swap ones.
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 imagesand 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.
An Example
This a sample section for disks. There are three disks using the image repository, and two beeing defined by type. The fs disk target has been set to sdg to avoid conflicts with the other disks that are mapped automatically. Note that fs and swap are generated on-the-fly:
# OS image, mapped to sda.
DISK = [ IMAGE = "Debian 5.0" ] # First DATABLOCK image, mapped to sde
DISK = [ IMAGE = "Testing results" ] # Second DATABLOCK image, mapped to sdf
DISK = [ IMAGE = "Experiment scripts" ] # swap, sdd
DISK = [ TYPE = swap,
SIZE = 1024,
READONLY = "no" ] DISK = [ TYPE = fs,
SIZE = 4096,
FORMAT = ext3,
SAVE = yes,
TARGET = sdg ]
For more information on image management and moving please check the Storage guide.
Network Section
Each network interface of a VM is defined with the NIC vector attribute. You can define as many NIC attributes as you need. The following sub-attributes for NIC are supported:
Note the hypervisor column states that the attribute is Optional, Mandatory, or - not supported for that hypervisor
| NIC Sub-Attribute | Description | XEN | KVM |
|---|---|---|---|
| NETWORK | Name of the network, as defined by onevnet to attach this device |
O | O |
| NETWORK_ID | ID of the network, to attach this device | O | O |
| IP | Request an specific IP from the NETWORK |
O | O |
| MAC | HW address associated with the network interface | O | O |
| BRIDGE | Name of the bridge the network device is going to be attached to. | O | O |
| TARGET | name for the tun device created for the VM | - | O |
| SCRIPT | name of a shell script to be executed after creating the tun device for the VM | - | O |
| MODEL | hardware that will emulate this network interface. With Xen this is the type attribute of the vif. | O | O |
Example, a VM with two NIC attached to two different networks, one make use of the Virtual Network Manager lease feature:
NIC = [ NETWORK = "Public" ] NIC = [ MAC = "00:11:22:33:44:55"
BRIDGE = eth0 ]
For more information on setting up virtual networks please check the Managing Virtual Networks guide.
I/O Devices Section
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 |
|---|---|---|---|
| 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 |
Example:
GRAPHICS = [
TYPE = "vnc",
LISTEN = "0.0.0.0",
PORT = "5"]
$VNC_BASE_PORT + $VMID, allowing to generate different ports for VMs so they do not collide. The VNC_BASE_PORT is specified inside theoned.conf file.Context Section
Context information is passed to the Virtual Machine via an ISO mounted as a partition. This information can be defined in the VM template in the optional section called Context, with the following attributes:
| Attribute | Description |
|---|---|
| VARIABLE | Variables that store values related to this virtual machine or others. The name of the variable is arbitrary (in the example, we use hostname). |
| FILES | space-separated list of paths to include in context device. |
| TARGET | device to attach the context ISO. |
The values referred to by VARIABLE can be defined :
- Hardcoded values:
HOSTNAME = "MAINHOST"
- Using template variables
$<template_variable>: any single value variable of the VM template, like for example:IP_GEN = "10.0.0.$VMID"
$<template_variable>[<attribute>]: Any single value contained in a multiple value variable in the VM template, like for example:IP_PRIVATE = $NIC[IP]
$<template_variable>[<attribute>, <attribute2>=<value2>]: Any single value contained in a multiple value variable in the VM template, setting one atribute to discern between multiple variables called the same way, like for example:IP_PUBLIC = "$NIC[IP, NETWORK=\"Public\"]"
- Using Virtual Network template variables
$NETWORK[<vnet_attribute>, NAME=<vnet_name>]: Any single value variable in the Virtual Network (vnet_name) template, like for example:DNS = "$NETWORK[DNS, NAME=\"Public\"]"
Example:
CONTEXT = [
HOSTNAME = "MAINHOST",
IP_PRIVATE = "$NIC[IP]",
DNS = "$NETWORK[DNS, NAME=\"Public\"]",
IP_GEN = "10.0.0.$VMID",
FILES = "/service/init.sh /service/certificates /service/service.conf",
TARGET = "sdc"
]
Placement Section
The following attributes placement constraints and preferences for the VM:
Note the hypervisor column states that the attribute is Optional, Mandatory, or - not supported for that hypervisor
| Attribute | Description | XEN | KVM |
|---|---|---|---|
| REQUIREMENTS | Boolean expression that rules out provisioning hosts from list of machines suitable to run this VM. | O | O |
| RANK | This field sets which attribute will be used to sort the suitable hosts for this VM. Basically, it defines which hosts are more suitable than others. | O | O |
Example:
REQUIREMENTS = "CPUSPEED > 1000"
RANK = FREECPU
Requirement Expression Syntax
The syntax of the requirement expressions is defined as:
stmt::= expr';'
expr::= VARIABLE '=' NUMBER
| VARIABLE '!=' NUMBER=' STRING
| VARIABLE '>' NUMBER
| VARIABLE '<' NUMBER
| VARIABLE '=' STRING
| VARIABLE '!
| expr '&' expr
| expr '|' expr
| '!' expr
| '(' expr ')'
Each expression is evaluated to 1 (TRUE) or 0 (FALSE). Only those hosts for which the requirement expression is evaluated to TRUE will be considered to run the VM.
Logical operators work as expected ( less '<', greater '>', '&' AND, '|' OR, '!' NOT), '=' means equals with numbers (floats and integers). When you use '=' operator with strings, it performs a shell wildcard pattern matching.
Any variable defined by the Information Manager driver can be used in the requirements. Check the configuration guide to find out how to extend the information model
There are some predefined variables that can be used: NAME, TOTALCPU, TOTALMEMORY, FREEMEMORY, FREECPU,USEDMEMORY, USEDCPU, HYPERVISOR
Examples:
REQUIREMENTS = "NAME = \"aquila*\"" #Only aquila nodes, note the quotes
REQUIREMENTS = FREECPU > 0.6 #Only those resources with more than 60% of free CPU
If using OpenNebula's default match-making scheduler in a hypervisor heterogeneous environment, it is a good idea to add an extra line like the following to the VM template to ensure its placement in a VMWare hypervisor enabled machine.
REQUIREMENTS = "HYPERVISOR=\"vmware\""
Template variables can be used in the REQUIREMENTS section.
$<template_variable>: any single value variable of the VM template.$<template_variable>[<attribute>]: Any single value contained in a multiple value variable in the VM template.$<template_variable>[<attribute>, <attribute2>=<value2>]: Any single value contained in a multiple value variable in the VM template, setting one atribute to discern between multiple variables called the same way.
For example, if you have a custom probe that generates a MACS attribute for the hosts, you can do short of a MAC pinning, so only VMs with a given MAC runs in a given host.
REQUIREMENTS = "MAC=\"$NIC[MAC]\""
Rank Expression Syntax
The syntax of the rank expressions is defined as:
stmt::= expr';'
expr::= VARIABLE
| NUMBER
| expr '+' expr
| expr '-' expr
| expr '*' expr
| expr '/' expr
| '-' expr
| '(' expr ')'
Rank expressions are evaluated using each host information. '+', '-', '*', '/' and '-' are arithmetic operators. The rank expression is calculated using floating point arithmetics, and then round to an integer value.
The rank expression is evaluated for each host, those hosts with a higher rank are used first to start the VM. The rank policy must be implemented by the scheduler. Check the configuration guide to configure the scheduler.
Similar to the requirements attribute, any number (integer or float) attribute defined for the host can be used in the rank attribute
Examples:
RANK = FREECPU # First those resources with a higher Free CPU
RANK = FREECPU * 100 - TEMPERATURE # Consider also the CPU temperature
RAW Section
This optional section of the VM template is used whenever the need to pass special attributes to the underlying hypervisor arises. Anything placed in the data attribute gets passed straight to the hypervisor, unmodified.
| RAW Sub-Attribute | Description | XEN | KVM |
|---|---|---|---|
| TYPE | Possible values are: kvm,xen |
O | O |
| DATA | Raw data to be passed directly to the hypervisor | O | O |
Example
RAW = [
TYPE = "xen",
DATA = "builder=\"linux\"
bootloader=\"/usr/lib/xen/boot/domUloader.py\"
bootargs=\"--entry=xvda2:/boot/vmlinuz-xenpae,/boot/vmlinuz-xenpae\""]
Virtual Machine Definition File 2.2的更多相关文章
- PatentTips - Safe general purpose virtual machine computing system
BACKGROUND OF THE INVENTION The present invention relates to virtual machine implementations, and in ...
- py, pyc, pyw, pyo, pyd Compiled Python File (.pyc) 和Java或.NET相比,Python的Virtual Machine距离真实机器的距离更远
https://my.oschina.net/renwofei423/blog/17404 1. PyCodeObject与Pyc文件 通常认为,Python是一种解释性的语言,但是这种说法 ...
- What is Java virtual machine?
Java Virtual Machine (JVM) is a specification that provides runtime environment in which java bytec ...
- [New Portal]Windows Azure Virtual Machine (23) 使用Storage Space,提高Virtual Machine磁盘的IOPS
<Windows Azure Platform 系列文章目录> 注意:如果使用Azure Virtual Machine,虚拟机所在的存储账号建议使用Local Redundant.不建议 ...
- Windows Azure Virtual Machine (31) 迁移Azure虚拟机
<Windows Azure Platform 系列文章目录> 为什么要写这篇Blog? 之前遇到过很多客户提问: (1)我之前创建的虚拟机,没有加入虚拟网络.现在需要重新加入虚拟机网络, ...
- [译] libvirt 虚机的生命周期 (Libvirt Virtual Machine Lifecycle)
翻译自:http://wiki.libvirt.org/page/VM_lifecycle 这篇文章描述虚机生命周期的基本概念.其目的在于在一篇文章中提供完整的关于虚机创建.运行.停止.迁移和删除 ...
- How to run a (Tomcat)Java application server on a Azure virtual machine
http://www.windowsazure.com/en-us/documentation/articles/virtual-machines-java-run-tomcat-applicatio ...
- config windows virtual machine on mac
1.download virtualbox and related extension pack from http://www.oracle.com/technetwork/server-stor ...
- 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the direc
原文转自:http://www.cnblogs.com/steararre/p/4037453.html 今天在机子上使用Eclipse时候打开发现这两个问题,通过查阅资料膜拜大神博客得知解决方法,特 ...
随机推荐
- Redis常见面试题总结
Redis面试题总结(1) 2018年02月28日 17:42:21 LSX丨笔头先生 阅读数:3568更多 个人分类: 面试题总结 (1)什么是redis? Redis 是一个基于内存的高性能k ...
- numpy 矩阵相关函数
我们 知道,矩阵在python里面用的不少,所以记载下关于矩阵的操作 numpy.zeros():可以用来构造全零矩阵 >>> zeros(3) array([ 0., 0., ...
- 一线互联网公司必备——最为详细的Docker入门吐血总结
在计算机技术日新月异的今天, Docker 在国内发展的如火如荼. 特别是在一线互联网公司 Docker 的使用是十分普遍的,甚至成为了一些企业面试的加分项,不信的话看看下面这张图. ...
- WPF简单模拟QQ登录背景动画(转)
介绍 之所以说是简单模拟,是因为我不知道QQ登录背景动画是怎么实现的.这里是通过一些办法把它简化了,做成了类似的效果 效果图 大体思路 首先把背景看成是一个4行8列的点的阵距,X轴Y轴都是距离70.把 ...
- [转]Mac上的抓包工具Charles
$*********************************************************************************************$ 博主推荐 ...
- 定时任务&&找出两个list的不同
/*-------------------------application-context.xml------------------------------*/ <?xml version= ...
- Nginx 教程示例
https://www.cnblogs.com/jingmoxukong/p/5945200.html
- (转)winform pictureBox后台显示图片
本文转载自:http://blog.csdn.net/meizhiyun/article/details/8639002 1.获取本地程序图片 方法一 pictureBox1.BackgroundIm ...
- 【转】Pro Android学习笔记(九八):BroadcastReceiver(2):接收器触发通知
文章转载只能用于非商业性质,且不能带有虚拟货币.积分.注册等附加条件.转载须注明出处:http://blog.sina.com.cn/flowingflying或作者@恺风Wei-傻瓜与非傻瓜 广播接 ...
- 【转】使用Badboy录制脚本,作为JMeter测试的素材
接触Badboy,是因为JMeter要引用Badboy导出的脚本 Badboy的录制提供两个模式:Request(默认模式) 和navigation模式.点击下图N,切换模式:但是要导出到Jmeter ...