diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py index c7c6f24a1fa6cfc23c4c5c48a390266494a5f83f..683bc38200fe9df866ff8f4a89b3bb71b2192a1e 100644 --- a/lib/hypervisor/hv_lxc.py +++ b/lib/hypervisor/hv_lxc.py @@ -142,7 +142,17 @@ class LXCHypervisor(hv_base.BaseHypervisor): """ # TODO: read container info from the cgroup mountpoint - return (instance_name, 0, 0, 0, 0, 0) + + result = utils.RunCmd(["lxc-info", "-n", instance_name]) + if result.failed: + raise errors.HypervisorError("Can't run lxc-info: %s" % result.output) + # lxc-info output examples: + # 'ganeti-lxc-test1' is STOPPED + # 'ganeti-lxc-test1' is RUNNING + _, state = result.stdout.rsplit(None, 1) + if state == "RUNNING": + return (instance_name, 0, 0, 0, 0, 0) + return None def GetAllInstancesInfo(self): """Get properties of all instances.