From b8aa46eda8e8a49b43b3f6ae550b8aa3973f23c5 Mon Sep 17 00:00:00 2001
From: Balazs Lecz <leczb@google.com>
Date: Thu, 8 Jul 2010 18:45:48 +0100
Subject: [PATCH] LXC: Fix GetInstanceInfo()

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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lib/hypervisor/hv_lxc.py b/lib/hypervisor/hv_lxc.py
index 842965b4a..23a79746e 100644
--- a/lib/hypervisor/hv_lxc.py
+++ b/lib/hypervisor/hv_lxc.py
@@ -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.
-- 
GitLab