[Kimchi-devel] [PATCH V2] Number of CPUs in Host's Basic Information.
Paulo Vital
pvital at linux.vnet.ibm.com
Thu Oct 30 14:12:59 UTC 2014
Support to provide the information of the number of on-line CPUs
present in the Host system.
This patch also updated the API.md, mockmodel, unittests and English
help page to express the new information.
Signed-off-by: Paulo Vital <pvital at linux.vnet.ibm.com>
---
docs/API.md | 3 ++-
src/kimchi/mockmodel.py | 3 ++-
src/kimchi/model/host.py | 5 +++--
tests/test_model.py | 3 ++-
tests/test_rest.py | 3 ++-
ui/pages/help/en_US/host.dita | 4 ++--
ui/pages/tabs/host.html.tmpl | 6 +++++-
7 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/docs/API.md b/docs/API.md
index 6984649..fdfb04f 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -790,7 +790,8 @@ Contains information of host.
* **GET**: Retrieve host static information
* memory: Total size of host physical memory
The unit is Bytes
- * cpu: The model name of host CPU
+ * cpu_model: The model name of host CPU
+ * cpus: The number of online CPUs available on host
* os_distro: The OS distribution that runs on host
* os_version: The version of OS distribution
* os_codename: The code name of OS distribution
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index de9df0e..7163f8d 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -936,7 +936,8 @@ class MockModel(object):
def host_lookup(self, *name):
res = {}
res['memory'] = 6114058240
- res['cpu'] = 'Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz'
+ res['cpu_model'] = 'Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz'
+ res['cpus'] = 4
res['os_distro'] = 'Red Hat Enterprise Linux Server'
res['os_version'] = '6.4'
res['os_codename'] = 'Santiago'
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index 1bc3ca2..8cddcdc 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -81,14 +81,15 @@ class HostModel(object):
def _get_host_info(self):
res = {}
if platform.machine().startswith('ppc'):
- res['cpu'] = self._get_ppc_cpu_info()
+ res['cpu_model'] = self._get_ppc_cpu_info()
else:
with open('/proc/cpuinfo') as f:
for line in f.xreadlines():
if "model name" in line:
- res['cpu'] = line.split(':')[1].strip()
+ res['cpu_model'] = line.split(':')[1].strip()
break
+ res['cpus'] = psutil.NUM_CPUS
res['memory'] = psutil.TOTAL_PHYMEM
# Include IBM PowerKVM name to supported distro names
diff --git a/tests/test_model.py b/tests/test_model.py
index 896540d..c06eaae 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -1298,7 +1298,8 @@ class ModelTests(unittest.TestCase):
objstore_loc=self.tmp_store)
info = inst.host_lookup()
distro, version, codename = platform.linux_distribution()
- self.assertIn('cpu', info)
+ self.assertIn('cpu_model', info)
+ self.assertIn('cpus', info)
self.assertEquals(distro, info['os_distro'])
self.assertEquals(version, info['os_version'])
self.assertEquals(unicode(codename, "utf-8"), info['os_codename'])
diff --git a/tests/test_rest.py b/tests/test_rest.py
index 60dce2f..9bc930f 100644
--- a/tests/test_rest.py
+++ b/tests/test_rest.py
@@ -1753,8 +1753,9 @@ class RestTests(unittest.TestCase):
self.assertEquals('6.4', info['os_version'])
self.assertEquals('Santiago', info['os_codename'])
self.assertEquals('Intel(R) Core(TM) i5 CPU M 560 @ 2.67GHz',
- info['cpu'])
+ info['cpu_model'])
self.assertEquals(6114058240, info['memory'])
+ self.assertEquals(4, info['cpus'])
def test_hoststats(self):
stats_keys = ['cpu_utilization', 'memory', 'disk_read_rate',
diff --git a/ui/pages/help/en_US/host.dita b/ui/pages/help/en_US/host.dita
index 335c51c..0dcb670 100644
--- a/ui/pages/help/en_US/host.dita
+++ b/ui/pages/help/en_US/host.dita
@@ -24,8 +24,8 @@ to the host system, if it is not already connected.</li>
<dlentry>
<dt>Basic information</dt>
<dd>This section displays the host operating system distribution,
-version, and code name, as well as the processor type and amount of
-memory in GB.</dd>
+version, and code name, as well as the processor type, the number of
+online CPUs and amount of memory in GB.</dd>
</dlentry><dlentry>
<dt>System statistics</dt>
<dd>This section displays graphs to show statistics for CPU, memory,
diff --git a/ui/pages/tabs/host.html.tmpl b/ui/pages/tabs/host.html.tmpl
index 8641962..81266ce 100644
--- a/ui/pages/tabs/host.html.tmpl
+++ b/ui/pages/tabs/host.html.tmpl
@@ -72,7 +72,11 @@
</div>
<div class="section-row">
<div class="section-label">$_("Processor")</div>
- <div class="section-value">{cpu}</div>
+ <div class="section-value">{cpu_model}</div>
+ </div>
+ <div class="section-row">
+ <div class="section-label">$_("CPU(s)")</div>
+ <div class="section-value">{cpus}</div>
</div>
<div class="section-row">
<div class="section-label">$_("Memory")</div>
--
1.9.3
More information about the Kimchi-devel
mailing list