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 = Fog::Compute.new(
provider: 'OpenNebula',
opennebula_username: 'oneadmin',
opennebula_password: 'password',
opennebula_endpoint: 'http://localhost:2633/RPC2'
)
# list all vms
con.servers
# list all OpenNebula templates
con.flavors
# get template with id 0
con.flavors.get 0
# list all Virtual Networks
con.networks
con.networks.get 0
# get all usergroups
con.groups
# create a new vm object (creates the object, the vm is not instantiated yet)
newvm = con.servers.new
# set the flavor of the vm
newvm.flavor = con.flavors.get 0
# set the name of the vm
newvm.name = "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 = con.interfaces.new({ :vnet => network, :model => "virtio"})
# Attach the new nic to our vm
newvm.flavor.nic = [ nic ]
# instantiate the new vm
newvm.save