Libvirt Python bindings

In Chapter 3, Command-Line Operations Using Native and Libvirt Tools, we explored an alternative way of working with LXC through the use of the libvirt userspace tools. Libvirt provides Python bindings that we can use to write applications, with the main benefit of uniformity with other virtualization technologies. It's quite convenient to write Python applications for KVM, XEN, and LXC using just one common library.

In this section, we are going to explore some of the Python methods provided by the libvirt library to create and control LXC containers.

Installing the libvirt Python development packages

Let's start by installing the required packages and starting the service.

On Ubuntu, run the following:

root@ubuntu:~# apt-get ...

Get Containerization with LXC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.