LXC Python bindings
LXC comes with stable C API and Python bindings for both Python 2.x and 3.x versions. Let's explore some of the functionalities that are available to us using Python 2.7.6, by writing a code that will cover most of the features provided by the userspace tools we saw in earlier chapters.
Installing the LXC Python bindings and preparing the development environment on Ubuntu and CentOS
Let's start by installing all the necessary packages that will allow us to write a functioning Python code. This includes the LXC API libraries and a Python development environment with ipython
and virtualenv
.
- To prepare an Ubuntu host, run the following commands:
root@ubuntu:~# apt-get update && apt-get upgrade && reboot root@ubuntu:~# apt-get install python-pip python-dev ipython root@ubuntu:~# apt-get install lxc-dev=2.0.3-0ubuntu1~ubuntu14.04.1 liblxc1=2.0.3-0ubuntu1~ubuntu14.04.1 cgroup-lite=1.11~ubuntu14.04.2 root@ubuntu:~# apt-get install lxc-templates=2...