lundi 23 juillet 2012

Outside Boxes


Let's start this post with a quick presentation of oVirt (you'll understand why in a few paragraphs...).
oVirt is a free project providing management, monitoring and provisioning of KVM virtual machines on multiple hosts. It comes with a web interface to create and manage virtual machines, hypervisor nodes, storage, ... and with a user portal for those who just want to connect to an already existing virtual machine.
The way the user portal works is that you log into the portal from your browser, then you choose the virtual machine you want to connect to, and a browser plugin will take over and spawn an external binary (these days it's remote-viewer)
oVirt also comes with an extensive REST API which lets you do programmatically the same thing as you can do from oVirt web UIs. Moreover, it has an extensive documentation.

But what about GNOME?

And now we are finally coming as to why I'm talking about all of this :) Lately, I've been hacking on Boxes, and since one of its goals is to view, access, and use shared connection / machine, I've decided it would be fun to make it support oVirt connections! This would make it easier for Boxes users to connect to oVirt virtual machines without having to go through their browser.

librest already provides a good low-level GObject library to access REST services (though it was missing authentication support), so I used it to build a higher level library which wraps the oVirt REST accesses: libgovirt. This library uses GObject and gobject-introspection, which gives bindings to several other languages for free (including vala which is needed for Boxes). It also provides asynchronous methods for all its remote operations.
The library is still young and only implements the few REST operations I needed (list oVirt virtual machines, get VM connection details, generate temporary VM display password, ...), but this is enough for Boxes needs ;)

Once this library was in good shape, using it in Boxes was quite easy as the existing code was modular enough. All I had to do was to add a new URI type (ovirt://), and add a new Machine subclass to handle oVirt VMs, but most of the work is done by the libgovirt library.

This work is not yet merged upstream but can be seen in my personal git repository. After some small cleanups and a libgovirt release, it should be in good shape for an upstream review and integration. As for libgovirt, there is a lot of API to bind (help welcome!), but binding this new 3.1 API will be mandatory to be able to connect to all oVirt-managed VMs. One possible way forward for libgovirt would be to leverage the python oVirt REST binding generator from ovirt-engine-sdk.

And before ending this blog post, mandatory screenshots!

Authentication to an oVirt broker

Boxes from the oVirt broker