2
0
mirror of git://github.com/lxc/lxc synced 2025-09-05 08:39:53 +00:00

Add python-lxc based on the new liblxc API.

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.
This commit is contained in:
Stéphane Graber
2012-08-27 19:04:43 -04:00
parent 7a44c8b447
commit be2e4e54da
7 changed files with 1023 additions and 1 deletions

28
src/python-lxc/test.py Normal file
View File

@@ -0,0 +1,28 @@
import lxc
t1 = lxc.Container("test")
print("Name set properly: %s" % (t1.name == "test"))
print("Test config loaded properly: %s" % t1.load_config("/etc/lxc/lxc.conf"))
print("Real config loaded properly: %s" % t1.load_config())
print("Test config path: %s" % (t1.config_file_name == "/var/lib/lxc/test/config"))
print("Set config item: %s" % t1.set_config_item("lxc.utsname", "blabla"))
print("Container defined: %s" % (t1.defined))
print("Started properly: %s" % t1.start())
print("Container running: %s" % t1.wait("RUNNING"))
print("Container state: %s" % t1.state)
print("Container running: %s" % t1.running)
print("Container init process: %s" % t1.init_pid)
print("Freezing: %s" % t1.freeze())
print("Container frozen: %s" % t1.wait("FROZEN"))
print("Container state: %s" % t1.state)
print("Unfreezing: %s" % t1.unfreeze())
print("Container running: %s" % t1.wait("RUNNING"))
print("Container state: %s" % t1.state)
print("Stopped properly: %s" % t1.stop())
print("Container state: %s" % t1.state)
#print("Started properly: %s" % t1.start(useinit=True))
#print("Container running: %s" % t1.wait("RUNNING"))
#print("Container state: %s" % t1.state)
#print("Stopped properly: %s" % t1.stop())
#print("Container state: %s" % t1.state)