Red Hat Enterprise Virtualization 3 (RHEV) comes with a great API that makes it easy to write Python scripts or Java programs for administrative tasks. The full documentation is available here : https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.3/html/Developer_Guide/index.html

A classical need is to automate the creation of virtual machine cold backups on an export domain. This can be easily done by using the Python API.

First you need to install the RHEV Software Development Kit :

$ yum install rhevm-sdk

You can now write a Python script using the ovirtsdk (RHEV SDK) :

#!/usr/bin/python

from ovirtsdk.api import API

Let’s declare a few constants :

RHEV_URL = "https://127.0.0.1"
RHEV_USERNAME = "admin@internal"
RHEV_PASSWORD = "ThePassword"

Then try to connect to RHEV :

api = API ( url=RHEV_URL,
username=RHEV_USERNAME,
password=RHEV_PASSWORD,
ca_file="/etc/pki/ovirt-engine/ca.pem")

print "Connected to %s successfully!" % api.get_product_info().name

We can display inform[…]

>> You can find the full post (free) on my company blog here: http://clevernetsystems.com/virtual-machines-backup-script-rhev-3/