PyONE: OpenNebula Python Bindings

PyONE is an implementation of OpenNebula XML-RPC bindings in Python. It has been designed as a wrapper for the XML-RPC methods, with some basic helpers. This means that you should be familiar with the XML-RPC API and the XML formats returned by the OpenNebula core. As stated in the XML-RPC documentation, you can download the XML Schemas (XSD) here.

API Documentation

As long as the code is generated, the main source of the documentation is still the XML-RPC doc

Download and installation

You can either use the system package python3-pyone or install it using pip install pyone.


You need to configure your XML-RPC Server endpoint and credentials when instantiate the OneServer class:

import pyone
one = pyone.OneServer("http://one:2633/RPC2", session="oneadmin:onepass")

If you are connecting to a test platform with a self signed certificate you can disable certificate verification as:

import pyone
import ssl
one = pyone.OneServer("https://one:8443/RPC2", session="oneadmin:onepass", https_verify=False)

It is also possible to modify the default connection timeout, but note that the setting will modify the TCP socket default timeout of your Python VM, ensure that the chosen timeout is suitable to any other connections running in your project.

Making Calls

Calls match the API documentation provided by OpenNebula, so for example to XML api call corresponds following code:

import pyone

one = pyone.OneServer("http://one:2633/RPC2", session="oneadmin:onepass" )
hostpool =
host = hostpool.HOST[0]
id = host.ID

Note that the session parameter is automatically included as well as the “one.” prefix to the method.

Returned Objects

The returned types have been generated with generateDS and closely match the XSD specification. You can use the XSD specification and XML-RPC as primary documentation.

marketpool =
m0 = marketpool.MARKETPLACE[0]
print "Marketplace name is " + m0.NAME

Structured Parameters

When making calls, the library will translate flat dictionaries into attribute=value vectors. Such as:,  {"LABELS": "HD"}, 1)

When the provided dictionary has a “root” dictionary, it is considered to be root element and it will be translated to XML:

    'TEMPLATE': {
      'NAME': 'abc',
      'MEMORY': '1024',
      'ATT1': 'value1'
  }, 1)

When, there are multiple entries with the same key like DISK or NIC, you can use array (from the version 6.8+).

    'TEMPLATE': {
      'NAME': 'test100',
      'MEMORY': '1024',
      'DISK': [
        { 'IMAGE_ID': 1 },
        { 'IMAGE_ID': 2 },
  }, 1)

In any case, it’s always possible to pass the template directly in OpenNebula format:

     DISK=[ IMAGE_ID= "1" ]
     DISK=[ IMAGE_ID= "2" ]

generateDS creates members from most returned parameters, however, some elements in the XSD are marked as anyType and generateDS cannot generate members automatically, TEMPLATE and USER_TEMPLATE are the common ones. Pyone will allow accessing its contents as a plain python dictionary.

host =
arch = host.TEMPLATE['ARCH']

This makes it possible to read a TEMPLATE as dictionary, modify it and use it as parameter for an update method, as following:

host =
host.TEMPLATE['NOTES']="Just updated",host.TEMPLATE,1)


Some methods will return encoded values such as those representing the STATE of a resource. Constants are provided to better handle those.

  # action that assumes app ready

More examples

import pyone
one = pyone.OneServer("http://one:2633/RPC2", session="oneadmin:onepass" )

Allocate localhost as new host'localhost', 'kvm', 'kvm', 0)

See host template

host =[0]

See VM template

vm_template =, -1, -1).VMTEMPLATE[0]

Instantiate it

one.template.instantiate(0, "my_VM")

See it

my_vm =,-1,-1,-1).VM[0]

Terminate it

one.vm.action('terminate', 0)


Python bindings were ported to upstream from stand-alone PyONE addon made by Rafael del Valle PyONE.