Collection of OpenNebula CLI scripts that improve the user experience in the shell.
Ruby Shell
Switch branches/tags
Nothing to show
Clone or download
jmelis Merge pull request #8 from vholer/master
Support nowait on datastore
Latest commit ce26f93 Jan 2, 2018

OpenNebula CLI Tools

This a collection of scripts useful for OpenNebula administrators. Their aim is to improve the user experience in the shell with simple, short and elegant scripts that use the power and simplicity of OpenNebula's CLI commands.

Contributions, hacks, ideas, improvements are more than welcome!


  • onelog: Displays OpenNebula logs.
  • oneinstantiate: Instantiates template with a name.
  • onedeploy: Creates and deploys instantaneously a Virtual Machine.
  • onereport: Displays a summary of running VMs.
  • onessh: SSH's into a running VM.
  • onessh-copy-id: Copies public key to a running VM.
  • onevnc: Opens the VNC console of a running VM.
  • oneirb: Opens an IRB session with all the OpenNebula libraries.
  • oneconf: Modifies the default configuration files.
  • onebootstrap: Creates initial OpenNebula resources.
  • onecast: OpenNebula templates with variables.
  • oneip: Returns the IP of a VM.
  • oneping: Pings a VM.


If no argument is passed it displays oned.log. One of these arguments can be passed:

  • econe: econe-server.log
  • econe.error: econe-server.error
  • occi: occi-server.log
  • occi.error: occi-server.error
  • sunstone: sunstone-server.log
  • sunstone.error: sunstone-server.error
  • ozones: ozones-server.log
  • ozones.error: ozones-server.error
  • VM_ID: the vm.log is displayed


$ onelog
[ opens oned.log in your $PAGER ]
$ onelog 10
[ opens the vm.log for VM 10 in your $PAGER ]


A wrapper for the onetemplate instantiate command. It instantiates a template using the name of the template as the Virtual Machine name:

$ oneinstantiate 0
onetemplate instantiate 0 -n ubuntu
VM ID: 11


Creates a Virtual Machine and deploys it instantaneously in the first available host it founds:

$ onedeploy


Displays a summary of running Virtual Machines:

$ onereport
VM: 9
NAME: one-9
HOSTNAME: localhost
VNC PORT: 5909

VM: 10
NAME: ttylinux
HOSTNAME: localhost


SSH's into a running VM:

$ onessh 9 -l root


Copies the public key to a running VM identified by ID or by name. If a second parameter is passed to the script, it will be used as the username.

# To the same username
$ onessh-copy-id 9
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
user@'s password:

# To a different username
$ onessh-copy-id 9 root
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
root@'s password:


Opens the VNC console of a running VM:

$ onevnc 9


Enters an irb environment with all the OpenNebula libraries loaded. The instance variable @client is available in the IRB shell.

$ oneirb
>> vm ='10'), @client);
?> vm['NAME']
=> "ttylinux"


This ruby script backs up and rewrites oned.conf and sched.conf, performing the following changes:


  • MANAGER_TIMER: 5 seconds
  • VM_POLLING_INTERVAL: 10 seconds
  • Enables TM_SSH
  • Enables TM_DUMMY
  • Enables IM_DUMMY
  • Enables VMM_DUMMY


  • SCHED_INTERVAL: 5 seconds


This command should be executed only with a fresh OpenNebula installation. It will create some resources:

  • host: localhost with KVM configuration
  • datastore: a file-system based user datastore
  • users: Any users in the folder. If default.user exists, the following resources will be created inder his name.
  • vnet: a few IPs in the network connected to bridge br0
  • image: an Ubuntu image (users will have to execute first bootstrap/image/
  • template: an Ubuntu template ready to be instantiated

By default the command will look in the bootstrap/ directory. However, a different path may be provided as an argument.

All of these resources can be customized by editing the files inside bootstrap/. Other resources can be added and they will also be created.

The datastore where the images will be instantiated needs to have DEFAULT = YES inside the template. This is only necessary if more than one datastore is created.


This tool that can rewrite parts of a VM template substituting the variables it contains by some values that the user provides. It also gets values from the environment if the values are not explicitly provided by the user and can also have a default value so they will be translated to something meaningful if not found by other methods.

An example of a VM template meaningful to onecast can be this one:

NAME    = "${NAME}"
CPU     = ${CPU|1.0}
VCPU    = ${CPU|1}
DISK    = [
    SOURCE  = "${HOME}/images/vm.img",
    TARGET  = sda

In this example we can see that the placeholder for the variable values is specified with ${VARIABLE}. The name of the variable is case sensitive and this will be translated to its value (user provided or from the environment) or left blank if not found. We have to be careful with variables not set or they will render the template unusable in some cases. To overcome this problem, and also to give some values that the user may not want to modify, default values can be provided alongside the variable name. Variable names with default values are specified with ${VARIABLE|default value}. Doing so if the variable is not set by the user in the command line or found in the environment it will be substituted by the default value.

It is also very useful to use environment variables to get some information specific to the user, in this example we suppose every user has a file called images/vm.img in their home directory so we use $HOME environment variable to point to it.

To generate the final template we use the this command:

$ onecast -d NAME="test vm"
NAME    = "test vm"
CPU     = 1.0
VCPU    = 1
MEMORY  = 512
DISK    = [
    SOURCE  = "/home/oneuser/images/vm.img",
    TARGET  = sda

We have to specify the template file to the onecast script and we can also provide variables using -d option. This option will have an argument in this form NAME=value that will be used to substitute any variable in the template with that name. More than one of those variables can be added in the command line. As another example to illustrate this we can also set the memory to 1Gb issuing this command:

$ onecast -d NAME="test vm" -d MEMORY=1024
NAME    = "test vm"
CPU     = 1.0
VCPU    = 1
MEMORY  = 1024
DISK    = [
    SOURCE  = "/home/oneuser/images/vm.img",
    TARGET  = sda

The output of the command can then be redirected to a file and use it to create a new VM or use the parameter -c so the VM is automatically sent to OpenNebula:

$ onecast -d NAME="test vm" -d MEMORY=1024 -c
ID: 9


Pings a VM:

$ oneping 9


Returns the ip of a VM:

$ oneping 9

Useful for things like:

$ scp myfile root@`oneip 0`: