Change GetInstanceInfo to use _IsInstanceAlive instead of calling
lxc-info for instance name.
Behavior of lxc-info for not existing container is changed in LXC 1.0.0
and also it is not accurate to use lxc-info for instance existence.

Signed-off-by: Yuto KAWAMURA(kawamuray) <[email protected]>
---
 lib/hypervisor/hv_lxc.py | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 9729f3f..4d358c0 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -253,15 +253,7 @@ class LXCHypervisor(hv_base.BaseHypervisor):
     """
     # TODO: read container info from the cgroup mountpoint
 
-    result = utils.RunCmd(["lxc-info", "-s", "-n", instance_name])
-    if result.failed:
-      raise errors.HypervisorError("Running lxc-info failed: %s" %
-                                   result.output)
-    # lxc-info output examples:
-    # 'state: STOPPED
-    # 'state: RUNNING
-    _, state = result.stdout.rsplit(None, 1)
-    if state != "RUNNING":
+    if not self._IsInstanceAlive(instance_name):
       return None
 
     cpu_list = self._GetCgroupCpuList(instance_name)
-- 
1.8.5.5

Reply via email to