Use our own len() function for network interfaces as doing
len(container.get_config_item("lxc.network")) will fail when the
list is empty.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
The new version of the pep8 command is detecting more indentation
mistakes than it used to, this fixes them.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This introduces a new add_devices() call to the python API.
Parameters:
- path => Mandatory, path to a character or block device on the host
- destpath => Optional, alternative path inside the container
The function will allow the node in the container's devices cgroup and
then create the entry in the container.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
The script used to contain a workaround for back when create()
wouldn't properly flush the config and reload it.
As these issues have now been fixed, these workarounds can be removed.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
When overriding wait(), I forgot to actually return the value coming
from the C binding...
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
At Serge's suggestion, always convert the state passed to the wait()
function in the python API to its uppercase equivalent.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This code was addeed to deal with stopped/dead containers but
really shouldn't be implemented there. Instead the setsid() call in
start() should be enough to prevent python from getting the SIGCHLD and
having to deal with it.
The liblxc API currently doesn't work as non-root, so check that the euid
is 0 when getting a Container instance in the python API.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Replaced python-lxc/test.py by a new api_test.py script that
uses all the available function of the API to run a batch of
basic tests.
This example is useful both as a test of the API and as a guide on
how to use the python API to manage containers.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
This adds a basic python binding done in C and a python overlay to
extend some features and provide a user-friendlier API.
This python API only supports python 3.x and was tested with >= 3.2.
It's disabled by default in configure and can be turned on by using
--enable-python.
A basic example of the API can be found in src/python-lxc/test.py.
More documentation and examples will be added soon.