Table of Contents

Managing Virtual Machines 3.0

This guide follows the Creating Virtual Machines guide. Once a Template is instantiated to a Virtual Machine, there are a number of operations that can be performed using the onevm command.

inlinetoc

Sunstone

You can manage your virtual machines using the onevm command or Sunstone. In Sunstone, you can easily instantiate currently defined templates by clicking “New” on the Virtual Machines tab. A dialog will allow you to name the VM and choose the number of instances you want to create:

Virtual Machine Life-cycle

The life-cycle of a Virtual Machine within OpenNebula includes the following stages:

:!: Note that this is a simplified version. If you are a developer you may want to take a look at the complete diagram referenced in the xml-rpc api page):

Virtual Machine States

onevm Command

The following sections show the basics of the onevm command with simple usage examples. A complete reference for these commands can be found here.

This command enables Virtual Machine management. Actions offered are:

Assuming we have a VM Template registered called vm-example with ID 6, then we can instantiate the VM issuing a:

<xterm> $ onetemplate list

ID USER     GROUP    NAME                         REGTIME PUB
 6 oneadmin oneadmin vm_example            09/28 06:44:07  No

$ onetemplate instantiate vm-example –name my_vm VM ID: 0 </xterm>

afterwards, the VM can be listed with the onevm list command:

<xterm> $ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        pend   0      0K                 00 00:00:03

</xterm>

After a Scheduling cycle, the VM will be automatically deployed. But the deployment can also be forced by oneadmin using onevm deploy:

<xterm> $ onehost list

ID NAME               RVM   TCPU   FCPU   ACPU   TMEM   FMEM   AMEM   STAT
 2 testbed              0    800    800    800    16G    16G    16G     on

$ onevm deploy 0 2

$ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        runn   0      0K         testbed 00 00:02:40

</xterm>

and details about it can be obtained with show:

<xterm> $ onevm show 0 VIRTUAL MACHINE 0 INFORMATION ID : 0 NAME : my_vm USER : oneadmin GROUP : oneadmin STATE : ACTIVE LCM_STATE : RUNNING START TIME : 04/14 09:00:24 END TIME : - DEPLOY ID: : one-0

VIRTUAL MACHINE MONITORING NET_TX : 13.05 NET_RX : 0 USED MEMORY : 512 USED CPU : 0

VIRTUAL MACHINE TEMPLATE CONTEXT=[

FILES=/service/init.sh /service/certificates /service/service.conf,
TARGET=hdb ]

CPU=1 DISK=[

CLONE=YES,
DISK_ID=0,
IMAGE=Debian 6.0,
IMAGE_ID=3,
READONLY=NO,
SAVE=NO,
SOURCE=/home/cloud/opennebula/var/images/147f94ddb708851e71651f05caf81da0131cc904,
TARGET=hda,
TYPE=DISK ]

DISK=[

CLONE=YES,
DISK_ID=1,
IMAGE=Testing results
IMAGE_ID=5,
READONLY=NO,
SAVE=NO,
SOURCE=/home/cloud/opennebula/var/images/6478ab2b7f839538c6dc4d525ea0153387a91f1c,
TARGET=hde,
TYPE=DISK ]

DISK=[

DISK_ID=2,
READONLY=no,
SIZE=1024,
TARGET=hdd,
TYPE=swap ]

MEMORY=512 NAME=my_vm NIC=[

BRIDGE=vbr2,
IP=192.168.30.1,
MAC=02:00:c0:a8:1e:01,
NETWORK=Private lab 3,
NETWORK_ID=6 ]

OS=[

INITRD=/initrd.img,
KERNEL=/vmlinuz,
ROOT=sda ]

RANK=FREECPU REQUIREMENTS=CPUSPEED > 1000 VMID=0

VIRTUAL MACHINE HISTORY SEQ HOSTNAME REASON START TIME PTIME

 0         testbed   none  09/28 06:48:18 00 00:07:23 00 00:00:00

</xterm>

The following is a quick example of the onevm suspend and onevm stop commands. Using suspend, the VM state is left in the Host. So a resume action restores the VM in the same Host it was running before.

<xterm> $ onevm suspend 0 $ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        susp   0    512K         testbed 00 00:11:13

$ onevm resume 0 $ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        runn   0    512K         testbed 00 00:15:18

</xterm>

On the other hand, onevm stop saves the VM's status back to the front-end. After a resume action, the VM is set to pending, waiting for the Scheduler to deploy it.

<xterm> $ onevm stop 0 $ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        stop   0    512K         testbed 00 00:32:35

$ onevm list

  ID USER     GROUP    NAME         STAT CPU     MEM        HOSTNAME        TIME
   0 oneadmin oneadmin my_vm        pend   0    512K         testbed 00 00:33:46

</xterm>