there is a CLI for that already, like the ouput of "onevm list"
If you use opennebula to manage or deploy VMs, I’d move away from using virsh and start using one cli. As far as I know, VMs are numbered by opennebula and naming them is set with a different attribute in the opennebula database (mysql or sqlite). This way, you can manage them from the web interface or the opennebula CLI. If you manage VMs using virsh, the database will not get updated, so things will prob. go berserk.
@Anyone, please correct me if I’m wrong, this is based on my adventures so far
Here is the documentation for CLI:
http://docs.opennebula.org/5.0/operation/references/cli.html
And here is the “onevm” info:
NAME
onevm - manages OpenNebula virtual machines
SYNOPSIS
onevm command [args] [options]
OPTIONS
-m, --multiple x Instance multiple VMs
--hold Creates the new VM on hold state instead of
pending
--name name Name for the new VM
--cpu cpu CPU percentage reserved for the VM (1=100% one
CPU)
--vcpu vcpu Number of virtualized CPUs
--arch arch Architecture of the VM, e.g.: i386 or x86_64
--memory memory Memory amount given to the VM. By default the
unit is megabytes. To use gigabytes add a 'g',
floats can be used: 8g=8192, 0.5g=512
--disk image0,image1 Disks to attach. To use an image owned by other
user use user[disk]. Add any additional
attributes separated by ':' and in the shape of
KEY=VALUE. For example, if the disk must be
resized, use image0:size=1000 . Or
image0:size=1000:target=vda,image1:target=vdb
--nic network0,network1 Networks to attach. To use a network owned by
other user use user[network]. Additional
attributes are supported like with the --disk
option.
--raw string Raw string to add to the template. Not to be
confused with the RAW attribute
--vnc Add VNC server to the VM
--vnc-password password VNC password
--vnc-listen ip VNC IP where to listen for connections. By
default is 0.0.0.0 (all interfaces).
--vnc-keymap keymap VNC keyboard layout
--spice Add spice server to the VM
--spice-password password spice password
--spice-listen ip spice IP where to listen for connections. By
default is 0.0.0.0 (all interfaces).
--spice-keymap keymap spice keyboard layout
--ssh [file] Add an ssh public key to the context. If the file
is omited then the user variable SSH_PUBLIC_KEY
will be used.
--net_context Add network contextualization parameters
--context line1,line2,line3 Lines to add to the context section
--boot device_list Set boot device list e.g. disk0,disk2,nic0
--files_ds file1,file2 Add files to the contextualization CD from
thefiles datastore
--init script1,script2 Script or scripts to start in context
--startscript [file] Start script to be executed
--report_ready Sends READY=YES to OneGate, useful for OneFlow
--dry Just print the template
-a, --append Append new attributes to the current template
--schedule TIME Schedules this action to be executed afterthe
given time. For example: onevm resume 0
--schedule "09/23 14:15"
-t, --type type Type of the new Image
-s, --snapshot snapshot ID of the Snapshot to save.
--hard Does not communicate with the guest OS
-e, --enforce Enforce that the host capacity is not exceeded
--live Do the action with the VM running
--success Recover a VM by succeeding the pending action
--failure Recover a VM by failing the pending action
--retry Recover a VM by retrying the last failed action
--interactive Enables interactive recovery. Only works
alongside the --retry option.
--delete No recover action possible, delete the VM
--recreate No recover action possible, delete and recreate
the VM
-f, --file file Selects the template file
-i, --image id|name Selects the image
-t, --target target Device where the image will be attached
--cache cache_mode Hypervisor cache mode: default, none,
writethrough, writeback, directsync or unsafe.
(Only KVM driver)
--discard discard_mode Hypervisor discard mode: ignore or unmap. (Only
KVM driver)
--prefix prefix Overrides the DEV_PREFIX of the image
-n, --network id|name Selects the virtual network
-i, --ip ip IP address for the new NIC
-l, --list x,y,z Selects columns to display with list command
-d, --delay x Sets the delay in seconds for top command
-f, --filter x,y,z Filter data. An array is specified with
column=value pairs.
--csv Write table in csv format
-x, --xml Show the resource in xml format
-n, --numeric Do not translate user and group IDs
-k, --kilobytes Show units in kilobytes
--describe Describe list columns
--all Show all template data
--persistent Make the new images persistent
-v, --verbose Verbose mode
-h, --help Show this message
-V, --version Show version and copyright information
--user name User name used to connect to OpenNebula
--password password Password to authenticate with OpenNebula
--endpoint endpoint URL of OpenNebula xmlrpc frontend