OpenNebula OpenNebula


Interaction with OpenNebula is done via the Ruby OpenNebula Cloud API.

Note: This provider is under construction! This means everything that is provided should work without problems, but there are many features not available yet. Please contribute!


  • See gemspec for ruby and gem versions
  • User credentials for an XMLRPC endpoint of an OpenNebula instance


Build the gem from source code

 cd fog-opennebula
 gem build fog-opennebula.gemspec
 version=$(ruby -e 'require "./lib/fog/opennebula/version"; puts Fog::OpenNebula::VERSION')
 gem install fog-opennebula-"$version".gem

Install from rubygems

 gem install fog-opennebula


General proceeding:

  • connect to OpenNebula xml-rpc
  • create new vm object
  • fetch a template/flavor from OpenNebula (this template should be predefined)
  • assign the flavor/template to the vm
  • change the attributes of this flavor/template (name, cpu, memory, nics....)
  • save/instantiate the vm
require 'fog/opennebula'

con =
  provider: 'OpenNebula',
  opennebula_username: 'oneadmin',
  opennebula_password: 'password',
  opennebula_endpoint: 'http://localhost:2633/RPC2'

# list all vms

# list all OpenNebula templates

# get template with id 0
con.flavors.get 0

# list all Virtual Networks
con.networks.get 0

# get all usergroups

# create a new vm object (creates the object, the vm is not instantiated yet)
newvm =

# set the flavor of the vm
newvm.flavor = con.flavors.get 0

# set the name of the vm = "FooBarVM"

# set the groupid of the vm
newvm.gid = 0

# set cores and memory (MB)
newvm.flavor.vcpu = 2
newvm.flavor.memory = 256

# create a new network interface attached to the network with id 0 and virtio as driver/model
network = con.networks.get(0)
nic ={ :vnet => network, :model => "virtio"})

# Attach the new nic to our vm
newvm.flavor.nic = [ nic ]

# instantiate the new vm

Additional Resources