LXC: Fix GetInstanceInfo()
authorBalazs Lecz <leczb@google.com>
Thu, 8 Jul 2010 17:45:48 +0000 (18:45 +0100)
committerBalazs Lecz <leczb@google.com>
Fri, 9 Jul 2010 15:17:34 +0000 (16:17 +0100)
Don't try to get cgroups info if instance is not running.

Signed-off-by: Balazs Lecz <leczb@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/hypervisor/hv_lxc.py

index 842965b..23a7974 100644 (file)
@@ -189,12 +189,11 @@ class LXCHypervisor(hv_base.BaseHypervisor):
     # 'ganeti-lxc-test1' is STOPPED
     # 'ganeti-lxc-test1' is RUNNING
     _, state = result.stdout.rsplit(None, 1)
+    if state != "RUNNING":
+      return None
 
     cpu_list = self._GetCgroupCpuList(instance_name)
-
-    if state == "RUNNING":
-      return (instance_name, 0, 0, len(cpu_list), 0, 0)
-    return None
+    return (instance_name, 0, 0, len(cpu_list), 0, 0)
 
   def GetAllInstancesInfo(self):
     """Get properties of all instances.