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 install python-libvirt debootstrap root@ubuntu:~# service libvirt-bin start
On CentOS, the library and the service are named differently:
[root@centos ~]# yum install libvirt libvirt-python debootstrap [root@centos ~]# service libvirtd start
Since...