Advanced integration with Red Hat Enterprise Virtualization Manager (RHEV-M) – Part 1 of 2

This is part 1 of a 2-part article about Advanced Integration with RHEV-M. 


At CloudOpen Europe 2013, in Edinburgh, I presented a talk about advanced integration with the oVirt engine. This technical article is covering the contents of this session.

RHEV-M is a Large scale, centralized management for server and desktop virtualization. It is based on leading performance, scalability and security infrastructure technologies, focusing on KVM for best integration/performance. It provides an alternative to Center/vSphere, providing end-to-end IaaS platform.


In this post I’ll show you how you can integrate with the RHEV-M engine, covering both new and cool features, as well as some “old” useful features.  Let’s start with the REST-based APIs. These APIs allow you to perform different operations on the engine externally. You can do anything using the REST APIs, even operations that aren’t exposed through the different UI interfaces.

REST-based APIs

We have several REST-based APIs in the RHEV-M engine:

  • REST API – provides application programming interface for the RHEV-M engine, using basic HTTP operations
  • SDKs (Python, Java) – based on the REST API – provides python based SDK to the RHEV-M engine
  • CLI (based on the Python SDK) – provides command line utility to the RHEV-M engine

So, what should you use?

That depends mostly on who you are, and what you are trying to accomplish:

  • If you’re a sysadmin running a virtualized environment, and you would like to troubleshoot some issues without going into the UI, then you should use the CLI.
  • If you’re a developer and you would like to integrate with the RHEV-M engine in your application, and your application is Java/Python based, then you should use the proper SDK.
  • If you’re a developer using other languages, then you should use the API, using some HTTP library available in your platform.
  • If you just want to automate some tasks, then you should use the Python SDK or the CLI, depending on your preferable scripting language.

Let’s dive a little deeper into the API and the SDK. I won’t cover the CLI in this post. For more information on that have a look at CLI Wiki page


The REST API provides application programming interface for the RHEV-M engine, using basic HTTP operations:

  • GET – Requests a resource
  • POST – Creates a new resource. The new resource data is included in the body of the request
  • PUT – Modifies an existing resource. The modified resource data is included in the body of the request
  • DELETE – Deletes a resource

The API URI structure is as follows:


For example, the following URL is a representation of the disk sub-resource with ID yyy-yyy in the VM resource with ID xxx-xxx, on our (secured) RHEV-M that’s installed on machine rhevm port 8443:


Some basic examples:

  1. To list all collection resources, use HTTP GET
    • GET http(s)://server:port/api/vms
  2. To retrieve a specific resource, use HTTP GET
    • GET http(s)://server:port/api/vms/{xxx}
    • curl -v -u “user@domain:password” -H “Content-type: application/xml” -X GET http(s)://server:port/api/vms/{xxx}
  3. To create a resource, use POST.
    • POST http(s)://server:port/api/vms
    • curl -v -u “user@domain:password”
      -H “Content-type: application/xml”
      </vm>’ ‘http(s)://server:port/api/vms’
  4. To update the resource, use PUT.
    • PUT http(s)://server:port/api/vms/{xxx}
    • echo “<vm><name>new_name</name></vm>” > /tmp/upload.xml
      curl -v -u “user@domain:password”
      -H “Content-type: application/xml”
      -T /tmp/upload.xml
  5. To remove the resource, use DELETE.
    • DELETE http(s)://server:port/api/vms/{xxx}
    • curl -v -u “user@domain:password” -X DELETE http(s)://server:port/api/vms/{xxx}

RSDL- RESTful Service Description Language

How do you know what arguments to use when doing different operations?

You can use the RSDL (RESTful Service Description Language) – machine and human readable XML description of HTTP-based web applications (typically REST web services). It models the resource/s provided by a service, the relationship between them, parameters that has to be supplied for the certain operation, specifies if parameter/s has to be mandated, and describes possible overloads as parameters sets.

RSDL is intended to simplify the reuse of web services that are based on the HTTP architecture of the Web. It is platform and language independent and aims to promote reuse of applications beyond the basic use in a web browser, by both humans and machines.

In order to get the RSDL, just follow the basic API URI, followed by “?rsdl”:

  • https://rhevm:8080/ovirt-engine/api?rsdl

And then you’ll get all the different options for each and every HTTP request you can do on each and every resource.

For example, here you see a partial list of available parameters when adding a new VM using HTTP POST on the VMs collection:



The Python-SDK is auto-generated software development kit for the RHEV-M engine API. Let’s show some examples on how to use it.

  1. First, you need to create a proxy to the API
    • api = API(url=’http://localhost:8080′, username=’user@domain’, password=’password’)
  2. Now, you can access the different collections, (api.vms(), api.clusters(), etc…)
  3. Create new resources, for example create a new VM:
    • cluster = api.clusters().get(name=’my_cluster’) #destination cluster

    • template = api.templates().get(name=’my_template’) #source template
    • param = params.VM(name=’new_vm’, cluster=cluster, template=template, memory=1073741824) #setting additional parameters

    • new_vm = api.vms().add(param) #creating the VM
  4. List resources by query (server side query)
    • vms = api.vms().list(query = ‘name=my_vm’)
  5. List resources by property constraint (client side filtering)
    • vms = api.vms().list(memory=1073741824)
  6. Get a resource by constraint
    • vm = api.vms().get(id=’f70d7c72-0232-4859-8fd7-fdaf1fd29d6d’)
  7. Access resource methods and properties
    • vm.start()
    • vm.start_time

Depending on your development environment, you’ll get auto-completion, and documentation that will ease the development process using the SDK.

In this part you learned how to perform different operations on the engine from the outside using the API/SDK. In the next part you’ll learn how you can influence the engine from the inside, using extension APIs.

Find Part 2 of this article here.

Join Red Hat Developers, a developer program for you to learn, share, and code faster – and get access to Red Hat software for your development.  The developer program and software are both free!


  1. I was interested in querying the RHEV-M engine, for which i came across oVirt SDK’s. Is this the right API, or there is an alternative? I came across some vague references of rhevm-api, but didn’t find any concrete documentation for it.

Leave a Reply