Implement inspector method - inspect_cpus
zvm inspector method inspect_cpus will return vcpu number and used cpu time to the pollster. Change-Id: I81d2f09b05220f19664f20d7328c6ed653ce3ea2
This commit is contained in:
parent
f4c3964e35
commit
4836e860e2
|
@ -129,7 +129,9 @@ class ZVMInspector(virt_inspector.Inspector):
|
|||
return inst_stat
|
||||
|
||||
def inspect_cpus(self, instance):
|
||||
pass
|
||||
inst_stat = self._get_inst_stat('cpus', instance)
|
||||
return virt_inspector.CPUStats(number=inst_stat['guest_cpus'],
|
||||
time=inst_stat['used_cpu_time'])
|
||||
|
||||
def inspect_memory_usage(self, instance, duration=None):
|
||||
pass
|
||||
|
|
|
@ -146,3 +146,12 @@ class TestZVMInspector(base.BaseTestCase):
|
|||
self.assertEqual(2, inst_stat['guest_cpus'])
|
||||
check_update.assert_called_once_with('cpus')
|
||||
update.assert_called_once_with('cpus', {'inst1': 'INST1'})
|
||||
|
||||
@mock.patch("ceilometer_zvm.compute.virt.zvm.inspector.ZVMInspector."
|
||||
"_get_inst_stat")
|
||||
def test_inspect_cpus(self, get_stat):
|
||||
get_stat.return_value = {'guest_cpus': 2, 'used_cpu_time': 99999999}
|
||||
cpu_stat = self.inspector.inspect_cpus(None)
|
||||
self.assertEqual(2, cpu_stat.number)
|
||||
self.assertEqual(99999999, cpu_stat.time)
|
||||
get_stat.assert_called_once_with('cpus', None)
|
||||
|
|
Loading…
Reference in New Issue