I use the lxc module for python and i need the python command to check up the current container state. Or i need a boolean command to check whether the container is current running.
Asked
Active
Viewed 965 times
2 Answers
1
I found the solution at self. It's possible to use the command wait to get a check for the current container state.
import lxc
container = lxc.Container("Test")
container.start()
if container.wait("RUNNING", timeout=5)
container.stop()
container.destroy()
This Command returns a true if it reach the state within the timeout. In other cases returns a false. And so we can make a check for the current container state with the standard library!
![](../../users/profiles/1032670.webp)
Smeagol86
- 15
- 1
- 9
0
Working with lxc (python3-lxc) version 1.0.3 I use
import lxc
container = lxc.Container("Test")
container.defined
True
to check if the container exists (in /var/lib/lxc) and
container.running
True
to see if the container runs.
![](../../users/profiles/1387558.webp)
tssch
- 694
- 8
- 23