[Kimchi-devel] [PATCH V2] Update host number of cpus and total physical memory

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Mon Mar 23 14:28:01 UTC 2015


 - The number of cpus and the total physical memory information
   displayed in the host section can change, so them cannot be
   static. This commit updates those values whenever a GET request
   hits the backend looking for host information.
---
 src/kimchi/model/host.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 4419bb3..588bb28 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -87,8 +87,8 @@ class HostModel(object):
                         res['cpu_model'] = line.split(':')[1].strip()
                         break
 
-        res['cpus'] = psutil.NUM_CPUS
-        res['memory'] = psutil.TOTAL_PHYMEM
+        res['cpus'] = 0
+        res['memory'] = 0L
 
         # Include IBM PowerKVM name to supported distro names
         _sup_distros = platform._supported_dists + ('ibm_powerkvm',)
@@ -102,6 +102,8 @@ class HostModel(object):
         return res
 
     def lookup(self, *name):
+        self.host_info['cpus'] = psutil._psplatform.get_num_cpus()
+        self.host_info['memory'] = psutil.phymem_usage().total
         return self.host_info
 
     def swupdate(self, *name):
-- 
1.9.1




More information about the Kimchi-devel mailing list