Go OpenNebula Cloud API

This page contains the OpenNebula Cloud API Specification for Go. 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.

Go OpenNebula Cloud API cover the resources lists below:

Resource URL
ACL acl.go
Cluster cluster.go
Datastore datastore.go
Document document.go
Group group.go
Host host.go
Hook hook.go
Image image.go
Market Place marketplace.go
Market Place App marketplaceapp.go
Template template.go
Security Group securitygroup.go
User user.go
VDC vdc.go
Vnet virtualnetwork.go
Vrouter virtualrouter.go
VMs vm.go
VM Groups | vmgroup.go
VN template | vntemplate.go
Zone zone.go


The source code can be downloaded from the OpenNebula repository.


To use the OpenNebula Cloud API for Go in your Go project, you have to import goca at your project as the example below and make a go get.

Code Sample

The example below show how get the information of a running VM, print its name, and power it off. It then builds a new OpenNebula template and prints its string representation.

package main

import (


func main() {
    conf := goca.NewConfig("user", "password_or_token", "endpoint")

    client := goca.NewDefaultClient(conf)
    controller := goca.NewController(client)

    id, _ := strconv.Atoi(os.Args[1])

    vm, err := controller.VM(uint(id)).Info()
    if err != nil {


    // Poweroff the VM
    err = vm.PoweroffHard()
    if err != nil {

    // Create a new Template
    tpl := vm.NewTemplate()

    disk := tpl.AddDisk()
    disk.Add(shared.ImageID, "119")
    disk.Add(shared.DevPrefix, "vd")

    nic := tpl.AddNIC()
    nic.Add(shared.NetworkID, "3")
    nic.Add(shared.Model, "virtio")


To see more, take at these examples.

Error handling

In the file errors.go, two errors types are defined: - ClientError: errors on client side implying that we can’t have a complete and well formed OpenNebula response (request building, network errors ...). - ResponseError: We have a well formed response, but there is an OpenNebula error (resource does not exists, can’t perform the action, rights problems ...).

Each of theses types has several error codes allowing you fine grained error handling. If we have an HTTP response, ClientError returns it.

Extend the client

The provided client is a basic XML-RPC client for OpenNebula, without any complex features. It’s possible to use an other client or enhance the basic client with Goca if it implements the RPCCaller interface.