Skip to content
A Ruby OCCI Framework
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

rOCCI - A Ruby OCCI Framework

Build Status


The following setup is recommended

  • usage of the Ruby Version Manger
  • Ruby 1.9.3
  • RubyGems installed


gem install occi


Use the Interactive Ruby Shell (IRB) to interact with an OCCI server. If you have the occi gem installed, you just have to start irb from the command line:


If you want to test newer versions of rOCCI, you have to tell irb from where it should load occi:

cd rOCCI
irb -I lib

First require the gem, for Ruby 1.8.7 you also have to require rubygems

require 'rubygems'
require 'occi'


The OCCI gem includes a Client to simplify the usage of an OCCI endpoint. If you want to use authentication then you should create a hash with information either on username and password for basic authentication or with a X.509 user certificate, the user certificate password and the path to the Root CAs which are used to verify the certificate of the OCCI server.

For Basic auth use

auth =
auth.type = 'basic'
auth.username = 'user'
auth.password = 'mypass'

For Digest auth use

auth =
auth.type = 'digest'
auth.username = 'user'
auth.password = 'mypass'

For X.509 auth use

auth =
auth.type = 'x509'
auth.user_cert = '/Path/To/My/usercert.pem'
auth.user_cert_password = 'MyPassword'
auth.ca_path = '/Path/To/root-certificates'

To connect to an OCCI endpoint/server (e.g. running on http://localhost:3000/ )

client ='',auth||=nil)

All available categories are automatically registered to the OCCI model during client initialization. You can get them via


To get all resources (as a list of OCCI::Resources) currently managed by the endpoint use

client.get resources

To get only compute, storage or network resources use get_compute_resources, ...

To get the location of all resources use

client.list resources

Analogue for compute, storage, network.

To get a list of all OS / resource templates use


To create a new compute resource use

os = { |template| template.term.include? 'my_os' }
size = { |template| template.term.include? 'large' }
cmpt = compute
cmpt.mixins << os << size
cmpt.attributes.occi!.core!.title = "My VM"
client.create cmpt


The OCCI gem includes its own logging mechanism using a message queue. By default, no one is listening to that queue. A new OCCI Logger can be initialized by specifying the log destination (either a filename or an IO object like STDOUT) and the log level.,OCCI::Log::INFO)

You can create multiple Loggers to receive the log output.

You can always, even if there is no logger defined, log output using the class methods of OCCI::Log e.g."Test message")

Registering categories in the OCCI Model

Before the parser may be used, the available categories have to be registered in the OCCI Model.

For categories already specified by the OCCI WG a method exists in the OCCI Model class to register them:

model =

Further categories can either be registered from files which include OCCI collections in JSON formator or from parsed JSON objects (e.g. from the query interface of an OCCI service endpoint).

Parsing OCCI messages

The OCCI gem includes a Parser to easily parse OCCI messages. With a given media type (e.g. json, xml or plain text) the parser analyses the content of the message body and, if supplied, the message header. As the text/plain and text/occi media type do not clearly distinguish between a message with a category and a message with an entity which has a kind, it has to be specified if the message contains a category (e .g. for user defined mixins)

OCCI messages can be parsed to an OCCI collection for example like

media_type = text/plain
body = %Q|Category: compute; scheme=""; class="kind"|
collection=OCCI::Parser.parse(media_type, body)

Parsing OVF / OVA files

Parsing of OVF/OVA files is partly supported and will be improved in future versions.

The example in DMTF DSP 2021 is bundled with rOCCI and can be parsed to an OCCI collection with

require 'open-uri'
ova=open ''

Currently only the following entries of OVF files are parsed

  • File in References
  • Disk in the DiskSection
  • Network in the NetworkSection
  • in the VirutalSystemSection: ** Info ** in the VirtualHardwareSection the items regarding *** Processor *** Memory *** Ethernet Adapter *** Parallel port

Using the OCCI model

The OCCI gem includes all OCCI Core classes necessary to handly arbitrary OCCI objects.


version 2.5

  • improved OCCI Client
  • improved documentation
  • several bugfixes

Version 2.4

  • Changed OCCI attribute properties from lowercase to first letter uppercase (e.g. type -> Type, default -> Default, ...)

Version 2.3

  • OCCI objects are now initialized with a list of attributes instead of a hash. Thus it is easier to check which attributes are expected by a class and helps prevent errors.
  • Parsing of a subset of the OVF specification is supported. Further parts of the specification will be covered in future versions of rOCCI.

Version 2.2

  • OCCI Client added. The client simplifies the execution of OCCI commands and provides shortcuts for often used steps.

Version 2.1

  • Several improvements to the gem structure and code documentation. First rSpec test were added. Readme has been extended to include instructions how the gem can be used.

Version 2.0

  • Starting with version 2.0 Florian Feldhaus and Piotr Kasprzak took over the development of the OCCI gem. The codebase was taken from the rOCCI framework and improved to be bundled as a standalone gem.

Version 1.X

  • Version 1.X of the OCCI gem has been developed by retr0h and served as a simple way to access the first OpenNebula OCCI implementation.


Checkout latest version from GIT:

git clone git://

Change to rOCCI folder

cd rOCCI

Install dependencies for deployment

bundle install --deployment

Code Documentation

Code Documentation for rOCCI by YARD

Continuous integration

Continuous integration for rOCCI by Travis-CI


  1. Fork it.
  2. Create a branch (git checkout -b my_markup)
  3. Commit your changes (git commit -am "My changes")
  4. Push to the branch (git push origin my_markup)
  5. Create an Issue with a link to your branch
Something went wrong with that request. Please try again.