[Kimchi-devel] [PATCH] Update host number of cpus and total physical memory information
Jose Ricardo Ziviani
joserz at linux.vnet.ibm.com
Fri Mar 20 19:45:45 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.
Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
---
src/kimchi/model/host.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 4419bb3..db14a28 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -87,8 +87,9 @@ 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
+ self._update_host_info(res)
# Include IBM PowerKVM name to supported distro names
_sup_distros = platform._supported_dists + ('ibm_powerkvm',)
@@ -101,7 +102,15 @@ class HostModel(object):
return res
+ def _update_host_info(self, host_info):
+ if not isinstance(host_info, dict):
+ return
+
+ host_info['cpus'] = psutil._psplatform.get_num_cpus()
+ host_info['memory'] = psutil.phymem_usage().total
+
def lookup(self, *name):
+ self._update_host_info(self.host_info)
return self.host_info
def swupdate(self, *name):
--
1.9.1
More information about the Kimchi-devel
mailing list