OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

6.15. LXC API


Most of the LXC functionality can now be accessed through an API exported by liblxc for which bindings are available in several languages, including Python, lua, ruby, and go.


Below is an example using the python bindings (which are available in the python3-lxc package) which creates and starts a container, then waits until it has been shut down:


# sudo python3

Python 3.2.3 (default, Aug 28 2012, 08:26:03)

[GCC 4.7.1 20120814 (prerelease)] on linux2

Type "help", "copyright", "credits" or "license" for more information.



>>> import lxc

__main__:1: Warning: The python-lxc API isn't yet stable and may change at any p oint in the future.

>>> c=lxc.Container("C1")

>>> c.create("ubuntu") True

>>> c.start() True

>>> c.wait("STOPPED")

True


Top OS Cloud Computing at OnWorks: