mirror of
git://github.com/lxc/lxc
synced 2025-09-05 02:49:35 +00:00
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.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
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)
|